Version 0.9.5
This commit is contained in:
501
block/all_bets.php
Normal file
501
block/all_bets.php
Normal file
@@ -0,0 +1,501 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$start = $this->request->variable('start', 0);
|
||||
$matches_on_matchday = false;
|
||||
|
||||
$sql = 'SELECT COUNT(DISTINCT user_id) AS num_users
|
||||
FROM ' . FOOTB_BETS . "
|
||||
WHERE season = $season AND league = $league";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$total_users = (int) $db->sql_fetchfield('num_users');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT
|
||||
m.match_no,
|
||||
m.status,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
t1.team_name_short AS home_name,
|
||||
t2.team_name_short AS guest_name,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
SUM(IF(b.goals_home + 0 > b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS home,
|
||||
SUM(IF(b.goals_home = b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS draw,
|
||||
SUM(IF(b.goals_home + 0 < b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS guest
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON(b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
GROUP BY m.match_no
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$matches = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$count_matches = sizeof($matches);
|
||||
|
||||
if ($user->data['football_mobile'])
|
||||
{
|
||||
if ($count_matches > 3)
|
||||
{
|
||||
$split_after = 3;
|
||||
$splits = ceil($count_matches / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
$split_after = $count_matches;
|
||||
$splits = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($count_matches > 11)
|
||||
{
|
||||
$split_after = 8;
|
||||
$splits = ceil($count_matches / 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
$split_after = $count_matches;
|
||||
$splits = 1;
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
|
||||
$sql_start = $start * $count_matches;
|
||||
$sql_limit = $config['football_users_per_page'] * $count_matches;
|
||||
|
||||
// If we've got a hightlight set pass it on to pagination.
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
if ($user->data['football_mobile'])
|
||||
{
|
||||
$sql_start = 0;
|
||||
$sql_limit = 99999;
|
||||
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $sql_limit, $start);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
}
|
||||
|
||||
$bet_line = array();
|
||||
if ($count_matches > 0)
|
||||
{
|
||||
$matches_on_matchday = true;
|
||||
|
||||
$sql = "SELECT
|
||||
u.user_id,
|
||||
u.username,
|
||||
m.status,
|
||||
b.goals_home AS bet_home,
|
||||
b.goals_guest AS bet_guest,
|
||||
" . select_points() . '
|
||||
FROM ' . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
ORDER BY LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
||||
$user_bets = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$bet_index = 0;
|
||||
$split_index = 0;
|
||||
foreach ($user_bets AS $user_bet)
|
||||
{
|
||||
if ($bet_index == $count_matches)
|
||||
{
|
||||
$bet_index = 0;
|
||||
$split_index = 0;
|
||||
}
|
||||
if (!($bet_index % $split_after))
|
||||
{
|
||||
$split_index++;
|
||||
}
|
||||
$sum_total[$user_bet['username']] = 0;
|
||||
$bet_line[$split_index][] = $user_bet;
|
||||
$bet_index++;
|
||||
}
|
||||
}
|
||||
$match_index = 0;
|
||||
$last_match_index = 0;
|
||||
$split_index = 0;
|
||||
$matchday_sum_total = 0;
|
||||
$colorstyle_total = ' color_finally';
|
||||
foreach ($matches AS $match)
|
||||
{
|
||||
if (!($match_index % $split_after))
|
||||
{
|
||||
if ($match_index > 0)
|
||||
{
|
||||
$total = 0;
|
||||
$count_user = 0;
|
||||
$bet_index = 0;
|
||||
$last_match_index = 0;
|
||||
foreach ($bet_line[$split_index] AS $user_bet)
|
||||
{
|
||||
if ($bet_index == 0)
|
||||
{
|
||||
$count_user++;
|
||||
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($user_bet['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('match_panel.user_row', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USER_NAME' => $user_bet['username'],
|
||||
)
|
||||
);
|
||||
$total = 0;
|
||||
}
|
||||
$bet_index++;
|
||||
$total += $user_bet['points'];
|
||||
if ($user_bet['status'] < 3)
|
||||
{
|
||||
$colorstyle_total = ' color_provisionally';
|
||||
}
|
||||
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet_home = ($user_bet['bet_home'] == '') ? ' ' : '?';
|
||||
$bet_guest = ($user_bet['bet_guest'] == '') ? ' ' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = $user_bet['bet_home'];
|
||||
$bet_guest = $user_bet['bet_guest'];
|
||||
}
|
||||
|
||||
$colorstyle_bet = color_style($user_bet['status']);
|
||||
$template->assign_block_vars('match_panel.user_row.bet', array(
|
||||
'BET' => $bet_home. ':'. $bet_guest,
|
||||
'COLOR_STYLE' => $colorstyle_bet,
|
||||
'POINTS' => ($user_bet['points'] == '') ? ' ' : $user_bet['points'],
|
||||
)
|
||||
);
|
||||
|
||||
if ($bet_index == $split_after)
|
||||
{
|
||||
$sum_total[$user_bet['username']] += $total;
|
||||
$matchday_sum_total += $total;
|
||||
$bet_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('match_panel.tendency_footer', array(
|
||||
'S_TOTAL' => false,
|
||||
)
|
||||
);
|
||||
foreach ($matches_tendency AS $match_tendency)
|
||||
{
|
||||
$template->assign_block_vars('match_panel.tendency_footer.tendency', array(
|
||||
'TENDENCY' => $match_tendency,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$matches_tendency = array();
|
||||
$split_index++;
|
||||
if ($split_index == $splits)
|
||||
{
|
||||
$display_total = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_total = false;
|
||||
}
|
||||
$template->assign_block_vars('match_panel', array(
|
||||
'S_TOTAL' => $display_total,
|
||||
)
|
||||
);
|
||||
}
|
||||
if (0 == $match['home_id'])
|
||||
{
|
||||
$home_info = get_team($season, $league, $match['match_no'], 'team_id_home', $match['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homename = $home_in_array[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homename = $match['home_name'];
|
||||
}
|
||||
if (0 == $match['guest_id'])
|
||||
{
|
||||
$guest_info = get_team($season, $league, $match['match_no'], 'team_id_guest', $match['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestname = $guest_in_array[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestname = $match['guest_name'];
|
||||
}
|
||||
$colorstyle_match = color_style($match['status']);
|
||||
$template->assign_block_vars('match_panel.match_entry', array(
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'RESULT' => $match['goals_home']. ':'.$match['goals_guest'],
|
||||
'COLOR_STYLE' => $colorstyle_match,
|
||||
)
|
||||
);
|
||||
if ($match['status'] < 1 && !$config['football_view_tendencies'])
|
||||
{
|
||||
// hide tendencies
|
||||
$matches_tendency[] = '?-?-?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$matches_tendency[] = $match['home']. '-'.$match['draw']. '-'.$match['guest'];
|
||||
}
|
||||
$match_index++;
|
||||
$last_match_index++;
|
||||
}
|
||||
if ($count_matches > 0)
|
||||
{
|
||||
$total = 0;
|
||||
$count_user = 0;
|
||||
$bet_index = 0;
|
||||
foreach ($bet_line[$split_index] AS $user_bet)
|
||||
{
|
||||
if ($bet_index == 0)
|
||||
{
|
||||
$count_user++;
|
||||
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($user_bet['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('match_panel.user_row', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USER_NAME' => $user_bet['username'],
|
||||
)
|
||||
);
|
||||
$total = 0;
|
||||
}
|
||||
$bet_index++;
|
||||
$total += $user_bet['points'];
|
||||
if ($user_bet['status'] < 3)
|
||||
{
|
||||
$colorstyle_total = ' color_provisionally';
|
||||
}
|
||||
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet_home = ($user_bet['bet_home'] == '') ? '' : '?';
|
||||
$bet_guest = ($user_bet['bet_guest'] == '') ? '' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = $user_bet['bet_home'];
|
||||
$bet_guest = $user_bet['bet_guest'];
|
||||
}
|
||||
|
||||
$colorstyle_bet = color_style($user_bet['status']);
|
||||
$template->assign_block_vars('match_panel.user_row.bet', array(
|
||||
'BET' => $bet_home. ':'. $bet_guest,
|
||||
'COLOR_STYLE' => $colorstyle_bet,
|
||||
'POINTS' => ($user_bet['points'] == '') ? ' ' : $user_bet['points'],
|
||||
)
|
||||
);
|
||||
|
||||
if ($bet_index == $last_match_index)
|
||||
{
|
||||
$sum_total[$user_bet['username']] += $total;
|
||||
$matchday_sum_total += $total;
|
||||
$template->assign_block_vars('match_panel.user_row.points', array(
|
||||
'COLOR_STYLE' => $colorstyle_total,
|
||||
'POINTS_TOTAL' => $sum_total[$user_bet['username']],
|
||||
)
|
||||
);
|
||||
$bet_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('match_panel.tendency_footer', array(
|
||||
'S_TOTAL' => true,
|
||||
'COLOR_STYLE' => $colorstyle_total, //currently ignored
|
||||
'SUMTOTAL' => $matchday_sum_total,
|
||||
)
|
||||
);
|
||||
foreach ($matches_tendency AS $match_tendency)
|
||||
{
|
||||
$template->assign_block_vars('match_panel.tendency_footer.tendency', array(
|
||||
'TENDENCY' => $match_tendency,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//extra bets
|
||||
// Calculate extra bets of matchday
|
||||
$sql_start = $start;
|
||||
$sql_limit = $config['football_users_per_page'];
|
||||
$sql = "SELECT e.*,
|
||||
t1.team_name AS result_team
|
||||
FROM " . FOOTB_EXTRA . ' AS e
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
|
||||
WHERE e.season = $season
|
||||
AND e.league = $league
|
||||
AND (e.matchday = $matchday OR e.matchday_eval = $matchday)
|
||||
ORDER BY e.extra_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extra_no = $row['extra_no'];
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '1':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
$extra_colorstyle = color_style($row['extra_status']);
|
||||
|
||||
$template->assign_block_vars('extra_panel', array(
|
||||
'QUESTION' => $row['question'],
|
||||
'RESULT' => ($display_type == 1) ? $row['result_team'] : $row['result'],
|
||||
'POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'EVALUATION_TITLE' => $eval_title,
|
||||
'COLOR_STYLE' => $extra_colorstyle,
|
||||
)
|
||||
);
|
||||
|
||||
// Get all extra bets of matchday
|
||||
$bet_number = 0;
|
||||
$sql = "SELECT u.user_id,
|
||||
u.username,
|
||||
e.*,
|
||||
eb.bet,
|
||||
eb.bet_points,
|
||||
t2.team_name AS bet_team
|
||||
FROM " . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
|
||||
LEFT JOIN ' . FOOTB_EXTRA . " AS e ON (e.season = b.season AND e.league = b.league AND (e.matchday = $matchday OR e.matchday_eval = $matchday) AND e.extra_no = $extra_no)
|
||||
LEFT JOIN " . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = b.season AND eb.league = b.league AND eb.extra_no = $extra_no AND eb.user_id = b.user_id)
|
||||
LEFT JOIN " . FOOTB_TEAMS . " AS t2 ON (t2.season = b.season AND t2.league = b.league AND t2.team_id = eb.bet)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND b.match_no = 1
|
||||
GROUP by b.user_id
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$result_bet = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
||||
|
||||
while ($user_row = $db->sql_fetchrow($result_bet))
|
||||
{
|
||||
$bet_number++ ;
|
||||
$row_class = (!($bet_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($user_row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
|
||||
if ($user_row['extra_status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet = ($user_row['bet'] == '') ? ' ' : '?';
|
||||
$bet_team = ($user_row['bet_team'] == NULL) ? ' ' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet = ($user_row['bet'] == '') ? ' ' : $user_row['bet'];
|
||||
$bet_team = ($user_row['bet_team'] == NULL) ? ' ' : $user_row['bet_team'];
|
||||
}
|
||||
|
||||
|
||||
$template->assign_block_vars('extra_panel.user_row', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USER_NAME' => $user_row['username'],
|
||||
'BET' => ($display_type == 1) ? $bet_team : $bet,
|
||||
'BET_POINTS' => $user_row['bet_points'],
|
||||
'COLOR_STYLE' => $extra_colorstyle,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sidename = sprintf($user->lang['ALL_BETS']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_ALL_BETS' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['BET']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['RESULTS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_BET']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RESULTS']),
|
||||
'S_MATCHES_ON_MATCHDAY' => $matches_on_matchday,
|
||||
'S_SPALTEN' => ($count_matches * 2) + 2,
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
)
|
||||
);
|
||||
?>
|
||||
235
block/bank.php
Normal file
235
block/bank.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
|
||||
}
|
||||
|
||||
global $phpbb_extension_manager;
|
||||
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints'))
|
||||
{
|
||||
$this->user->add_lang_ext('dmzx/ultimatepoints', 'common');
|
||||
// Get an instance of the ultimatepoints functions_points
|
||||
$functions_points = $phpbb_container->get('dmzx.ultimatepoints.core.functions.points');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get an instance of the football functions_points
|
||||
$functions_points = $phpbb_container->get('football.football.core.functions.points');
|
||||
}
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league) or $league == 0)
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$username = '';
|
||||
$member = true;
|
||||
if ($this->auth->acl_get('a_football_points'))
|
||||
{
|
||||
$where_user = '';
|
||||
$multi_view = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$multi_view = false;
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$where_user = ' AND b.user_id = ' . $user->data['user_id'] . ' ';
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($league)
|
||||
{
|
||||
$member = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$where_league = '';
|
||||
if ($league)
|
||||
{
|
||||
$where_league = " AND b.league = $league";
|
||||
}
|
||||
|
||||
$data = false;
|
||||
// Select user
|
||||
$total_users = 0;
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE season = $season
|
||||
$where_league
|
||||
$where_user
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$total_users++;
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$where_season = '';
|
||||
if ($season)
|
||||
{
|
||||
$where_season = " AND fp.season = $season";
|
||||
}
|
||||
|
||||
$where_league = '';
|
||||
$order_by = 'ORDER BY fp.points_type ASC, fp.matchday ASC, fp.league ASC';
|
||||
|
||||
if ($league)
|
||||
{
|
||||
$where_league = " AND fp.league = $league";
|
||||
$order_by = 'ORDER BY fp.league ASC, fp.matchday ASC, fp.points_type ASC';
|
||||
}
|
||||
|
||||
// The different book types
|
||||
$types = array(
|
||||
0 => '--',
|
||||
1 => sprintf($user->lang['FOOTBALL_BET_POINTS']),
|
||||
2 => $user->lang['FOOTBALL_DEPOSIT'],
|
||||
3 => sprintf($user->lang['FOOTBALL_WIN']),
|
||||
4 => $user->lang['FOOTBALL_WIN'],
|
||||
5 => $user->lang['FOOTBALL_WIN'],
|
||||
6 => $user->lang['FOOTBALL_WIN'],
|
||||
7 => $user->lang['FOOTBALL_PAYOUT'],
|
||||
);
|
||||
|
||||
// Grab the football points
|
||||
$sql = 'SELECT fp.season,
|
||||
s.season_name,
|
||||
s.season_name_short,
|
||||
fp.league,
|
||||
l.league_name,
|
||||
l.league_name_short,
|
||||
fp.matchday,
|
||||
md.matchday_name,
|
||||
fp.points_type,
|
||||
fp.points,
|
||||
fp.points_comment,
|
||||
fp.cash
|
||||
FROM ' . FOOTB_POINTS . ' AS fp
|
||||
INNER JOIN ' . FOOTB_SEASONS . ' AS s ON (s.season = fp.season)
|
||||
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = fp.season AND l.league = fp.league)
|
||||
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = fp.season AND md.league = fp.league AND md.matchday = fp.matchday)
|
||||
WHERE user_id = ' . (int) $user_sel . "
|
||||
$where_season
|
||||
$where_league
|
||||
$order_by";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$current_balance = 0.00;
|
||||
$count = 0;
|
||||
// Start looping all the football points
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$count = $count + 1;
|
||||
if ($row['points_type'] == POINTS_BET OR $row['points_type'] == POINTS_PAID)
|
||||
{
|
||||
$points_sign = '-';
|
||||
$points_style = " color: red;";
|
||||
$current_balance -= $row['points'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$points_sign = '+';
|
||||
$points_style = " color: green;";
|
||||
$current_balance += $row['points'];
|
||||
}
|
||||
// Add the items to the template
|
||||
$template->assign_block_vars('football', array(
|
||||
'SEASON' => $season,
|
||||
'SEASON_NAME' => $season_name,
|
||||
'LEAGUE' => $row['league'],
|
||||
'LEAGUE_NAME' => $row['league_name'],
|
||||
'LEAGUE_SHORT' => $row['league_name_short'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'MATCHDAY_NAME' => ($row['matchday_name'] == '') ? $row['matchday'] . '.' . sprintf($user->lang['FOOTBALL_MATCHDAY']) : $row['matchday_name'],
|
||||
'MATCHDAY_SHORT'=> $row['matchday'] . '.' . sprintf($user->lang['MATCHDAY_SHORT']),
|
||||
'POINTS_SIGN' => $points_sign,
|
||||
'POINTS_STYLE' => $points_style,
|
||||
'POINTS_TYPE' => $types[$row['points_type']],
|
||||
'S_CASH' => $row['cash'],
|
||||
'POINTS' => $functions_points->number_format_points($row['points']),
|
||||
'COMMENT' => nl2br($row['points_comment']),
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($current_balance < 0)
|
||||
{
|
||||
$points_style = " color: red;";
|
||||
}
|
||||
else
|
||||
{
|
||||
$points_style = " color: green;";
|
||||
}
|
||||
|
||||
$template->assign_block_vars('football', array(
|
||||
'SEASON' => $season,
|
||||
'SEASON_NAME' => '',
|
||||
'LEAGUE' => $league,
|
||||
'LEAGUE_NAME' => '',
|
||||
'MATCHDAY' => '',
|
||||
'MATCHDAY_NAME' => '',
|
||||
'POINTS_SIGN' => '',
|
||||
'POINTS_STYLE' => $points_style,
|
||||
'POINTS_TYPE' => '',
|
||||
'S_CASH' => 1,
|
||||
'POINTS' => $functions_points->number_format_points($current_balance),
|
||||
'COMMENT' => ($league == 0) ? sprintf($user->lang['FOOTBALL_BALANCES']) : sprintf($user->lang['FOOTBALL_BALANCE']),
|
||||
));
|
||||
|
||||
$sidename = sprintf($user->lang['FOOTBALL_BANK']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_BANK' => true,
|
||||
'S_MATCHDAY_HIDE' => true,
|
||||
'S_MEMBER' => $member,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_MULTI_VIEW' => $multi_view,
|
||||
'L_TOTAL_ENTRIES' => ($count == 1) ? $count . ' ' .sprintf($user->lang['FOOTBALL_RECORD']) : $count . ' ' .sprintf($user->lang['FOOTBALL_RECORDS']),
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['RANK_TOTAL']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_BETS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_TOTAL']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_BETS']),
|
||||
'USERNAME' => $username,
|
||||
'POINTS' => $config['football_win_name'],
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
534
block/bet.php
Normal file
534
block/bet.php
Normal file
@@ -0,0 +1,534 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$edit_mode = false;
|
||||
$data_group = false;
|
||||
$data_bet_results = false;
|
||||
$data_bet = false;
|
||||
$join_league = false;
|
||||
$matchnumber = 0;
|
||||
$userid = $user->data['user_id'];
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
$user_is_member = user_is_member($userid, $season, $league);
|
||||
$display_rating = false;
|
||||
|
||||
// Calculate multiple delivery
|
||||
$display_delivery2 = false;
|
||||
$display_delivery3 = false;
|
||||
$delivery2 = '';
|
||||
$delivery3 = '';
|
||||
$sql = "SELECT
|
||||
delivery_date_2,
|
||||
delivery_date_3,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(delivery_date_2,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(delivery_date_2,' %d.%m.%Y %H:%i')
|
||||
) as deliverytime2,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(delivery_date_3,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(delivery_date_3,' %d.%m.%Y %H:%i')
|
||||
) as deliverytime3
|
||||
FROM " . FOOTB_MATCHDAYS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday = $matchday";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['delivery_date_2'] <> '')
|
||||
{
|
||||
$display_delivery2 = true;
|
||||
$delivery2 = $row['deliverytime2'];
|
||||
}
|
||||
if ($row['delivery_date_3'] <> '')
|
||||
{
|
||||
$display_delivery3 = true;
|
||||
$delivery3 = $row['deliverytime3'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Calculate matches and bets of matchday
|
||||
$sql = "SELECT
|
||||
m.league,
|
||||
m.match_no,
|
||||
m.matchday,
|
||||
m.status,
|
||||
m.group_id,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
t1.team_symbol AS home_symbol,
|
||||
t2.team_symbol AS guest_symbol,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
t1.team_name AS home_name,
|
||||
t2.team_name AS guest_name,
|
||||
t1.team_name_short AS home_short,
|
||||
t2.team_name_short AS guest_short,
|
||||
b.goals_home AS bet_home,
|
||||
b.goals_guest AS bet_guest,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
m.trend,
|
||||
m.odd_1,
|
||||
m.odd_x,
|
||||
m.odd_2,
|
||||
m.rating,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.match_datetime,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.match_datetime,' %d.%m. %H:%i')
|
||||
) AS match_time,
|
||||
" . select_points() . '
|
||||
FROM ' . FOOTB_MATCHES . ' AS m
|
||||
INNER JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no AND b.user_id = $userid)
|
||||
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
GROUP BY m.match_no
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_bet = true;
|
||||
$matchnumber++ ;
|
||||
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$display_link = true;
|
||||
$display_rating = ($display_rating || ($row['rating'] <> '0.00'));
|
||||
|
||||
if (0 == $row['home_id'])
|
||||
{
|
||||
$display_link = false;
|
||||
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homelogo = $home_in_array[0];
|
||||
$homeid = $home_in_array[1];
|
||||
$homename = $home_in_array[2];
|
||||
$homeshort = $home_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homelogo = $row['home_symbol'];
|
||||
$homeid = $row['home_id'];
|
||||
$homename = $row['home_name'];
|
||||
$homeshort = $row['home_short'];
|
||||
}
|
||||
|
||||
if (0 == $row['guest_id'])
|
||||
{
|
||||
$display_link = false;
|
||||
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestlogo = $guest_in_array[0];
|
||||
$guestid = $guest_in_array[1];
|
||||
$guestname = $guest_in_array[2];
|
||||
$guestshort = $guest_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestlogo = $row['guest_symbol'];
|
||||
$guestid = $row['guest_id'];
|
||||
$guestname = $row['guest_name'];
|
||||
$guestshort = $row['guest_short'];
|
||||
}
|
||||
if ($homelogo <> '')
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($guestlogo <> '')
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($row['status'] == -1)
|
||||
{
|
||||
$delivertag = "<strong style='color:green'>*</strong>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($row['status'] == -2)
|
||||
{
|
||||
$delivertag = "<strong style='color:green'>**</strong>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$delivertag = '';
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['group_id'] == '')
|
||||
{
|
||||
$group_id = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_group = true;
|
||||
$group_id = $row['group_id'];
|
||||
}
|
||||
|
||||
if ($row['status'] <= 0)
|
||||
{
|
||||
$edit_mode = true;
|
||||
$template->assign_block_vars('bet_edit', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LEAGUE_ID' => $row['league'],
|
||||
'MATCH_NUMBER' => $row['match_no'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'STATUS' => $row['status'],
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'HOME_ID' => $homeid,
|
||||
'GUEST_ID' => $guestid,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'HOME_SHORT' => $homeshort,
|
||||
'GUEST_SHORT' => $guestshort,
|
||||
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
|
||||
'tid' => $homeid, 'mode' => 'all')),
|
||||
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
|
||||
'tid' => $guestid, 'mode' => 'all')),
|
||||
'BET_HOME' => $row['bet_home'],
|
||||
'BET_GUEST' => $row['bet_guest'],
|
||||
'DELIVERTAG' => $delivertag,
|
||||
'GOALS_HOME' => ($row['goals_home'] == '') ? ' ' : $row['goals_home'],
|
||||
'GOALS_GUEST' => ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'],
|
||||
'POINTS' => ($row['points'] == '') ? ' ' : $row['points'],
|
||||
'U_MATCH_STATS' => $this->helper->route('football_football_popup', array('popside' => 'hist_popup', 's' => $season, 'l' => $row['league'],
|
||||
'hid' => $homeid, 'gid' => $guestid, 'm' => $row['matchday'],
|
||||
'mn' => $row['match_no'], 'gr' => $row['group_id'])),
|
||||
'DATA_RESULTS' => $data_bet_results,
|
||||
'DISPLAY_LINK' => $display_link,
|
||||
'TREND' => $row['trend'],
|
||||
'ODDS' => ($row['odd_1'] == '') ? '' : $row['odd_1'] . '|' . $row['odd_x'] . '|' . $row['odd_2'],
|
||||
'RATING' => $row['rating'],
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_bet_results = true;
|
||||
$colorstyle = color_style($row['status']);
|
||||
|
||||
$template->assign_block_vars('bet_view', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LEAGUE_ID' => $row['league'],
|
||||
'MATCH_NUMBER' => $row['match_no'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'STATUS' => $row['status'],
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'HOME_ID' => $homeid,
|
||||
'GUEST_ID' => $guestid,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'HOME_SHORT' => $homeshort,
|
||||
'GUEST_SHORT' => $guestshort,
|
||||
'BET_HOME' => ($row['bet_home'] == '') ? ' ' : $row['bet_home'],
|
||||
'BET_GUEST' => ($row['bet_guest'] == '') ? ' ' : $row['bet_guest'],
|
||||
'GOALS_HOME' => ($row['goals_home'] == '') ? ' ' : $row['goals_home'],
|
||||
'GOALS_GUEST' => ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'],
|
||||
'POINTS' => ($row['points'] == '') ? ' ' : $row['points'],
|
||||
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
|
||||
'tid' => $homeid, 'mode' => 'all')),
|
||||
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
|
||||
'tid' => $guestid, 'mode' => 'all')),
|
||||
'U_MATCH_STATS' => $this->helper->route('football_football_popup', array('popside' => 'hist_popup', 's' => $season, 'l' => $row['league'],
|
||||
'hid' => $homeid, 'gid' => $guestid, 'm' => $row['matchday'],
|
||||
'mn' => $row['match_no'], 'gr' => $row['group_id'])),
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'DISPLAY_LINK' => $display_link,
|
||||
'TREND' => $row['trend'],
|
||||
'ODDS' => ($row['odd_1'] == '') ? '' : $row['odd_1'] . '|' . $row['odd_x'] . '|' . $row['odd_2'],
|
||||
'RATING' => $row['rating'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Calculate extra bets of matchday
|
||||
// Start select team
|
||||
$sql = 'SELECT
|
||||
team_id AS option_value,
|
||||
team_name AS option_name
|
||||
FROM ' . FOOTB_TEAMS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY team_name ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$option_rows = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT e.*,
|
||||
eb.bet,
|
||||
eb.bet_points,
|
||||
t1.team_name AS result_team,
|
||||
t2.team_name AS bet_team
|
||||
FROM " . FOOTB_EXTRA . ' AS e
|
||||
LEFT JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season AND eb.league = e.league AND eb.extra_no = e.extra_no AND eb.user_id = $userid)
|
||||
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = e.season AND t2.league = e.league AND t2.team_id = eb.bet)
|
||||
WHERE e.season = $season
|
||||
AND e.league = $league
|
||||
AND e.matchday = $matchday
|
||||
ORDER BY e.extra_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extra_bet = false;
|
||||
$extra_edit = false;
|
||||
$extra_results = false;
|
||||
$extranumber = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extra_bet = true;
|
||||
$extranumber++ ;
|
||||
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '1':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($row['extra_status'] <= 0)
|
||||
{
|
||||
// edit extra bets
|
||||
$extra_edit = true;
|
||||
$bet_extra = ($row['bet_team'] == NULL) ? '' : $row['bet_team'];
|
||||
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '3':
|
||||
case '4':
|
||||
{
|
||||
$option_arr = array();
|
||||
for ($i = 65; $i <= 72; $i++)
|
||||
{
|
||||
if (strstr($row['question'], chr($i) . ':'))
|
||||
{
|
||||
$option_arr[] = array(
|
||||
'option_value' => chr($i),
|
||||
'option_name' => chr($i),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (sizeof($option_arr) > 1)
|
||||
{
|
||||
$display_type = 1;
|
||||
$option_rows = $option_arr;
|
||||
$bet_extra = $row['bet'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('extra_edit', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'EXTRA_NO' => $row['extra_no'],
|
||||
'QUESTION' => $row['question'],
|
||||
'EXTRA_POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'EVALUATION_TITLE' => $eval_title,
|
||||
'BET' => ($display_type == 1) ? $bet_extra : $row['bet'],
|
||||
'S_DISPLAY_TYPE' => $display_type,
|
||||
)
|
||||
);
|
||||
|
||||
if ($display_type == 1)
|
||||
{
|
||||
$selected = ($row['bet'] == '') ? ' selected="selected"' : '';
|
||||
|
||||
$template->assign_block_vars('extra_edit.extra_option', array(
|
||||
'OPTION_VALUE' => '',
|
||||
'OPTION_NAME' => sprintf($user->lang['SELECT']),
|
||||
'S_SELECTED' => $selected));
|
||||
|
||||
foreach ($option_rows as $option_row)
|
||||
{
|
||||
$selected = ($row['bet'] && $option_row['option_value'] == $row['bet']) ? ' selected="selected"' : '';
|
||||
$template->assign_block_vars('extra_edit.extra_option', array(
|
||||
'OPTION_VALUE' => $option_row['option_value'],
|
||||
'OPTION_NAME' => $option_row['option_name'],
|
||||
'S_SELECTED' => $selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// view extra bets
|
||||
$extra_results = true;
|
||||
$extra_colorstyle = color_style($row['extra_status']);
|
||||
$extra_result = ($row['result'] == '') ? ' ' : $row['result'];
|
||||
$result_extra = ($row['result_team'] == NULL) ? ' ' : $row['result_team'];
|
||||
$bet = ($row['bet'] == '') ? ' ' : $row['bet'];
|
||||
$bet_extra = ($row['bet_team'] == NULL) ? ' ' : $row['bet_team'];
|
||||
|
||||
$template->assign_block_vars('extra_view', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'QUESTION' => $row['question'],
|
||||
'EXTRA_POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'EVALUATION_TITLE' => $eval_title,
|
||||
'RESULT' => ($display_type == 1) ? $result_extra : $extra_result,
|
||||
'BET' => ($display_type == 1) ? $bet_extra : $bet,
|
||||
'BET_POINTS' => $row['bet_points'],
|
||||
'COLOR_STYLE' => $extra_colorstyle,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$league_info = league_info($season, $league);
|
||||
$bet_explain = '';
|
||||
switch ($league_info['bet_ko_type'])
|
||||
{
|
||||
case BET_KO_90:
|
||||
$bet_explain = sprintf($user->lang['MIN90']);
|
||||
break;
|
||||
case BET_KO_EXTRATIME:
|
||||
$bet_explain = sprintf($user->lang['EXTRATIME_SHORT']);
|
||||
break;
|
||||
case BET_KO_PENALTY:
|
||||
$bet_explain = sprintf($user->lang['PENALTY']);
|
||||
break;
|
||||
default:
|
||||
$bet_explain = sprintf($user->lang['MIN90']);
|
||||
break;
|
||||
}
|
||||
|
||||
$link_rules = '';
|
||||
if (!$data_bet AND join_allowed($season, $league) AND $user->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
if ($league_info["rules_post_id"])
|
||||
{
|
||||
$join_league = true;
|
||||
$link_rules = append_sid($phpbb_root_path . "viewtopic.$phpEx?p=" . $league_info["rules_post_id"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$link_rules = '';
|
||||
}
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['BET']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_BET' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'BET_EXPLAIN' => $bet_explain,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'stat_results', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['STAT_RESULTS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['ALL_BETS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_STAT_RESULTS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_ALL_BETS']),
|
||||
'JOIN_LEAGUE' => ($link_rules == '') ? '' : sprintf($user->lang['JOIN_LEAGUE'], $link_rules),
|
||||
'S_FORM_ACTION_BET' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'bet')),
|
||||
'S_FORM_ACTION_JOIN' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'join')),
|
||||
'S_USER_IS_MEMBER' => $user_is_member,
|
||||
'S_DATA_BET' => $data_bet,
|
||||
'S_DATA_GROUP' => $data_group,
|
||||
'S_DATA_BET_RESULTS' => $data_bet_results,
|
||||
'S_EDIT_MODE' => $edit_mode,
|
||||
'S_DISPLAY_DELIVERY2' => $display_delivery2,
|
||||
'S_DISPLAY_DELIVERY3' => $display_delivery3,
|
||||
'S_DELIVERY2' => $delivery2,
|
||||
'S_DELIVERY3' => $delivery3,
|
||||
'S_JOIN_LEAGUE' => $join_league,
|
||||
'S_EXTRA_BET' => $extra_bet,
|
||||
'S_EXTRA_RESULTS' => $extra_results,
|
||||
'S_EXTRA_EDIT' => $extra_edit,
|
||||
'S_DISPLAY_RATING' => $display_rating,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
391
block/bet_popup.php
Normal file
391
block/bet_popup.php
Normal file
@@ -0,0 +1,391 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
// Can this user view Prediction Leagues pages?
|
||||
if (!$config['football_guest_view'])
|
||||
{
|
||||
if ($user->data['user_id'] == ANONYMOUS)
|
||||
{
|
||||
trigger_error('NO_GUEST_VIEW');
|
||||
}
|
||||
}
|
||||
if (!$config['football_user_view'])
|
||||
{
|
||||
// Only Prediction League member should see this page
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
}
|
||||
|
||||
// Football disabled?
|
||||
if ($config['football_disable'])
|
||||
{
|
||||
$message = (!empty($config['football_disable_msg'])) ? $config['football_disable_msg'] : 'FOOTBALL_DISABLED';
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
$userid = $this->request->variable('u', 0);
|
||||
$season = $this->request->variable('s', 0);
|
||||
$league = $this->request->variable('l', 0);
|
||||
$matchday = $this->request->variable('m', 0);
|
||||
|
||||
$error_message = '';
|
||||
$username = '?';
|
||||
if (!$userid OR !$season OR !$league OR !$matchday)
|
||||
{
|
||||
$data_bet = false;
|
||||
if (!$userid)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
|
||||
}
|
||||
if (!$season)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
}
|
||||
if (!$league)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
}
|
||||
if (!$matchday)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_MATCHDAY']) . '<br />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$season_info = season_info($season);
|
||||
if (sizeof($season_info))
|
||||
{
|
||||
$league_info = league_info($season, $league);
|
||||
if (sizeof($league_info))
|
||||
{
|
||||
// Get username
|
||||
$sql = 'SELECT username
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_id = $userid ";
|
||||
$result = $db->sql_query($sql);
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$username = $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_bet = false;
|
||||
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$display_group = false;
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
// Required for select_points function:
|
||||
$league_info = league_info($season, $league);
|
||||
|
||||
// Calculate matches and bets of matchday
|
||||
$sql = "SELECT
|
||||
m.league,
|
||||
m.match_no,
|
||||
m.matchday,
|
||||
m.status,
|
||||
m.group_id,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
t1.team_symbol AS home_symbol,
|
||||
t2.team_symbol AS guest_symbol,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
t1.team_name AS home_name,
|
||||
t2.team_name AS guest_name,
|
||||
b.goals_home AS bet_home,
|
||||
b.goals_guest AS bet_guest,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.match_datetime,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.match_datetime,' %d.%m. %H:%i')
|
||||
) AS match_time,
|
||||
" . select_points() . "
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
INNER JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no AND b.user_id = $userid)
|
||||
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
GROUP BY m.match_no
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_bet = true;
|
||||
$matchnumber = 0;
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
do
|
||||
{
|
||||
$matchnumber++ ;
|
||||
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$display_link = true;
|
||||
if (0 == $row['home_id'])
|
||||
{
|
||||
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homelogo = $home_in_array[0];
|
||||
$homeid = $home_in_array[1];
|
||||
$homename = $home_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homelogo = $row['home_symbol'];
|
||||
$homeid = $row['home_id'];
|
||||
$homename = $row['home_name'];
|
||||
}
|
||||
if (0 == $row['guest_id'])
|
||||
{
|
||||
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestlogo = $guest_in_array[0];
|
||||
$guestid = $guest_in_array[1];
|
||||
$guestname = $guest_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestlogo = $row['guest_symbol'];
|
||||
$guestid = $row['guest_id'];
|
||||
$guestname = $row['guest_name'];
|
||||
}
|
||||
if ($homelogo <> '')
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
if ($guestlogo <> '')
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($row['group_id'] == '')
|
||||
{
|
||||
$group_id = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_group = true;
|
||||
$group_id = $row['group_id'];
|
||||
}
|
||||
|
||||
|
||||
if ($row['status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet_home = ($row['bet_home'] == '') ? ' ' : '?';
|
||||
$bet_guest = ($row['bet_guest'] == '') ? ' ' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = ($row['bet_home'] == '') ? ' ' : $row['bet_home'];
|
||||
$bet_guest = ($row['bet_guest'] == '') ? ' ' : $row['bet_guest'];
|
||||
}
|
||||
|
||||
$colorstyle = color_style($row['status']);
|
||||
$template->assign_block_vars('bet_view', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LEAGUE_ID' => $row['league'],
|
||||
'MATCH_NUMBER' => $row['match_no'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'STATUS' => $row['status'],
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'HOME_ID' => $homeid,
|
||||
'GUEST_ID' => $guestid,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'BET_HOME' => $bet_home,
|
||||
'BET_GUEST' => $bet_guest,
|
||||
'GOALS_HOME' => ($row['goals_home'] == '') ? ' ' : $row['goals_home'],
|
||||
'GOALS_GUEST' => ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'],
|
||||
'POINTS' => ($row['points'] == '') ? ' ' : $row['points'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
)
|
||||
);
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_bet = false;
|
||||
$error_message .= sprintf($user->lang['NO_BETS']) . '<br />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_bet = false;
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_bet = false;
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate extra bets of matchday
|
||||
$sql = "SELECT e.*,
|
||||
eb.bet,
|
||||
eb.bet_points,
|
||||
t1.team_name AS result_team,
|
||||
t2.team_name AS bet_team
|
||||
FROM " . FOOTB_EXTRA . ' AS e
|
||||
LEFT JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season AND eb.league = e.league AND eb.extra_no = e.extra_no AND eb.user_id = $userid)
|
||||
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = e.season AND t2.league = e.league AND t2.team_id = eb.bet)
|
||||
WHERE e.season = $season
|
||||
AND e.league = $league
|
||||
AND e.matchday = $matchday
|
||||
ORDER BY e.extra_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extra_bet = false;
|
||||
$extranumber = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extra_bet = true;
|
||||
$extranumber++ ;
|
||||
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
|
||||
if ($row['extra_status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet = ($row['bet'] == '') ? ' ' : '?';
|
||||
$bet_team = ($row['bet_team'] == NULL) ? ' ' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet = ($row['bet'] == '') ? ' ' : $row['bet'];
|
||||
$bet_team = ($row['bet_team'] == NULL) ? ' ' : $row['bet_team'];
|
||||
}
|
||||
$extra_colorstyle = color_style($row['extra_status']);
|
||||
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '1':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('extra_view', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'QUESTION' => $row['question'],
|
||||
'EXTRA_POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'EVALUATION_TITLE' => $eval_title,
|
||||
'RESULT' => ($display_type == 1) ? $row['result_team'] : $row['result'],
|
||||
'BET' => ($display_type == 1) ? $bet_team : $bet,
|
||||
'BET_POINTS' => $row['bet_points'],
|
||||
'COLOR_STYLE' => $extra_colorstyle,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['BET']);
|
||||
if ($data_bet)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_USER_NAME' => $username,
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'S_FROM' => sprintf($user->lang['FROM_DAY_SEASON'], $matchday, $season),
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'S_DATA_BET' => $data_bet,
|
||||
'S_DISPLAY_GROUP' => $display_group,
|
||||
'S_EXTRA_BET' => $extra_bet,
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header(sprintf($user->lang['BETS_OF']) . ' ' . $username);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_USER_NAME' => '',
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'S_FROM' => '',
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'S_DATA_BET' => $data_bet,
|
||||
'S_DISPLAY_GROUP' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header(sprintf($user->lang['BETS_OF']));
|
||||
}
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => 'bet_popup.html')
|
||||
);
|
||||
|
||||
page_footer();
|
||||
?>
|
||||
157
block/delivery.php
Normal file
157
block/delivery.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?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_delivery = false;
|
||||
$user_id = $user->data['user_id'];
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
$index = 0;
|
||||
$local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
|
||||
$sql = "(SELECT
|
||||
m.season,
|
||||
m.league,
|
||||
m.matchday,
|
||||
l.league_name_short,
|
||||
CASE m.matchday_name
|
||||
WHEN ''
|
||||
THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
|
||||
ELSE m.matchday_name
|
||||
END AS matchday_name,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.delivery_date,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.delivery_date,' %d.%m.%y %H:%i')
|
||||
) as delivery_time,
|
||||
m.delivery_date AS delivery,
|
||||
SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
|
||||
COUNT(*) AS matches_count,
|
||||
SUM(IF(eb.extra_no > 0, IF(eb.bet = '', 0, 1), 0)) AS extra_bets_count,
|
||||
SUM(IF(e.extra_no > 0, 1, 0)) AS extra_count
|
||||
FROM " . FOOTB_MATCHDAYS . " AS m
|
||||
JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league)
|
||||
JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = 0)
|
||||
JOIN " . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
|
||||
LEFT JOIN " . FOOTB_EXTRA . " AS e ON (e.season = m.season AND e.league = m.league AND e.matchday = m.matchday AND e.extra_status = 0)
|
||||
LEFT JOIN " . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = m.season AND eb.league = m.league AND eb.extra_no = e.extra_no AND eb.user_id = $user_id)
|
||||
WHERE m.delivery_date > FROM_UNIXTIME('$local_board_time')
|
||||
AND m.status <= 0
|
||||
GROUP BY m.delivery_date, m.league, b.user_id
|
||||
)
|
||||
UNION
|
||||
(SELECT
|
||||
m.season,
|
||||
m.league,
|
||||
m.matchday,
|
||||
l.league_name_short,
|
||||
CASE m.matchday_name
|
||||
WHEN ''
|
||||
THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
|
||||
ELSE m.matchday_name
|
||||
END AS matchday_name,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.delivery_date_2,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.delivery_date_2,' %d.%m.%y %H:%i')
|
||||
) as delivery_time,
|
||||
m.delivery_date_2 AS delivery ,
|
||||
SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
|
||||
COUNT(*) AS matches_count,
|
||||
0 AS extra_bets_count,
|
||||
0 AS extra_count
|
||||
FROM " . FOOTB_MATCHDAYS . " AS m
|
||||
JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league)
|
||||
JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = -1)
|
||||
JOIN " . FOOTB_BETS . " AS b ON (b.season = ma.season AND b.league = ma.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
|
||||
WHERE m.delivery_date_2 > FROM_UNIXTIME('$local_board_time')
|
||||
AND m.status <= 0
|
||||
GROUP BY m.delivery_date, m.league, b.user_id
|
||||
)
|
||||
UNION
|
||||
(SELECT
|
||||
m.season,
|
||||
m.league,
|
||||
m.matchday,
|
||||
l.league_name_short,
|
||||
CASE m.matchday_name
|
||||
WHEN ''
|
||||
THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
|
||||
ELSE m.matchday_name
|
||||
END AS matchday_name,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.delivery_date_3,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.delivery_date_3,' %d.%m.%y %H:%i')
|
||||
) as delivery_time,
|
||||
m.delivery_date_3 AS delivery,
|
||||
SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
|
||||
COUNT(*) AS matches_count,
|
||||
0 AS extra_bets_count,
|
||||
0 AS extra_count
|
||||
FROM " . FOOTB_MATCHDAYS . " AS m
|
||||
JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league)
|
||||
JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = -2)
|
||||
JOIN " . FOOTB_BETS . " AS b ON (b.season = ma.season AND b.league = ma.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
|
||||
WHERE m.delivery_date_3 > FROM_UNIXTIME('$local_board_time')
|
||||
AND m.status <= 0
|
||||
GROUP BY m.delivery_date, m.league, b.user_id
|
||||
)
|
||||
ORDER BY delivery, league";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result) AND $index < 11)
|
||||
{
|
||||
$index++;
|
||||
$data_delivery = true;
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
|
||||
$template->assign_block_vars('delivery', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'U_BET_LINK' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $row['season'], 'l' => $row['league'], 'm' => $row['matchday'])),
|
||||
'LEAGUE_SHORT' => $row['league_name_short'],
|
||||
'MATCHDAY_NAME' => $row['matchday_name'],
|
||||
'COLOR' => ($row['bets_count'] == $row['matches_count'] && $row['extra_bets_count'] == $row['extra_count']) ? 'green' : 'red',
|
||||
'TITLE' => ($row['bets_count'] == $row['matches_count']) ? sprintf($user->lang['DELIVERY_READY']) : sprintf($user->lang['DELIVERY_NOT_READY']),
|
||||
'DELIVERY' => $row['delivery_time'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_DELIVERY' => $data_delivery,
|
||||
'S_DATA_DELIVERY' => $data_delivery,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
134
block/dload_bank.php
Normal file
134
block/dload_bank.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
$this->user->add_lang_ext('football/football', 'info_acp_bank');
|
||||
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
|
||||
$action='';
|
||||
$phpbb_root_path = './../../';
|
||||
|
||||
if (!$season OR !$league)
|
||||
{
|
||||
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$season_info = season_info($season);
|
||||
if (!sizeof($season_info))
|
||||
{
|
||||
$error_message = sprintf($user->lang['NO_SEASON']);
|
||||
trigger_error($error_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$league_info = league_info($season, $league);
|
||||
if (!sizeof($league_info))
|
||||
{
|
||||
$error_message = sprintf($user->lang['NO_LEAGUE']);
|
||||
trigger_error($error_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_points = $league_info['bet_points'];
|
||||
$league_name =$league_info['league_name'];
|
||||
$league_short =$league_info['league_name_short'];
|
||||
|
||||
$user_points = '';
|
||||
global $phpbb_extension_manager;
|
||||
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'])
|
||||
{
|
||||
$user_points = 'u.user_points,';
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_points = "0.00 AS user_points,";
|
||||
}
|
||||
|
||||
// Grab the members points
|
||||
$sql = "SELECT
|
||||
b.user_id,
|
||||
u.username,
|
||||
$user_points
|
||||
$bet_points AS bet_points,
|
||||
SUM(IF(p.points_type = " . POINTS_BET . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_bet_points,
|
||||
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_deposit,
|
||||
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
|
||||
IF(p.cash = 0, p.points, 0.00),
|
||||
0.00)) AS no_cash_wins,
|
||||
SUM(IF(p.points_type = ' . POINTS_PAID . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_paid,
|
||||
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', p.points, 0.00)) AS deposit,
|
||||
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)) > 0,
|
||||
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)), 0.00) AS new_deposit,
|
||||
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
|
||||
p.points, 0.00)) AS wins,
|
||||
SUM(IF(p.points_type = ' . POINTS_PAID . ', p.points, 0.00)) AS paid,
|
||||
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)) > 0,
|
||||
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)), 0.00) AS new_pay
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
|
||||
LEFT JOIN ' . FOOTB_POINTS . " AS p ON (p.season = $season AND p.league = $league AND p.user_id = b.user_id)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND b.match_no = 1
|
||||
GROUP BY b.user_id
|
||||
ORDER BY u.username ASC";
|
||||
|
||||
if(!$result = $db->sql_query($sql))
|
||||
{
|
||||
trigger_error('NO_LEAGUE');
|
||||
}
|
||||
$user_rows = $db->sql_fetchrowset($result);
|
||||
$export_file = $league_short . '_' . $season . '_bank.csv';
|
||||
$newline = "\r\n";
|
||||
header('Pragma: no-cache');
|
||||
header("Content-Type: text/csv; name=\"$export_file\"");
|
||||
header("Content-disposition: attachment; filename=$export_file");
|
||||
$export= '';
|
||||
$export .= $league_name . ' ' . sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
|
||||
$export .= sprintf($user->lang['NAME']) . ';' . $config['football_win_name'] . ';' . sprintf($user->lang['BET_POINTS']) . ';' .
|
||||
sprintf($user->lang['DEPOSITED']) . ';' . sprintf($user->lang['DEPOSIT']) . ';' . sprintf($user->lang['WINS']) . ';' .
|
||||
sprintf($user->lang['PAID']) . ';' . sprintf($user->lang['PAYOUT']) . ';' . $newline;
|
||||
|
||||
$curr_season = curr_season();
|
||||
foreach ($user_rows as $user_row)
|
||||
{
|
||||
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'] && $season == $curr_season)
|
||||
{
|
||||
$no_cash_bet_points = ($user_row['no_cash_bet_points'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_bet_points']) . ')';
|
||||
$no_cash_deposit = ($user_row['no_cash_deposit'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_deposit']) . ')';
|
||||
$no_cash_wins = ($user_row['no_cash_wins'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_wins']) . ')';
|
||||
$no_cash_paid = ($user_row['no_cash_paid'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_paid']) . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_cash_bet_points = '';
|
||||
$no_cash_deposit = '';
|
||||
$no_cash_wins = '';
|
||||
$no_cash_paid = '';
|
||||
}
|
||||
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
|
||||
str_replace('.', ',', $user_row['user_points']) . ';' .
|
||||
str_replace('.', ',', $user_row['bet_points']) . $no_cash_bet_points . ';' .
|
||||
str_replace('.', ',', $user_row['deposit']) . $no_cash_deposit . ';' .
|
||||
str_replace('.', ',', $user_row['new_deposit']) . ';' .
|
||||
str_replace('.', ',', $user_row['wins']) . $no_cash_wins . ';' .
|
||||
str_replace('.', ',', $user_row['paid']) . $no_cash_paid . ';' .
|
||||
str_replace('.', ',', $user_row['new_pay']) . ';' . $newline;
|
||||
}
|
||||
echo utf8_decode($export);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
87
block/dload_bank_open.php
Normal file
87
block/dload_bank_open.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
$this->user->add_lang_ext('football/football', 'info_acp_bank');
|
||||
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
|
||||
$action='';
|
||||
|
||||
if (!$season)
|
||||
{
|
||||
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$season_info = season_info($season);
|
||||
if (!sizeof($season_info))
|
||||
{
|
||||
$error_message = sprintf($user->lang['NO_SEASON']);
|
||||
trigger_error($error_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grab the members points
|
||||
$sql = 'SELECT
|
||||
u.username,
|
||||
p.season,
|
||||
p.league,
|
||||
round(sum(if(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)),2) as saldo
|
||||
FROM ' . FOOTB_POINTS . ' AS p
|
||||
JOIN ' . USERS_TABLE . " AS u ON (u.user_id = p.user_id)
|
||||
WHERE p.season <= $season
|
||||
GROUP BY p.season, p.league, u.username
|
||||
HAVING saldo <> 0.00
|
||||
ORDER BY u.username, p.season, p.league";
|
||||
|
||||
if(!$result = $db->sql_query($sql))
|
||||
{
|
||||
trigger_error('NO_SEASON');
|
||||
}
|
||||
$user_rows = $db->sql_fetchrowset($result);
|
||||
$export_file = $season. '_bank.csv';
|
||||
$newline = "\r\n";
|
||||
header('Pragma: no-cache');
|
||||
header("Content-Type: text/csv; name=\"$export_file\"");
|
||||
header("Content-disposition: attachment; filename=$export_file");
|
||||
$export= '';
|
||||
$export .= sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
|
||||
$export .= sprintf($user->lang['NAME']) . ';' . sprintf($user->lang['SEASON']) . ';' . sprintf($user->lang['LEAGUE']) . ';Saldo;' . $newline;
|
||||
|
||||
$last_username = '';
|
||||
$sum_saldo = 0.0;
|
||||
foreach ($user_rows as $user_row)
|
||||
{
|
||||
if ($last_username != '' AND $last_username != $user_row['username'])
|
||||
{
|
||||
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
|
||||
str_replace('.', ',', $sum_saldo) . ';' . $newline;
|
||||
$sum_saldo = 0.0;
|
||||
}
|
||||
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
|
||||
$user_row['season'] . ';' .
|
||||
$user_row['league'] . ';' .
|
||||
str_replace('.', ',', $user_row['saldo']) . ';' . $newline;
|
||||
$sum_saldo += $user_row['saldo'];
|
||||
$last_username = $user_row['username'];
|
||||
}
|
||||
if ($last_username != '')
|
||||
{
|
||||
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
|
||||
str_replace('.', ',', $sum_saldo) . ';' . $newline;
|
||||
}
|
||||
echo utf8_decode($export);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
52
block/dload_export.php
Normal file
52
block/dload_export.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
|
||||
$action='';
|
||||
|
||||
if (!$season OR !$league)
|
||||
{
|
||||
redirect($this->helper->route('football_main_controller', array('side' => 'bet')));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$season_info = season_info($season);
|
||||
if (!sizeof($season_info))
|
||||
{
|
||||
$error_message = sprintf($user->lang['NO_SEASON']);
|
||||
trigger_error($error_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$league_info = league_info($season, $league);
|
||||
if (!sizeof($league_info))
|
||||
{
|
||||
$error_message = sprintf($user->lang['NO_LEAGUE']);
|
||||
trigger_error($error_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
include($this->football_includes_path . 'export.' . $this->php_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect($this->helper->route('football_main_controller', array('side' => 'bet')));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
1352
block/hist_popup.php
Normal file
1352
block/hist_popup.php
Normal file
File diff suppressed because it is too large
Load Diff
65
block/last_users.php
Normal file
65
block/last_users.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$display_last_users = false;
|
||||
// Last 5 users
|
||||
$sql = 'SELECT s.session_user_id
|
||||
, u.username
|
||||
, u.user_colour
|
||||
, u.user_lastvisit
|
||||
, MAX(s.session_time) AS session_time
|
||||
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(s.session_time), u.user_lastvisit) AS lastvisit
|
||||
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(CONCAT(s.session_time,s.session_browser)), "") AS session_browser
|
||||
FROM ' . USERS_TABLE . ' AS u
|
||||
LEFT JOIN ' . SESSIONS_TABLE . ' AS s ON (u.user_id = s.session_user_id)
|
||||
WHERE u.user_lastvisit > 0
|
||||
GROUP BY u.user_id
|
||||
ORDER BY lastvisit DESC';
|
||||
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
$first = true;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!$row['lastvisit'] && $first == true)
|
||||
{
|
||||
$display_last_users = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_last_users = true;
|
||||
if($row['lastvisit'] > 0)
|
||||
{
|
||||
$browser = '';
|
||||
if (preg_match('/iPad|iPhone|iOS|Opera Mobi|BlackBerry|Android|IEMobile|Symbian/', $row['session_browser'], $match_browser))
|
||||
{
|
||||
$browser = ' (' . $match_browser[0] . ')';
|
||||
}
|
||||
$template->assign_block_vars('last_users', array(
|
||||
'USER_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']) . $browser,
|
||||
'LAST_VISIT_DATE' => $user->format_date($row['lastvisit']),
|
||||
));
|
||||
}
|
||||
}
|
||||
$first = false;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'LAST_USERS' => sprintf($user->lang['LAST_VISITORS'], 5),
|
||||
'S_DISPLAY_LAST_USERS' => $display_last_users,
|
||||
'S_LAST_USERS' => true,
|
||||
));
|
||||
|
||||
?>
|
||||
332
block/my_bets.php
Normal file
332
block/my_bets.php
Normal file
@@ -0,0 +1,332 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
$username = '';
|
||||
|
||||
$data = false;
|
||||
// select user
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE season = $season AND league = $league
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$numb_users = 0;
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$numb_users++;
|
||||
$data = true;
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// All bets of selected user group by bet
|
||||
$rank = 0;
|
||||
$bets_home_win = 0;
|
||||
$bets_draw = 0;
|
||||
$bets_guest_win = 0;
|
||||
$win_home_win = 0;
|
||||
$win_draw = 0;
|
||||
$win_guest_win = 0;
|
||||
$points_home_win = 0;
|
||||
$points_draw = 0;
|
||||
$points_guest_win = 0;
|
||||
|
||||
$sql = 'SELECT
|
||||
COUNT(b.match_no) AS bets,
|
||||
b.goals_home,
|
||||
b.goals_guest,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
|
||||
)
|
||||
) AS hits,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
)
|
||||
) AS tendencies,
|
||||
' . select_points('m',true) . '
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND m.status = 3
|
||||
AND b.user_id = $user_sel
|
||||
AND m.matchday <= $matchday
|
||||
GROUP by b.goals_home, b.goals_guest
|
||||
ORDER by bets DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['goals_home'] > $row['goals_guest'])
|
||||
{
|
||||
$bets_home_win += $row['bets'];
|
||||
$win_home_win += $row['hits'] + $row['tendencies'];
|
||||
$points_home_win += $row['points'];
|
||||
}
|
||||
if ($row['goals_home'] == $row['goals_guest'])
|
||||
{
|
||||
$bets_draw += $row['bets'];
|
||||
$win_draw += $row['hits'] + $row['tendencies'];
|
||||
$points_draw += $row['points'];
|
||||
}
|
||||
if ($row['goals_home'] < $row['goals_guest'])
|
||||
{
|
||||
$bets_guest_win += $row['bets'];
|
||||
$win_guest_win += $row['hits'] + $row['tendencies'];
|
||||
$points_guest_win += $row['points'];
|
||||
}
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('bets', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'GOALSHOME' => $row['goals_home'],
|
||||
'GOALSGUEST' => $row['goals_guest'],
|
||||
'COUNT' => $row['bets'],
|
||||
'DIRECTHITS' => $row['hits'],
|
||||
'TENDENCIES' => $row['tendencies'],
|
||||
'TOTAL' => $row['hits'] + $row['tendencies'],
|
||||
'POINTS' => $row['points'],
|
||||
'AVERAGE' => round($row['points'] / $row['bets'],1),
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Tendencies of all results
|
||||
$sql = "SELECT
|
||||
SUM(IF(goals_home + 0 > goals_guest,1,0)) AS SUM_HOME_WIN,
|
||||
SUM(IF(goals_home = goals_guest,1,0)) AS SUM_DRAW,
|
||||
SUM(IF(goals_home + 0 < goals_guest,1,0)) AS SUM_GUEST_WIN
|
||||
FROM " . FOOTB_MATCHES . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND status = 3
|
||||
AND matchday <= $matchday";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('bets_wdl', array(
|
||||
'ROW_CLASS' => 'bg2 row_dark',
|
||||
'SCORE' => sprintf($user->lang['PLAYED']),
|
||||
'HOMEWIN' => $row['SUM_HOME_WIN'],
|
||||
'DRAW' => $row['SUM_DRAW'],
|
||||
'GUESTWIN' => $row['SUM_GUEST_WIN'],
|
||||
)
|
||||
);
|
||||
// Muliply with user of this league
|
||||
$template->assign_block_vars('bets_wdl_all', array(
|
||||
'ROW_CLASS' => 'bg2 row_dark',
|
||||
'SCORE' => sprintf($user->lang['PLAYED']),
|
||||
'HOMEWIN' => $row['SUM_HOME_WIN'] * $numb_users,
|
||||
'DRAW' => $row['SUM_DRAW'] * $numb_users,
|
||||
'GUESTWIN' => $row['SUM_GUEST_WIN'] * $numb_users,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Count tendencies (bets of selected user)
|
||||
$template->assign_block_vars('bets_wdl', array(
|
||||
'ROW_CLASS' => 'bg1 row_light',
|
||||
'SCORE' => sprintf($user->lang['GUESSED']),
|
||||
'HOMEWIN' => $bets_home_win,
|
||||
'DRAW' => $bets_draw,
|
||||
'GUESTWIN' => $bets_guest_win,
|
||||
)
|
||||
);
|
||||
// Scored with tendency (bets of selected user)
|
||||
$template->assign_block_vars('bets_wdl', array(
|
||||
'ROW_CLASS' => 'bg2 row_dark',
|
||||
'SCORE' => sprintf($user->lang['SCORED']),
|
||||
'HOMEWIN' => $win_home_win,
|
||||
'DRAW' => $win_draw,
|
||||
'GUESTWIN' => $win_guest_win,
|
||||
)
|
||||
);
|
||||
// Points with tendency (bets of selected user)
|
||||
$template->assign_block_vars('bets_wdl', array(
|
||||
'ROW_CLASS' => 'bg1 row_light',
|
||||
'SCORE' => sprintf($user->lang['POINTS']),
|
||||
'HOMEWIN' => $points_home_win,
|
||||
'DRAW' => $points_draw,
|
||||
'GUESTWIN' => $points_guest_win,
|
||||
)
|
||||
);
|
||||
|
||||
// All bets of all users group by bet
|
||||
$rank = 0;
|
||||
$bets_home_win = 0;
|
||||
$bets_draw = 0;
|
||||
$bets_guest_win = 0;
|
||||
$win_home_win = 0;
|
||||
$win_draw = 0;
|
||||
$win_guest_win = 0;
|
||||
$points_home_win = 0;
|
||||
$points_draw = 0;
|
||||
$points_guest_win = 0;
|
||||
|
||||
$sql = 'SELECT
|
||||
COUNT(b.match_no) AS bets,
|
||||
b.goals_home,
|
||||
b.goals_guest,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
|
||||
)
|
||||
) AS hits,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
)
|
||||
) AS tendencies,
|
||||
' . select_points('m',true) . '
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND m.status = 3
|
||||
AND m.matchday <= $matchday
|
||||
GROUP by b.goals_home, b.goals_guest
|
||||
ORDER by bets DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['goals_home'] > $row['goals_guest'])
|
||||
{
|
||||
$bets_home_win += $row['bets'];
|
||||
$win_home_win += $row['hits'] + $row['tendencies'];
|
||||
$points_home_win += $row['points'];
|
||||
}
|
||||
if ($row['goals_home'] == $row['goals_guest'])
|
||||
{
|
||||
$bets_draw += $row['bets'];
|
||||
$win_draw += $row['hits'] + $row['tendencies'];
|
||||
$points_draw += $row['points'];
|
||||
}
|
||||
if ($row['goals_home'] < $row['goals_guest'])
|
||||
{
|
||||
$bets_guest_win += $row['bets'];
|
||||
$win_guest_win += $row['hits'] + $row['tendencies'];
|
||||
$points_guest_win += $row['points'];
|
||||
}
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('allbets', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'GOALSHOME' => $row['goals_home'],
|
||||
'GOALSGUEST' => $row['goals_guest'],
|
||||
'COUNT' => $row['bets'],
|
||||
'DIRECTHITS' => $row['hits'],
|
||||
'TENDENCIES' => $row['tendencies'],
|
||||
'TOTAL' => $row['hits'] + $row['tendencies'],
|
||||
'POINTS' => $row['points'],
|
||||
'AVERAGE' => round($row['points'] / $row['bets'],1),
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Count tendencies (bets of all user)
|
||||
$template->assign_block_vars('bets_wdl_all', array(
|
||||
'ROW_CLASS' => 'bg2 row_dark',
|
||||
'SCORE' => sprintf($user->lang['GUESSED']),
|
||||
'HOMEWIN' => $bets_home_win,
|
||||
'DRAW' => $bets_draw,
|
||||
'GUESTWIN' => $bets_guest_win,
|
||||
)
|
||||
);
|
||||
// Scored with tendency (bets of all user)
|
||||
$template->assign_block_vars('bets_wdl_all', array(
|
||||
'ROW_CLASS' => 'bg1 row_light',
|
||||
'SCORE' => sprintf($user->lang['SCORED']),
|
||||
'HOMEWIN' => $win_home_win,
|
||||
'DRAW' => $win_draw,
|
||||
'GUESTWIN' => $win_guest_win,
|
||||
)
|
||||
);
|
||||
// Points with tendency (bets of all user)
|
||||
$template->assign_block_vars('bets_wdl_all', array(
|
||||
'ROW_CLASS' => 'bg2 row_dark',
|
||||
'SCORE' => sprintf($user->lang['POINTS']),
|
||||
'HOMEWIN' => $points_home_win,
|
||||
'DRAW' => $points_draw,
|
||||
'GUESTWIN' => $points_guest_win,
|
||||
)
|
||||
);
|
||||
|
||||
$sidename = sprintf($user->lang['MY_BETS']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_BETS' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
|
||||
$this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => ($config['football_bank']) ? '< ' . sprintf($user->lang['FOOTBALL_BANK']) :
|
||||
'< ' . sprintf($user->lang['RANK_TOTAL']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_POINTS']) . ' >',
|
||||
'LEFT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_RANK_TOTAL']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_POINTS']),
|
||||
'S_DATA_MY_BETS' => $data,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'USERNAME' => $username,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
339
block/my_chart.php
Normal file
339
block/my_chart.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?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 = false;
|
||||
$user1 = '';
|
||||
$user2 = '';
|
||||
$user3 = '';
|
||||
$user4 = '';
|
||||
$username = '';
|
||||
$username2 = '';
|
||||
$username3 = '';
|
||||
$username4 = '';
|
||||
// Calculate rank total
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
SUM(r.points) AS points_total
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.matchday <= $matchday
|
||||
GROUP BY r.user_id
|
||||
ORDER BY points_total DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$current_ranks = $db->sql_fetchrowset($result);
|
||||
$total_users = sizeof($current_ranks);
|
||||
if ($total_users > 3 AND $total_users <= 50)
|
||||
{
|
||||
$data = true;
|
||||
$middle = round($total_users / 2,0);
|
||||
// If user = leader then first = seconde
|
||||
$user_first = $current_ranks[0]['user_id'];
|
||||
if ($user_first == $user->data['user_id'])
|
||||
$user_first = $current_ranks[1]['user_id'];
|
||||
// If user = middle then middle = middle - 1
|
||||
$user_middle = $current_ranks[$middle-1]['user_id'];
|
||||
if ($user_middle == $user->data['user_id'])
|
||||
$user_middle = $current_ranks[$middle]['user_id'];
|
||||
// If user = last then last = last but one
|
||||
$user_last = $current_ranks[$total_users - 1]['user_id'];
|
||||
if ($user_last == $user->data['user_id'])
|
||||
$user_last = $current_ranks[$total_users - 2]['user_id'];
|
||||
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
// Take user, leader, middle and last
|
||||
$user1 = $this->request->variable('user1', $user->data['user_id']);
|
||||
$user2 = $this->request->variable('user2', $user_first);
|
||||
$user3 = $this->request->variable('user3', $user_middle);
|
||||
$user4 = $this->request->variable('user4', $user_last);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only take leader, middle and last
|
||||
$user1 = $this->request->variable('user1', $user_first);
|
||||
$user2 = $this->request->variable('user2', $user_middle);
|
||||
$user3 = $this->request->variable('user3', $user_last);
|
||||
$user4 = $this->request->variable('user4', 0);
|
||||
}
|
||||
|
||||
// Add empty choice
|
||||
$template->assign_block_vars('form_user2', array(
|
||||
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
|
||||
'S_USERID' => 0,
|
||||
'S_SELECTEDID2' => '',
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('form_user3', array(
|
||||
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
|
||||
'S_USERID' => 0,
|
||||
'S_SELECTEDID3' => '',
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('form_user4', array(
|
||||
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
|
||||
'S_USERID' => 0,
|
||||
'S_SELECTEDID4' => '',
|
||||
)
|
||||
);
|
||||
|
||||
// Start select user
|
||||
foreach ($current_ranks as $rank_user)
|
||||
{
|
||||
$curr_userid =$rank_user['user_id'];
|
||||
if ($user1 == $curr_userid)
|
||||
{
|
||||
$selectid1 = ' selected="selected"';
|
||||
$username = $rank_user['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid1 = '';
|
||||
}
|
||||
if ($user2 == $curr_userid)
|
||||
{
|
||||
$selectid2 = ' selected="selected"';
|
||||
$username2 = $rank_user['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid2 = '';
|
||||
}
|
||||
if ($user3 == $curr_userid)
|
||||
{
|
||||
$selectid3 = ' selected="selected"';
|
||||
$username3 = $rank_user['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid3 = '';
|
||||
}
|
||||
if ($user4 == $curr_userid)
|
||||
{
|
||||
$selectid4 = ' selected="selected"';
|
||||
$username4 = $rank_user['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid4 = '';
|
||||
}
|
||||
if ($curr_userid != $user2 AND $curr_userid != $user3 AND $curr_userid != $user4)
|
||||
$template->assign_block_vars('form_user1', array(
|
||||
'S_USERNAME' => $rank_user['username'],
|
||||
'S_USERID' => $curr_userid,
|
||||
'S_SELECTEDID' => $selectid1));
|
||||
if ($curr_userid != $user1 AND $curr_userid != $user3 AND $curr_userid != $user4)
|
||||
$template->assign_block_vars('form_user2', array(
|
||||
'S_USERNAME' => $rank_user['username'],
|
||||
'S_USERID' => $curr_userid,
|
||||
'S_SELECTEDID' => $selectid2));
|
||||
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user4)
|
||||
$template->assign_block_vars('form_user3', array(
|
||||
'S_USERNAME' => $rank_user['username'],
|
||||
'S_USERID' => $curr_userid,
|
||||
'S_SELECTEDID' => $selectid3));
|
||||
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user3)
|
||||
$template->assign_block_vars('form_user4', array(
|
||||
'S_USERNAME' => $rank_user['username'],
|
||||
'S_USERID' => $curr_userid,
|
||||
'S_SELECTEDID' => $selectid4));
|
||||
}
|
||||
|
||||
$ranks_total_1 = '';
|
||||
$ranks_dayl_1 = '';
|
||||
$points_1 = '';
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday <= $matchday
|
||||
AND user_id = $user1
|
||||
ORDER BY matchday ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$points_1 = $points_1. $row['points']. ',';
|
||||
$ranks_total_1 = $ranks_total_1. $row['rank_total']. ',';
|
||||
$ranks_dayl_1 = $ranks_dayl_1. $row['rank']. ',';
|
||||
}
|
||||
$points_1 = substr($points_1, 0, strlen($points_1) - 1);
|
||||
$ranks_total_1 = substr($ranks_total_1, 0, strlen($ranks_total_1) - 1);
|
||||
$ranks_dayl_1 = substr($ranks_dayl_1, 0, strlen($ranks_dayl_1) - 1);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$ranks_total_2 = '';
|
||||
$ranks_dayl_2 = '';
|
||||
$points_2 = '';
|
||||
if ($user2 != 0)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday <= $matchday
|
||||
AND user_id = $user2
|
||||
ORDER BY matchday ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$points_2 = $points_2 . $row['points']. ',';
|
||||
$ranks_total_2 = $ranks_total_2 . $row['rank_total']. ',';
|
||||
$ranks_dayl_2 = $ranks_dayl_2 . $row['rank']. ',';
|
||||
}
|
||||
$points_2 = substr($points_2, 0, strlen($points_2) - 1);
|
||||
$ranks_total_2 = substr($ranks_total_2, 0, strlen($ranks_total_2) - 1);
|
||||
$ranks_dayl_2 = substr($ranks_dayl_2, 0, strlen($ranks_dayl_2) - 1);
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$ranks_total_3 = '';
|
||||
$ranks_dayl_3 = '';
|
||||
$points_3 = '';
|
||||
if ($user3 != 0)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday <= $matchday
|
||||
AND user_id = $user3
|
||||
ORDER BY matchday ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$points_3 = $points_3. $row['points']. ',';
|
||||
$ranks_total_3 = $ranks_total_3. $row['rank_total']. ',';
|
||||
$ranks_dayl_3 = $ranks_dayl_3. $row['rank']. ',';
|
||||
}
|
||||
$points_3 = substr($points_3,0,strlen($points_3)-1);
|
||||
$ranks_total_3 = substr($ranks_total_3,0,strlen($ranks_total_3)-1);
|
||||
$ranks_dayl_3 = substr($ranks_dayl_3,0,strlen($ranks_dayl_3)-1);
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$ranks_total_4 = '';
|
||||
$ranks_dayl_4 = '';
|
||||
$points_4 = '';
|
||||
if ($user4 != 0)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday <= $matchday
|
||||
AND user_id = $user4
|
||||
ORDER BY matchday ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$points_4 = $points_4. $row['points']. ',';
|
||||
$sptagplatz = $row['rank'];
|
||||
$ranks_total_4 = $ranks_total_4. $row['rank_total']. ',';
|
||||
$ranks_dayl_4 = $ranks_dayl_4. $row['rank']. ',';
|
||||
}
|
||||
$points_4 = substr($points_4,0,strlen($points_4)-1);
|
||||
$ranks_total_4 = substr($ranks_total_4,0,strlen($ranks_total_4)-1);
|
||||
$ranks_dayl_4 = substr($ranks_dayl_4,0,strlen($ranks_dayl_4)-1);
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$min = '';
|
||||
$max = '';
|
||||
if ($user1 != 0)
|
||||
{
|
||||
$sql = 'SELECT
|
||||
MIN(points) As points_min,
|
||||
MAX(points) As points_max
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday <= $matchday
|
||||
GROUP BY matchday
|
||||
ORDER BY matchday ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$min = $min. $row['points_min']. ',';
|
||||
$max = $max. $row['points_max']. ',';
|
||||
}
|
||||
$min = substr($min,0,strlen($min)-1);
|
||||
$max = substr($max,0,strlen($max)-1);
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
// Create and display charts
|
||||
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
|
||||
. "includes/chart_rank.php?t=$total_users&m=$matchday&v1=$ranks_total_1&v2=$ranks_total_2&v3=$ranks_total_3&v4=$ranks_total_4&c="
|
||||
. sprintf($user->lang['PLACE']) . "' alt='"
|
||||
. sprintf($user->lang['CHART_TOTAL'])
|
||||
. "'/>";
|
||||
$template->assign_block_vars('chart_rank', array(
|
||||
'CHARTIMAGE' => $chart,
|
||||
)
|
||||
);
|
||||
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
|
||||
. "includes/chart_rank.php?t=$total_users&m=$matchday&v1=$ranks_dayl_1&v2=$ranks_dayl_2&v3=$ranks_dayl_3&v4=$ranks_dayl_4&c="
|
||||
. sprintf($user->lang['PLACE']) . "' alt='"
|
||||
. sprintf($user->lang['CHART_MATCHDAY'])
|
||||
. "'/>";
|
||||
$template->assign_block_vars('chart_matchtdays', array(
|
||||
'CHARTIMAGE' => $chart,
|
||||
)
|
||||
);
|
||||
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
|
||||
. "includes/chart_points.php?m=$matchday&v1=$points_1&v2=$points_2&v3=$points_3&v4=$points_4&min=$min&max=$max&c="
|
||||
. sprintf($user->lang['POINTS']) . ',' . sprintf($user->lang['BANDWIDTH']) . "' alt='"
|
||||
. sprintf($user->lang['CHART_POINTS'])
|
||||
. "'/>";
|
||||
$template->assign_block_vars('chart_points', array(
|
||||
'CHARTIMAGE' => $chart,
|
||||
)
|
||||
);
|
||||
}
|
||||
$sidename = sprintf($user->lang['MY_CHART']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_CHART' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_RANK']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_KOEFF']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_RANKS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_KOEFF']),
|
||||
'S_DATA_MY_CHART' => $data,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'S_USER1' => $user1,
|
||||
'S_USER2' => $user2,
|
||||
'S_USER3' => $user3,
|
||||
'S_USER4' => $user4,
|
||||
'USERNAME1' => $username,
|
||||
'USERNAME2' => $username2,
|
||||
'USERNAME3' => $username3,
|
||||
'USERNAME4' => $username4,
|
||||
)
|
||||
);
|
||||
?>
|
||||
393
block/my_koeff.php
Normal file
393
block/my_koeff.php
Normal file
@@ -0,0 +1,393 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$start = $this->request->variable('start', 0);
|
||||
$matches_on_matchday = false;
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
$username = '';
|
||||
|
||||
$data = false;
|
||||
// Select user
|
||||
$total_users = 0;
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$total_users++;
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
// Select matches with results and tendencies
|
||||
$sql = "SELECT
|
||||
m.match_no,
|
||||
m.status,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
t1.team_name_short AS home_name,
|
||||
t2.team_name_short AS guest_name,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
SUM(IF(b.goals_home + 0 > b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS home,
|
||||
SUM(IF(b.goals_home = b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS draw,
|
||||
SUM(IF(b.goals_home + 0 < b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS guest
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season=m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t2 ON (t2.season=m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON(b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
GROUP BY m.match_no
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$matches = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$count_matches = sizeof($matches);
|
||||
if ($count_matches > 11)
|
||||
{
|
||||
$split_after = 8;
|
||||
$splits = floor($count_matches / 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
$split_after = $count_matches;
|
||||
$splits = 1;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
|
||||
$sql_start = $start * $count_matches;
|
||||
$sql_limit = $config['football_users_per_page'] * $count_matches;
|
||||
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday, 'u' => "$user_sel"));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
|
||||
$bet_line = array();
|
||||
if ($count_matches > 0)
|
||||
{
|
||||
$matches_on_matchday = true;
|
||||
// Select user bets and points on user results
|
||||
$sql = "SELECT
|
||||
u.user_id,
|
||||
u.username,
|
||||
m.status,
|
||||
b.goals_home AS bet_home,
|
||||
b.goals_guest AS bet_guest,
|
||||
" . select_points("bu") . "
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_BETS . ' AS b ON(b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS bu ON(bu.season = m.season AND bu.league = m.league AND bu.match_no = m.match_no AND bu.user_id = $user_sel)
|
||||
LEFT JOIN " . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
ORDER BY LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
||||
$user_bets = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$bet_index = 0;
|
||||
$split_index = 0;
|
||||
foreach ($user_bets AS $user_bet)
|
||||
{
|
||||
$data = true;
|
||||
if ($bet_index == $count_matches)
|
||||
{
|
||||
$bet_index = 0;
|
||||
$split_index = 0;
|
||||
}
|
||||
if (!($bet_index % $split_after))
|
||||
{
|
||||
$split_index++;
|
||||
}
|
||||
$sum_total[$user_bet['username']] = 0;
|
||||
$bet_line[$split_index][] = $user_bet;
|
||||
$bet_index++;
|
||||
}
|
||||
}
|
||||
$match_index = 0;
|
||||
$split_index = 0;
|
||||
$matchday_sum_total = 0;
|
||||
$colorstyle_total = ' color_finally';
|
||||
foreach ($matches AS $match)
|
||||
{
|
||||
if (!($match_index % $split_after))
|
||||
{
|
||||
if ($match_index > 0)
|
||||
{
|
||||
$total = 0;
|
||||
$count_user = 0;
|
||||
$bet_index = 0;
|
||||
foreach ($bet_line[$split_index] AS $user_bet)
|
||||
{
|
||||
if ($bet_index == 0)
|
||||
{
|
||||
$count_user++;
|
||||
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($user_bet['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('match_panel.user_row', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USER_NAME' => $user_bet['username'],
|
||||
)
|
||||
);
|
||||
$total = 0;
|
||||
}
|
||||
$bet_index++;
|
||||
$total += $user_bet['points'];
|
||||
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
|
||||
{
|
||||
// hide bets
|
||||
$bet_home = ($user_bet['bet_home'] == '') ? ' ' : '?';
|
||||
$bet_guest = ($user_bet['bet_guest'] == '') ? ' ' : '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = $user_bet['bet_home'];
|
||||
$bet_guest = $user_bet['bet_guest'];
|
||||
}
|
||||
|
||||
$colorstyle_bet = color_style($user_bet['status']);
|
||||
$template->assign_block_vars('match_panel.user_row.bet', array(
|
||||
'BET' => $bet_home. ':'. $bet_guest,
|
||||
'COLOR_STYLE' => $colorstyle_bet,
|
||||
'POINTS' => ($user_bet['points'] == '') ? ' ' : $user_bet['points'],
|
||||
)
|
||||
);
|
||||
|
||||
if ($bet_index == $split_after)
|
||||
{
|
||||
$sum_total[$user_bet['username']] += $total;
|
||||
$matchday_sum_total += $total;
|
||||
$bet_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('match_panel.tendency_footer', array(
|
||||
'S_TOTAL' => false,
|
||||
)
|
||||
);
|
||||
foreach ($matches_tendency AS $match_tendency)
|
||||
{
|
||||
$template->assign_block_vars('match_panel.tendency_footer.tendency', array(
|
||||
'TENDENCY' => $match_tendency,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$matches_tendency = array();
|
||||
$split_index++;
|
||||
if ($split_index == $splits)
|
||||
{
|
||||
$display_total = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_total = false;
|
||||
}
|
||||
$template->assign_block_vars('match_panel', array(
|
||||
'S_TOTAL' => $display_total,
|
||||
)
|
||||
);
|
||||
}
|
||||
if (0 == $match['home_id'])
|
||||
{
|
||||
$home_info = get_team($season, $league, $match['match_no'], 'team_id_home', $match['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homename = $home_in_array[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homename = $match['home_name'];
|
||||
}
|
||||
if (0 == $match['guest_id'])
|
||||
{
|
||||
$guest_info = get_team($season, $league, $match['match_no'], 'team_id_guest', $match['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestname = $guest_in_array[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestname = $match['guest_name'];
|
||||
}
|
||||
$colorstyle_match = color_style($match['status']);
|
||||
$template->assign_block_vars('match_panel.match_entry', array(
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'RESULT' => $match['goals_home'] . ':' . $match['goals_guest'],
|
||||
'COLOR_STYLE' => $colorstyle_match,
|
||||
)
|
||||
);
|
||||
if ($match['status'] < 1 && !$config['football_view_tendencies'])
|
||||
{
|
||||
// hide tendencies
|
||||
$matches_tendency[] = '?-?-?';
|
||||
}
|
||||
else
|
||||
{
|
||||
$matches_tendency[] = $match['home'] . '-' . $match['draw'] . '-' . $match['guest'];
|
||||
}
|
||||
$match_index++;
|
||||
}
|
||||
if ($count_matches > 0)
|
||||
{
|
||||
$total = 0;
|
||||
$count_user = 0;
|
||||
$bet_index = 0;
|
||||
foreach ($bet_line[$split_index] AS $user_bet)
|
||||
{
|
||||
if ($bet_index == 0)
|
||||
{
|
||||
$count_user++;
|
||||
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($user_bet['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('match_panel.user_row', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USER_NAME' => $user_bet['username'],
|
||||
)
|
||||
);
|
||||
$total = 0;
|
||||
}
|
||||
$bet_index++;
|
||||
$total += $user_bet['points'];
|
||||
if ($user_bet['status'] < 1)
|
||||
{
|
||||
if ($user_bet['bet_home'] == '')
|
||||
{
|
||||
$bet_home = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = '?';
|
||||
}
|
||||
if ($user_bet['bet_guest'] == '')
|
||||
{
|
||||
$bet_guest = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_guest = '?';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bet_home = $user_bet['bet_home'];
|
||||
$bet_guest = $user_bet['bet_guest'];
|
||||
}
|
||||
|
||||
$colorstyle_bet = color_style($user_bet['status']);
|
||||
$template->assign_block_vars('match_panel.user_row.bet', array(
|
||||
'BET' => $bet_home. ':'. $bet_guest,
|
||||
'COLOR_STYLE' => $colorstyle_bet,
|
||||
'POINTS' => ($user_bet['points'] == '') ? ' ' : $user_bet['points'],
|
||||
)
|
||||
);
|
||||
|
||||
if ($bet_index == $split_after)
|
||||
{
|
||||
$sum_total[$user_bet['username']] += $total;
|
||||
$matchday_sum_total += $total;
|
||||
$template->assign_block_vars('match_panel.user_row.points', array(
|
||||
'COLOR_STYLE' => $colorstyle_total,
|
||||
'POINTS_TOTAL' => $sum_total[$user_bet['username']],
|
||||
)
|
||||
);
|
||||
$bet_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('match_panel.tendency_footer', array(
|
||||
'S_TOTAL' => true,
|
||||
'COLOR_STYLE' => $colorstyle_total, //currently ignored
|
||||
'SUMTOTAL' => $matchday_sum_total,
|
||||
)
|
||||
);
|
||||
foreach ($matches_tendency AS $match_tendency)
|
||||
{
|
||||
$template->assign_block_vars('match_panel.tendency_footer.tendency', array(
|
||||
'TENDENCY' => $match_tendency,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['MY_KOEFF']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_KOEFF' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_CHART']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['STAT_POINTS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_CHART']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_STAT_POINTS']),
|
||||
'S_MATCHES_ON_MATCHDAY' => $matches_on_matchday,
|
||||
'S_SPALTEN' => ($count_matches * 2) + 2,
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
'USERNAME' => $username,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
204
block/my_points.php
Normal file
204
block/my_points.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
$username = '';
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
$data = false;
|
||||
// Select user
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data = true;
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Select sum of users points group by team
|
||||
$sql = "SELECT
|
||||
t.*,
|
||||
SUM(1) AS bets,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS lost,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),
|
||||
0,1
|
||||
)
|
||||
)
|
||||
)AS tendencies,
|
||||
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),1,0))AS hits,
|
||||
" . select_points('m',true) . "
|
||||
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))
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
|
||||
WHERE t.season = $season
|
||||
AND t.league = $league
|
||||
AND m.status IN (3,6)
|
||||
AND b.user_id = $user_sel
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND m.matchday <= $matchday
|
||||
GROUP BY t.team_id
|
||||
ORDER BY points DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
$template->assign_block_vars('points', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'LOGO' => $logo,
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'COUNT' => $row['bets'],
|
||||
'WIN' => $row['win'],
|
||||
'DRAW' => $row['draw'],
|
||||
'LOST' => $row['lost'],
|
||||
'DIRECTHITS' => $row['hits'],
|
||||
'TENDENCIES' => $row['tendencies'],
|
||||
'TOTAL' => $row['hits'] + $row['tendencies'],
|
||||
'POINTS' => $row['points'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Select sum of all users points group by team
|
||||
$sql = "SELECT
|
||||
t.*,
|
||||
SUM(1) AS bets,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS lost,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
)
|
||||
)AS tendencies,
|
||||
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)) AS hits,
|
||||
" . select_points('m',true) . "
|
||||
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))
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
|
||||
WHERE t.season = $season
|
||||
AND t.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND m.status IN (3,6)
|
||||
AND m.matchday <= $matchday
|
||||
GROUP BY t.team_id
|
||||
ORDER BY points DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
$template->assign_block_vars('allpoints', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'LOGO' => $logo,
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'COUNT' => $row['bets'],
|
||||
'WIN' => $row['win'],
|
||||
'DRAW' => $row['draw'],
|
||||
'LOST' => $row['lost'],
|
||||
'DIRECTHITS' => $row['hits'],
|
||||
'TENDENCIES' => $row['tendencies'],
|
||||
'TOTAL' => $row['hits'] + $row['tendencies'],
|
||||
'POINTS' => $row['points'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['MY_POINTS']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_POINTS' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_BETS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_TABLE']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_BETS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_TABLE']),
|
||||
'S_DATA_MY_POINTS' => $data,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'USERNAME' => $username,
|
||||
)
|
||||
);
|
||||
?>
|
||||
179
block/my_rank.php
Normal file
179
block/my_rank.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
$username = '';
|
||||
|
||||
$data = false;
|
||||
// select user
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS w
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = w.user_id)
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY LOWER(u.username) ASC ";
|
||||
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Get ranks 1-3 of selected user
|
||||
$sql = 'SELECT
|
||||
season,
|
||||
COUNT(matchday) AS matchdays,
|
||||
SUM(points) AS points,
|
||||
SUM(IF(rank = 1, 1, 0)) AS rank1,
|
||||
SUM(IF(rank = 2, 1, 0)) AS rank2,
|
||||
SUM(IF(rank = 3, 1, 0)) AS rank3
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND user_id = $user_sel
|
||||
GROUP BY user_id, season
|
||||
ORDER BY season ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('myrank', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'SEASON' => $row['season'],
|
||||
'MATCHDAYS' => $row['matchdays'],
|
||||
'POINTS' => $row['points'],
|
||||
'RANK1' => $row['rank1'],
|
||||
'RANK2' => $row['rank2'],
|
||||
'RANK3' => $row['rank3'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Get all ranks 1-3 of selected user
|
||||
$sql = 'SELECT
|
||||
COUNT(matchday) AS matchdays,
|
||||
rank
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND user_id = $user_sel
|
||||
GROUP BY user_id, rank
|
||||
ORDER BY rank ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('season_ranks', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $row['rank'],
|
||||
'MATCHDAYS' => $row['matchdays'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Get ranks 1-3 of all users
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
COUNT(r.matchday) AS matchdays,
|
||||
SUM(r.points) AS points,
|
||||
SUM(IF(r.rank =1, 1, 0)) AS rank1,
|
||||
SUM(IF(r.rank =2, 1, 0)) AS rank2,
|
||||
SUM(IF(r.rank =3, 1, 0)) AS rank3
|
||||
FROM ' . FOOTB_RANKS . " AS r
|
||||
LEFT JOIN " . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
GROUP BY r.user_id
|
||||
ORDER BY rank1 DESC, rank2 DESC, rank3 DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data = true;
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('allranks', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'NAME' => $row['username'],
|
||||
'MATCHDAYS' => $row['matchdays'],
|
||||
'POINTS' => $row['points'],
|
||||
'AVERAGE' => round($row['points'] / $row['matchdays'],1),
|
||||
'RANK1' => $row['rank1'],
|
||||
'RANK2' => $row['rank2'],
|
||||
'RANK3' => $row['rank3'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['MY_RANK']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_RANK' => true,
|
||||
'S_MATCHDAY_HIDE' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_TABLE']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_CHART']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_TABLE']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_CHART']),
|
||||
'S_DATA_MY_RANK' => $data,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'USERNAME' => $username,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
438
block/my_table.php
Normal file
438
block/my_table.php
Normal file
@@ -0,0 +1,438 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if (!$user_sel)
|
||||
{
|
||||
if (user_is_member($user->data['user_id'], $season, $league))
|
||||
{
|
||||
$user_sel = $user->data['user_id'];
|
||||
}
|
||||
}
|
||||
$username = '';
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
// select user
|
||||
$sql = 'SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.username
|
||||
FROM ' . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($user_sel == 900)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = 'Alle';
|
||||
$user_sel = 900;
|
||||
$where_user = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
$where_user = "b.user_id = $user_sel AND ";
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => 900,
|
||||
'S_USERNAME' => 'Alle',
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($user_sel == $row['user_id'] OR !$user_sel)
|
||||
{
|
||||
$selectid = ' selected="selected"';
|
||||
$username = $row['username'];
|
||||
$user_sel = $row['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectid = '';
|
||||
}
|
||||
$template->assign_block_vars('form_user', array(
|
||||
'S_USER' => $row['user_id'],
|
||||
'S_USERNAME' => $row['username'],
|
||||
'S_SELECTEDID' => $selectid,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$data_table = false;
|
||||
$data_form = false;
|
||||
if ($matchday > 5)
|
||||
{
|
||||
$form_from = $matchday - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
$form_from = 1;
|
||||
}
|
||||
|
||||
$sql = '
|
||||
SELECT *
|
||||
FROM ' . FOOTB_LEAGUES . "
|
||||
WHERE season = $season
|
||||
AND league = $league";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$league_type = $row['league_type'];
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
|
||||
|
||||
$rank = 0;
|
||||
// Select table on selected user bets
|
||||
$sql = 'SELECT
|
||||
t.*,
|
||||
SUM(1) AS matches,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS lost,
|
||||
SUM(IF(m.team_id_home = t.team_id,
|
||||
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
|
||||
)
|
||||
) AS points,
|
||||
SUM(IF(m.team_id_home = t.team_id,
|
||||
IF(m.goals_home + 0 > m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0)),
|
||||
IF(m.goals_home + 0 < m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0))
|
||||
)
|
||||
) AS realpoints,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
|
||||
WHERE $where_user
|
||||
t.season = $season
|
||||
AND t.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
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";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$lastGroup = '';
|
||||
$sumdiff = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($lastGroup != $row['group_id'])
|
||||
{
|
||||
$lastGroup = $row['group_id'];
|
||||
$rank = 0;
|
||||
$template->assign_block_vars('total', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$data_table = true;
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
$pdiff = $row['points'] - $row['realpoints'];
|
||||
if ($pdiff >= 0)
|
||||
{
|
||||
$sumdiff += $pdiff;
|
||||
$pdiff = ' (+' . $pdiff . ')';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$sumdiff -= $pdiff;
|
||||
$pdiff = ' (' . $pdiff . ')';
|
||||
}
|
||||
if ($user_sel == 900)
|
||||
{
|
||||
$pdiff = '';
|
||||
}
|
||||
|
||||
$template->assign_block_vars('total', array(
|
||||
'RANK' => $rank . '.',
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LOGO' => $logo,
|
||||
'TEAM_ID' => $row['team_id'],
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $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'] . $pdiff,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
// Select formtable on selected user bets
|
||||
$sql = 'SELECT
|
||||
t.*,
|
||||
SUM(1) AS matches,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF((m.team_id_home = t.team_id),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
|
||||
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
|
||||
)
|
||||
) AS lost,
|
||||
SUM(IF(m.team_id_home = t.team_id,
|
||||
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
|
||||
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
|
||||
)
|
||||
) AS points,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
|
||||
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
|
||||
WHERE $where_user
|
||||
t.season = $season
|
||||
AND t.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND m.matchday >= $form_from
|
||||
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";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$lastGroup = '';
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_form = true;
|
||||
if ($lastGroup != $row['group_id'])
|
||||
{
|
||||
$lastGroup = $row['group_id'];
|
||||
$rank = 0;
|
||||
$template->assign_block_vars('form', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
|
||||
$template->assign_block_vars('form', array(
|
||||
'RANK' => $rank . '.',
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LOGO' => $logo,
|
||||
'TEAM_ID' => $row['team_id'],
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $row['team_id'], 'mode' => 'rest')),
|
||||
'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;
|
||||
// Select home-table on selected user bets
|
||||
$sql = 'SELECT
|
||||
t.*,
|
||||
SUM(1) AS matches,
|
||||
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS lost,
|
||||
SUM(IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
|
||||
SUM(b.goals_home - b.goals_guest) AS goals_diff,
|
||||
SUM(b.goals_home) AS goals,
|
||||
SUM(b.goals_guest) 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 AND m.group_id = t.group_id)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
|
||||
WHERE $where_user
|
||||
t.season = $season
|
||||
AND t.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
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";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$lastGroup = '';
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($lastGroup != $row['group_id'])
|
||||
{
|
||||
$lastGroup = $row['group_id'];
|
||||
$rank = 0;
|
||||
$template->assign_block_vars('home', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
|
||||
$template->assign_block_vars('home', array(
|
||||
'RANK' => $rank . '.',
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LOGO' => $logo,
|
||||
'TEAM_ID' => $row['team_id'],
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $row['team_id'], 'mode' => 'home')),
|
||||
'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;
|
||||
// Select away-table on selected user bets
|
||||
$sql = 'SELECT
|
||||
t.*,
|
||||
SUM(1) AS matches,
|
||||
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS win,
|
||||
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
|
||||
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS lost,
|
||||
SUM(IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
|
||||
SUM(b.goals_guest - b.goals_home) AS goals_diff,
|
||||
SUM(b.goals_guest) AS goals,
|
||||
SUM(b.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_guest = t.team_id AND m.group_id = t.group_id)
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
|
||||
WHERE $where_user
|
||||
t.season = $season
|
||||
AND t.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
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";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$lastGroup = '';
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($lastGroup != $row['group_id'])
|
||||
{
|
||||
$lastGroup = $row['group_id'];
|
||||
$rank = 0;
|
||||
$template->assign_block_vars('away', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
|
||||
$template->assign_block_vars('away', array(
|
||||
'RANK' => $rank . '.',
|
||||
'ROW_CLASS' => $row_class,
|
||||
'LOGO' => $logo,
|
||||
'TEAM_ID' => $row['team_id'],
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $row['team_id'], 'mode' => 'away')),
|
||||
'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);
|
||||
|
||||
$sidename = sprintf($user->lang['MY_TABLE']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_MY_TABLE' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_TABLE']),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_POINTS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_TABLE']),
|
||||
'RIGHT_LINK' => sprintf($user->lang['MY_RANK']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_POINTS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_RANKS']),
|
||||
'S_DATA_MY_TABLE' => $data_table,
|
||||
'S_DATA_FORM' => $data_form,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'TEXT_FORM' => $text_form,
|
||||
'S_PDIFF' => $sumdiff,
|
||||
'USERNAME' => $username,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
211
block/odds.php
Normal file
211
block/odds.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?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_odds = false;
|
||||
$matchnumber = 0;
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
|
||||
$sql = "SELECT
|
||||
m.league,
|
||||
m.match_no,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.match_datetime,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.match_datetime,' %d.%m. %H:%i')
|
||||
) AS match_time,
|
||||
t1.team_symbol AS home_symbol,
|
||||
t2.team_symbol AS guest_symbol,
|
||||
t1.team_name_short AS home_name,
|
||||
t2.team_name_short AS guest_name,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
m.goals_overtime_home AS kogoals_home,
|
||||
m.goals_overtime_guest AS kogoals_guest,
|
||||
m.ko_match,
|
||||
m.group_id,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
m.odd_1,
|
||||
m.odd_x,
|
||||
m.odd_2,
|
||||
m.trend FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$rows = $db->sql_fetchrowset($result);
|
||||
|
||||
$league_info = league_info($season, $league);
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
//while($row = $db->sql_fetchrow($result))
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$data_odds = true;
|
||||
$matchnumber++ ;
|
||||
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if (0 == $row['home_id'])
|
||||
{
|
||||
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homelogo = $home_in_array[0];
|
||||
$homeid = $home_in_array[1];
|
||||
$homename = $home_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homelogo = $row['home_symbol'];
|
||||
$homeid = $row['home_id'];
|
||||
$homename = $row['home_name'];
|
||||
}
|
||||
if (0 == $row['guest_id'])
|
||||
{
|
||||
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestlogo = $guest_in_array[0];
|
||||
$guestid = $guest_in_array[1];
|
||||
$guestname = $guest_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestlogo = $row['guest_symbol'];
|
||||
$guestid = $row['guest_id'];
|
||||
$guestname = $row['guest_name'];
|
||||
}
|
||||
if ($homelogo <> '')
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
if ($guestlogo <> '')
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($row['ko_match'])
|
||||
{
|
||||
$display_ko = true;
|
||||
$ko_match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ko_match = false;
|
||||
}
|
||||
|
||||
if ($row['group_id'] == '')
|
||||
{
|
||||
$group_id = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_group = true;
|
||||
$group_id = $row['group_id'];
|
||||
}
|
||||
|
||||
$edit_match = false;
|
||||
$goals_home = ($row['goals_home'] == '') ? ' ' : $row['goals_home'];
|
||||
$goals_guest = ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'];
|
||||
$kogoals_home = ($row['kogoals_home'] == '') ? ' ' : $row['kogoals_home'];
|
||||
$kogoals_guest = ($row['kogoals_guest'] == '') ? ' ' : $row['kogoals_guest'];
|
||||
|
||||
$template->assign_block_vars('odds', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'MATCH_NUMBER' => $row['match_no'],
|
||||
'MATCHDAY' => $matchday,
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'HOME_ID' => $homeid,
|
||||
'GUEST_ID' => $guestid,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $homeid, 'mode' => 'all')),
|
||||
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $guestid, 'mode' => 'all')),
|
||||
'GOALS_HOME' => $goals_home,
|
||||
'GOALS_GUEST' => $goals_guest,
|
||||
'COLOR_STYLE' => '',
|
||||
'KOGOALS_HOME' => $kogoals_home,
|
||||
'KOGOALS_GUEST' => $kogoals_guest,
|
||||
'S_KO_MATCH' => $ko_match,
|
||||
'TREND' => $row['trend'],
|
||||
'U_MATCH_STATS' => $this->helper->route('football_football_popup', array('popside' => 'hist_popup', 's' => $season, 'l' => $league,
|
||||
'hid' => $homeid, 'gid' => $guestid, 'm' => $matchday,
|
||||
'mn' => $row['match_no'], 'gr' => $row['group_id'])),
|
||||
'ODD_1' => $row['odd_1'],
|
||||
'ODD_X' => $row['odd_x'],
|
||||
'ODD_2' => $row['odd_2'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = 'Chancen';
|
||||
switch ($league_info['bet_ko_type'])
|
||||
{
|
||||
case BET_KO_90:
|
||||
$result_explain = sprintf($user->lang['MIN90']);
|
||||
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
|
||||
break;
|
||||
case BET_KO_EXTRATIME:
|
||||
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
|
||||
$label_finalresult = sprintf($user->lang['PENALTY']);
|
||||
break;
|
||||
case BET_KO_PENALTY:
|
||||
$result_explain = sprintf($user->lang['PENALTY']);
|
||||
$display_ko = false;
|
||||
break;
|
||||
default:
|
||||
$result_explain = sprintf($user->lang['MIN90']);
|
||||
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_ODDS' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'RESULT_EXPLAIN' => $result_explain,
|
||||
'LABEL_FINALRESULT' => $label_finalresult,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['BET']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['TABLE']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_BET']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
|
||||
'S_DATA_ODDS' => $data_odds,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
72
block/rank_matchday.php
Normal file
72
block/rank_matchday.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if ($league <> 0)
|
||||
{
|
||||
$data_rank_matchday = false;
|
||||
$index = 0;
|
||||
$sql = "SELECT
|
||||
r.status,
|
||||
r.rank,
|
||||
r.user_id,
|
||||
u.username,
|
||||
r.points,
|
||||
IF(r.win=0, '', r.win) AS win
|
||||
FROM " . FOOTB_RANKS . ' AS r
|
||||
LEFT Join ' . USERS_TABLE . " AS u ON (r.user_id = u.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $matchday
|
||||
AND r.status IN (2,3)
|
||||
ORDER BY rank ASC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$index++;
|
||||
if (($index <= $config['football_display_ranks']) OR ($row['user_id'] == $user->data['user_id']))
|
||||
{
|
||||
$data_rank_matchday = true;
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($row['status']);
|
||||
|
||||
$template->assign_block_vars('rank', array(
|
||||
'RANK' => $row['rank'],
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USERID' => $row['user_id'],
|
||||
'USERNAME' => $row['username'],
|
||||
'U_BET_USER' => $this->helper->route('football_football_popup', array('popside' => 'bet_popup', 's' => $season, 'l' => $league,
|
||||
'm' => $matchday, 'u' => $row['user_id'])),
|
||||
'POINTS' => $row['points'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $row['win'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$league_info = league_info($season, $league);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANK_MATCHDAY' => true,
|
||||
'S_DATA_RANK_MATCHDAY' => $data_rank_matchday,
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
));
|
||||
}
|
||||
?>
|
||||
94
block/rank_total.php
Normal file
94
block/rank_total.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
if ($league <> 0)
|
||||
{
|
||||
$sql = 'SELECT
|
||||
r.matchday AS last_matchday
|
||||
FROM '. FOOTB_RANKS . " AS r
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.status IN (2,3)
|
||||
ORDER BY r.matchday DESC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
if($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$last_matchday = $row['last_matchday'];
|
||||
$db->sql_freeresult($result);
|
||||
$rank_matchday = ($last_matchday < $matchday) ? $last_matchday : $matchday;
|
||||
|
||||
$sql = 'SELECT
|
||||
r.rank_total AS rank,
|
||||
r.user_id,
|
||||
u.username,
|
||||
u.user_colour,
|
||||
r.status AS status,
|
||||
r.points_total AS points,
|
||||
r.win_total AS win
|
||||
FROM '. FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN '. USERS_TABLE . " AS u ON (r.user_id = u.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $rank_matchday
|
||||
AND r.status IN (2,3)
|
||||
ORDER BY points DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$index = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$index++;
|
||||
$data_rank_total = true;
|
||||
if (($index <= $config['football_display_ranks']) OR ($row['user_id'] == $user->data['user_id']))
|
||||
{
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($row['status']);
|
||||
|
||||
$template->assign_block_vars("ranktotal", array(
|
||||
'RANK' => $row['rank'],
|
||||
'ROW_CLASS' => $row_class,
|
||||
'USERID' => $row['user_id'],
|
||||
'USERNAME' => $row['username'],
|
||||
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'URL' => $phpbb_root_path . "profile.php?mode=viewprofile&u=" . $row['user_id'],
|
||||
'POINTS' => $row['points'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $row['win'] ,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_rank_total = false;
|
||||
}
|
||||
$league_info = league_info($season, $league);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANK_TOTAL' => true,
|
||||
'S_DATA_RANK_TOTAL' => $data_rank_total,
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0' and $league_info['win_season'] == '0') ? false : true,
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
270
block/ranks_matchday.php
Normal file
270
block/ranks_matchday.php
Normal file
@@ -0,0 +1,270 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$start = $this->request->variable('start', 0);
|
||||
$win_user_most_hits = array();
|
||||
$win_user_most_hits_away = array();
|
||||
$season_wins = array();
|
||||
$win_user_most_hits = win_user_most_hits($season, $league, $matchday);
|
||||
$win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
|
||||
|
||||
// Statistics of matchday
|
||||
$sql = "SELECT
|
||||
b.user_id,
|
||||
COUNT(b.match_no) AS matches,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0),
|
||||
0
|
||||
)
|
||||
) AS hits,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((m.goals_home <= m.goals_guest),
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0),
|
||||
0
|
||||
),
|
||||
0
|
||||
)
|
||||
) AS hits02,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest) OR
|
||||
(b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest) OR
|
||||
(b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
),
|
||||
0
|
||||
)
|
||||
) AS tendency
|
||||
FROM " . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND m.status IN (2,3)
|
||||
AND m.matchday = $matchday
|
||||
GROUP BY user_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$usersstats = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
foreach ($usersstats AS $userstats)
|
||||
{
|
||||
$betsof[$userstats['user_id']] = $userstats['bets'];
|
||||
$nobetsof[$userstats['user_id']] = $userstats['matches'] - $userstats['bets'];
|
||||
$tendenciesof[$userstats['user_id']] = $userstats['tendency'];
|
||||
$hitsof[$userstats['user_id']] = $userstats['hits'];
|
||||
$hits02of[$userstats['user_id']] = $userstats['hits02'];
|
||||
}
|
||||
|
||||
// ranks of matchday
|
||||
$sql = 'SELECT
|
||||
rank,
|
||||
user_id
|
||||
FROM '. FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday = $matchday
|
||||
AND status IN (2,3)
|
||||
ORDER BY rank ASC, user_id ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
$ranks = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$total_users = sizeof($ranks);
|
||||
foreach ($ranks AS $rank)
|
||||
{
|
||||
$rankof[$rank['user_id']] = $rank['rank'];
|
||||
}
|
||||
|
||||
if ($matchday > 1)
|
||||
{
|
||||
// rank previous matchday
|
||||
$sql = 'SELECT
|
||||
rank AS last_rang,
|
||||
user_id
|
||||
FROM '. FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday = ($matchday-1)
|
||||
AND status IN (2,3)
|
||||
ORDER BY last_rang ASC, user_id ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$ranks = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($ranks AS $rank)
|
||||
{
|
||||
$prevrankof[$rank['user_id']] = $rank['last_rang'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchday == $maxmatchday)
|
||||
{
|
||||
$season_wins = season_wins($season, $league, $matchday);
|
||||
}
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$sql_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
$sql_limit = $config['football_users_per_page'];
|
||||
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
$data_ranks = false;
|
||||
$index = 0;
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
$sql = 'SELECT
|
||||
r.rank,
|
||||
r.status,
|
||||
r.user_id,
|
||||
r.points,
|
||||
r.win AS wins,
|
||||
u.user_colour,
|
||||
u.username
|
||||
FROM '. FOOTB_RANKS . ' AS r
|
||||
LEFT Join '. USERS_TABLE . " AS u ON (r.user_id = u.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $matchday
|
||||
AND r.status IN (2,3)
|
||||
ORDER BY r.rank ASC, r.points DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$index++;
|
||||
$data_ranks = true;
|
||||
if (isset($prevrankof[$row['user_id']]))
|
||||
{
|
||||
if ($rankof[$row['user_id']] == '')
|
||||
{
|
||||
$change_sign = '';
|
||||
$change_img = '';
|
||||
$change_differ = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($rankof[$row['user_id']] == $prevrankof[$row['user_id']])
|
||||
{
|
||||
$change_sign = '=';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/no_change.gif\" alt=\"" . $user->lang['NO_CHANGES'] . "\"/>";
|
||||
$change_differ = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($rankof[$row['user_id']] > $prevrankof[$row['user_id']])
|
||||
{
|
||||
$change_sign = '+';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/arrow_down.gif\" alt=\"" . $user->lang['WORSENED'] . "\"/>";
|
||||
$differ = $rankof[$row['user_id']] - $prevrankof[$row['user_id']];
|
||||
$change_differ = ' (' . $differ . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$change_sign = '-';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/arrow_up.gif\" alt=\"" . $user->lang['IMPROVED'] . "\"/>";
|
||||
$differ = $prevrankof[$row['user_id']] - $rankof[$row['user_id']];
|
||||
$change_differ = ' (' . $differ . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$change_sign = '';
|
||||
$change_img = '';
|
||||
$change_differ = ' ';
|
||||
}
|
||||
|
||||
if ($matchday == $maxmatchday)
|
||||
{
|
||||
// if someone didn't bet the hole Season
|
||||
if(!isset($win_user_most_hits[$row['user_id']]['win']))
|
||||
{
|
||||
$win_user_most_hits[$row['user_id']]['win'] = 0;
|
||||
}
|
||||
if(!isset($win_user_most_hits_away[$row['user_id']]['win']))
|
||||
{
|
||||
$win_user_most_hits_away[$row['user_id']]['win'] = 0;
|
||||
}
|
||||
if(!isset($season_wins[$row['user_id']]['win']))
|
||||
{
|
||||
$season_wins[$row['user_id']]['win'] = 0;
|
||||
}
|
||||
$win_total = sprintf('%01.2f',$row['wins'] + $win_user_most_hits[$row['user_id']]['win'] + $win_user_most_hits_away[$row['user_id']]['win']
|
||||
+ $season_wins[$row['user_id']]['win']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$win_total = sprintf('%01.2f',$row['wins']);
|
||||
}
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($row['status']);
|
||||
|
||||
$template->assign_block_vars('rankstotal', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rankof[$row['user_id']],
|
||||
'CHANGE_SIGN' => $change_sign,
|
||||
'CHANGE_IMG' => $change_img,
|
||||
'CHANGE_DIFFER' => $change_differ,
|
||||
'USERID' => $row['user_id'],
|
||||
'USERNAME' => $row['username'],
|
||||
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'BETS' => $betsof[$row['user_id']],
|
||||
'NOBETS' => ($nobetsof[$row['user_id']] == 0) ? ' ' : $nobetsof[$row['user_id']],
|
||||
'TENDENCIES' => ($tendenciesof[$row['user_id']] == 0) ? ' ' : $tendenciesof[$row['user_id']],
|
||||
'DIRECTHITS' => ($hitsof[$row['user_id']] == 0) ? ' ' : $hitsof[$row['user_id']],
|
||||
'DIRECTHITS02' => ($hits02of[$row['user_id']] == 0) ? ' ' : $hits02of[$row['user_id']],
|
||||
'POINTS' => $row['points'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $win_total,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$league_info = league_info($season, $league);
|
||||
|
||||
$sidename = sprintf($user->lang['RANK_MATCHDAY']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANKS_MATCHDAY' => true,
|
||||
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['TABLE']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['RANK_TOTAL']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RANK_TOTAL']),
|
||||
'S_DATA_RANKS' => $data_ranks,
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
590
block/ranks_total.php
Normal file
590
block/ranks_total.php
Normal file
@@ -0,0 +1,590 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$start = $this->request->variable('start', 0);
|
||||
$mode = $this->request->variable('mode', '');
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'alltime':
|
||||
// Statistics
|
||||
$sql = "SELECT
|
||||
b.user_id,
|
||||
COUNT(b.match_no) AS matches,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
),
|
||||
0
|
||||
)
|
||||
) AS tendency
|
||||
FROM " . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . ' AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
LEFT JOIN ' . FOOTB_LEAGUES . " AS l ON (l.season = b.season AND l.league = b.league)
|
||||
WHERE b.league = $league
|
||||
AND ((b.season < $season) OR (b.season = $season AND m.matchday <= $matchday))
|
||||
AND m.status IN (2,3)
|
||||
GROUP BY user_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$rows = $db->sql_fetchrowset($result);
|
||||
$total_users = sizeof($rows);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($rows AS $row)
|
||||
{
|
||||
$bets_of[$row['user_id']] = $row['bets'];
|
||||
$nobets_of[$row['user_id']] = $row['matches'] - $row['bets'];
|
||||
}
|
||||
|
||||
// Wins
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
sum(r.win_total) As win_total
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . FOOTB_LEAGUES . " AS l ON (l.season = r.season AND l.league = r.league)
|
||||
WHERE r.league = $league
|
||||
AND ((r.season < $season AND r.matchday = l.matchdays) OR (r.season = $season AND r.matchday = $matchday))
|
||||
AND r.status IN (2,3)
|
||||
GROUP BY user_id
|
||||
ORDER BY r.user_id ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$win_arr = array();
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$win_arr[$row['user_id']] = $row['win_total'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$data_ranks = false;
|
||||
$pagination = '';
|
||||
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
min(r.status) AS status,
|
||||
sum(r.points) As points_total,
|
||||
sum(r.tendencies) As tendencies,
|
||||
sum(r.correct_result) As hits
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . ' AS u ON (r.user_id = u.user_id)
|
||||
LEFT JOIN ' . FOOTB_LEAGUES . " AS l ON (l.season = r.season AND l.league = r.league)
|
||||
WHERE r.league = $league
|
||||
AND ((r.season < $season) OR (r.season = $season AND r.matchday <= $matchday))
|
||||
AND r.status IN (2,3)
|
||||
GROUP BY user_id
|
||||
ORDER BY points_total DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$ranking_arr = array();
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$ranking_arr[$row['user_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$index_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$index_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
$index_end = $index_start + $config['football_users_per_page'] - 1;
|
||||
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'alltime'));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
|
||||
$index = 0;
|
||||
$rank = 0;
|
||||
$last_points = 0;
|
||||
$data_rank_total = false;
|
||||
foreach ($ranking_arr AS $curr_rank)
|
||||
{
|
||||
if ($curr_rank['points_total'] <> $last_points)
|
||||
{
|
||||
$rank = $index + 1;
|
||||
$last_points = $curr_rank['points_total'];
|
||||
}
|
||||
$data_ranks = true;
|
||||
if (($index_start <= $index) && ($index <= $index_end))
|
||||
{
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($curr_rank['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($curr_rank['status']);
|
||||
|
||||
$template->assign_block_vars('rankstotal', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'USERID' => $curr_rank['user_id'],
|
||||
'USERNAME' => $curr_rank['username'],
|
||||
'URL' => $phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $curr_rank['user_id'],
|
||||
'BETS' => $bets_of[$curr_rank['user_id']],
|
||||
'NOBETS' => ($nobets_of[$curr_rank['user_id']] == 0) ? ' ' : $nobets_of[$curr_rank['user_id']],
|
||||
'TENDENCIES' => ($curr_rank['tendencies'] == 0) ? ' ' : $curr_rank['tendencies'],
|
||||
'DIRECTHITS' => ($curr_rank['hits'] == 0) ? ' ' : $curr_rank['hits'],
|
||||
'POINTS' => $curr_rank['points_total'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $win_arr[$curr_rank['user_id']],
|
||||
)
|
||||
);
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['RANK_TOTAL']);
|
||||
$league_info = league_info($season, $league);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANKS_TOTAL' => true,
|
||||
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
|
||||
'S_DATA_RANKS' => $data_ranks,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['RANK_MATCHDAY']),
|
||||
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
|
||||
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' >' : sprintf($user->lang['MY_BETS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
|
||||
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
'S_WIN' => false,
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
'S_SHOW_OTHER_LINKS' => true,
|
||||
'S_HEADER' => sprintf($user->lang['RANKING_ALL_TIME']),
|
||||
'S_LINK_RANKING' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'S_LINK_ALL_TIME' => '',
|
||||
'S_LINK_COMPARE' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'compare')),
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'compare':
|
||||
// Statistics
|
||||
$sql = "SELECT
|
||||
b.season as season,
|
||||
b.user_id,
|
||||
COUNT(b.match_no) AS matches,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
),
|
||||
0
|
||||
)
|
||||
) AS tendency,
|
||||
SUM(IF(b.goals_home = m.goals_home AND b.goals_guest = m.goals_guest, 1, 0)) AS hits
|
||||
FROM " . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE b.season <= $season
|
||||
AND b.league = $league
|
||||
AND m.matchday <= $matchday
|
||||
AND m.status IN (2,3)
|
||||
GROUP BY b.season, b.user_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$rows = $db->sql_fetchrowset($result);
|
||||
$total_users = sizeof($rows);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($rows AS $row)
|
||||
{
|
||||
$bets_of[$row['user_id'] . '#' . $row['season']] = $row['bets'];
|
||||
$nobets_of[$row['user_id'] . '#' . $row['season']] = $row['matches'] - $row['bets'];
|
||||
$tendency_of[$row['user_id'] . '#' . $row['season']] = $row['tendency'];
|
||||
$hits_of[$row['user_id'] . '#' . $row['season']] = $row['hits'];
|
||||
}
|
||||
|
||||
// Wins
|
||||
$sql = 'SELECT
|
||||
r.season as season,
|
||||
r.user_id,
|
||||
sum(r.win_total) As win_total
|
||||
FROM ' . FOOTB_RANKS . " AS r
|
||||
WHERE r.season <= $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $matchday
|
||||
AND r.status IN (2,3)
|
||||
GROUP BY season, user_id
|
||||
ORDER BY r.user_id ASC, season ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$win_arr = array();
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$win_arr[$row['user_id'] . '#' . $row['season']] = $row['win_total'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$data_ranks = false;
|
||||
$pagination = '';
|
||||
|
||||
$sql = 'SELECT
|
||||
r.season,
|
||||
r.user_id,
|
||||
u.username,
|
||||
r.rank_total,
|
||||
r.status,
|
||||
r.points_total
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (r.user_id = u.user_id)
|
||||
WHERE r.season <= $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $matchday
|
||||
AND r.status IN (2,3)
|
||||
ORDER BY r.points_total DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$ranking_arr = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$index_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$index_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
$index_end = $index_start + $config['football_users_per_page'] - 1;
|
||||
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'compare'));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
|
||||
$index = 0;
|
||||
$rank = 0;
|
||||
$last_points = 0;
|
||||
$data_rank_total = false;
|
||||
foreach ($ranking_arr AS $curr_rank)
|
||||
{
|
||||
if ($curr_rank['points_total'] <> $last_points)
|
||||
{
|
||||
$rank = $index + 1;
|
||||
$last_points = $curr_rank['points_total'];
|
||||
}
|
||||
$data_ranks = true;
|
||||
if (($index_start <= $index) && ($index <= $index_end))
|
||||
{
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($curr_rank['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($curr_rank['status']);
|
||||
|
||||
$template->assign_block_vars('rankstotal', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'USERID' => $curr_rank['user_id'],
|
||||
'USERNAME' => $curr_rank['username'],
|
||||
'SEASON' => $curr_rank['season'],
|
||||
'SEASON_RANK' => $curr_rank['rank_total'],
|
||||
'URL' => $phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $curr_rank['user_id'],
|
||||
'BETS' => $bets_of[$curr_rank['user_id'] . '#' . $curr_rank['season']],
|
||||
'NOBETS' => ($nobets_of[$curr_rank['user_id'] . '#' . $curr_rank['season']] == 0) ? ' ' : $nobets_of[$curr_rank['user_id'] . '#' . $curr_rank['season']],
|
||||
'TENDENCIES' => ($tendency_of[$curr_rank['user_id'] . '#' . $curr_rank['season']] == 0) ? ' ' : $tendency_of[$curr_rank['user_id'] . '#' . $curr_rank['season']],
|
||||
'DIRECTHITS' => ($hits_of[$curr_rank['user_id'] . '#' . $curr_rank['season']] == 0) ? ' ' : $hits_of[$curr_rank['user_id'] . '#' . $curr_rank['season']],
|
||||
'POINTS' => $curr_rank['points_total'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $win_arr[$curr_rank['user_id'] . '#' . $curr_rank['season']],
|
||||
)
|
||||
);
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['RANK_TOTAL']);
|
||||
$league_info = league_info($season, $league);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANKS_TOTAL' => true,
|
||||
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
|
||||
'S_DATA_RANKS' => $data_ranks,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['RANK_MATCHDAY']),
|
||||
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
|
||||
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' >' : sprintf($user->lang['MY_BETS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
|
||||
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0' and $league_info['win_season'] == '0') ? false : ($this->auth->acl_gets('a_')) ? true : false,
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
'S_SHOW_OTHER_LINKS' => true,
|
||||
'S_HEADER' => sprintf($user->lang['RANKING_COMPARE']),
|
||||
'S_LINK_RANKING' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'S_LINK_ALL_TIME' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'alltime')),
|
||||
'S_LINK_COMPARE' => '',
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
$win_user_most_hits = array();
|
||||
$win_user_most_hits_away = array();
|
||||
$win_user_most_hits = win_user_most_hits($season, $league, $matchday);
|
||||
$win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
|
||||
|
||||
// Statistics
|
||||
$sql = "SELECT
|
||||
b.user_id,
|
||||
COUNT(b.match_no) AS matches,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
|
||||
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
|
||||
IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
),
|
||||
0
|
||||
)
|
||||
) AS tendency
|
||||
FROM " . FOOTB_BETS . ' AS b
|
||||
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE b.season = $season
|
||||
AND b.league = $league
|
||||
AND m.status IN (2,3)
|
||||
AND m.matchday <= $matchday
|
||||
GROUP BY user_id";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$rows = $db->sql_fetchrowset($result);
|
||||
$total_users = sizeof($rows);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($rows AS $row)
|
||||
{
|
||||
$bets_of[$row['user_id']] = $row['bets'];
|
||||
$nobets_of[$row['user_id']] = $row['matches'] - $row['bets'];
|
||||
$tendency_of[$row['user_id']] = $row['tendency'];
|
||||
}
|
||||
|
||||
$data_ranks = false;
|
||||
$pagination = '';
|
||||
|
||||
$prev_rank_of = array();
|
||||
if ($matchday > 1)
|
||||
{
|
||||
// previous rank total
|
||||
$sql = 'SELECT
|
||||
rank_total,
|
||||
user_id
|
||||
FROM ' . FOOTB_RANKS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
AND matchday = ($matchday-1)
|
||||
AND status IN (2,3)
|
||||
ORDER BY rank_total ASC, user_id ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
$rows = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($rows AS $row)
|
||||
{
|
||||
$prev_rank_of[$row['user_id']] = $row['rank_total'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT
|
||||
r.rank_total,
|
||||
r.user_id,
|
||||
u.username,
|
||||
u.user_colour,
|
||||
r.status,
|
||||
r.points_total,
|
||||
r.win_total
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (r.user_id = u.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
AND r.matchday = $matchday
|
||||
AND r.status IN (2,3)
|
||||
GROUP BY user_id
|
||||
ORDER BY r.points_total DESC, LOWER(u.username) ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$ranking_arr = array();
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$ranking_arr[$row['user_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
if ($start < 0 || $start >= $total_users)
|
||||
{
|
||||
$index_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$index_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
|
||||
}
|
||||
$index_end = $index_start + $config['football_users_per_page'] - 1;
|
||||
|
||||
// handle pagination.
|
||||
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday));
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
if ($user->data['football_mobile'])
|
||||
{
|
||||
$index_start = 0;
|
||||
$index_end = 9999;
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $index_end, $start);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
|
||||
}
|
||||
|
||||
$index = 0;
|
||||
$data_rank_total = false;
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
foreach ($ranking_arr AS $curr_rank)
|
||||
{
|
||||
$data_ranks = true;
|
||||
$rank = $curr_rank['rank_total'];
|
||||
|
||||
if (($index_start <= $index) && ($index <= $index_end))
|
||||
{
|
||||
// Display page
|
||||
if (isset($prev_rank_of[$curr_rank['user_id']]))
|
||||
{
|
||||
if ($rank == $prev_rank_of[$curr_rank['user_id']])
|
||||
{
|
||||
$change_sign = '=';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/no_change.gif\" alt=\"" . $user->lang['NO_CHANGES'] . "\"/>";
|
||||
$change_differ = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($rank > $prev_rank_of[$curr_rank['user_id']])
|
||||
{
|
||||
$change_sign = '+';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/arrow_down.gif\" alt=\"" . $user->lang['WORSENED'] . "\"/>";
|
||||
$differ = $rank - $prev_rank_of[$curr_rank['user_id']];
|
||||
$change_differ = ' (' . $differ . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$change_sign = '-';
|
||||
$change_img = "<img src=\"" . $ext_path . "images/arrow_up.gif\" alt=\"" . $user->lang['IMPROVED'] . "\"/>";
|
||||
$differ = $prev_rank_of[$curr_rank['user_id']] - $rank;
|
||||
$change_differ = ' (' . $differ . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$change_sign = '';
|
||||
$change_img = '';
|
||||
$change_differ = '';
|
||||
}
|
||||
|
||||
$win_total = sprintf('%01.2f',$curr_rank['win_total']);
|
||||
if(!isset($win_user_most_hits[$curr_rank['user_id']]['direct_hit']))
|
||||
{
|
||||
$win_user_most_hits[$curr_rank['user_id']]['direct_hit'] = 0;
|
||||
}
|
||||
if(!isset($win_user_most_hits_away[$curr_rank['user_id']]['direct_hit']))
|
||||
{
|
||||
$win_user_most_hits_away[$curr_rank['user_id']]['direct_hit'] = 0;
|
||||
}
|
||||
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($curr_rank['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$colorstyle = color_style($curr_rank['status']);
|
||||
|
||||
$template->assign_block_vars('rankstotal', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'CHANGE_SIGN' => $change_sign,
|
||||
'CHANGE_IMG' => $change_img,
|
||||
'CHANGE_DIFFER' => $change_differ,
|
||||
'USERID' => $curr_rank['user_id'],
|
||||
'USERNAME' => $curr_rank['username'],
|
||||
'U_PROFILE' => get_username_string('profile', $curr_rank['user_id'], $curr_rank['username'], $curr_rank['user_colour']),
|
||||
'BETS' => $bets_of[$curr_rank['user_id']],
|
||||
'NOBETS' => ($nobets_of[$curr_rank['user_id']] == 0) ? ' ' : $nobets_of[$curr_rank['user_id']],
|
||||
'TENDENCIES' => ($tendency_of[$curr_rank['user_id']] == 0) ? ' ' : $tendency_of[$curr_rank['user_id']],
|
||||
'DIRECTHITS' => ($win_user_most_hits[$curr_rank['user_id']]['direct_hit'] == 0) ? ' ' : $win_user_most_hits[$curr_rank['user_id']]['direct_hit'],
|
||||
'DIRECTHITS02' => ($win_user_most_hits_away[$curr_rank['user_id']]['direct_hit'] == 0) ? ' ' : $win_user_most_hits_away[$curr_rank['user_id']]['direct_hit'],
|
||||
'POINTS' => $curr_rank['points_total'],
|
||||
'COLOR_STYLE' => $colorstyle,
|
||||
'WIN' => $win_total,
|
||||
)
|
||||
);
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['RANK_TOTAL']);
|
||||
$league_info = league_info($season, $league);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RANKS_TOTAL' => true,
|
||||
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
|
||||
'S_DATA_RANKS' => $data_ranks,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['RANK_MATCHDAY']),
|
||||
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
|
||||
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' >' : sprintf($user->lang['MY_BETS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
|
||||
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
|
||||
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
|
||||
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0' and $league_info['win_season'] == '0') ? false : true,
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
'S_SHOW_OTHER_LINKS' => true,
|
||||
'S_LINK_RANKING' => '',
|
||||
'S_LINK_ALL_TIME' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'alltime')),
|
||||
'S_LINK_COMPARE' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday, 'mode' => 'compare')),
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
433
block/results.php
Normal file
433
block/results.php
Normal file
@@ -0,0 +1,433 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$user_is_member = user_is_member($user->data['user_id'], $season, $league);
|
||||
$edit_mode = false;
|
||||
$display_group = false;
|
||||
$display_ko = false;
|
||||
$data_results = false;
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
$matchnumber = 0;
|
||||
$editstatus = array(1, 2, 4, 5);
|
||||
|
||||
$league_info = league_info($season, $league);
|
||||
// Calculate matches AND results of matchday
|
||||
$sql = "SELECT
|
||||
m.match_no,
|
||||
m.matchday,
|
||||
m.status,
|
||||
m.group_id,
|
||||
m.formula_home,
|
||||
m.formula_guest,
|
||||
t1.team_symbol AS home_symbol,
|
||||
t2.team_symbol AS guest_symbol,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
t1.team_name AS home_name,
|
||||
t2.team_name AS guest_name,
|
||||
t1.team_name_short AS home_short,
|
||||
t2.team_name_short AS guest_short,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
m.ko_match AS ko_match,
|
||||
m.goals_overtime_home AS kogoals_home,
|
||||
m.goals_overtime_guest AS kogoals_guest,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.match_datetime,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.match_datetime,' %d.%m. %H:%i')
|
||||
) AS match_time
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.matchday = $matchday
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_results = true;
|
||||
$matchnumber++ ;
|
||||
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if (0 == $row['home_id'])
|
||||
{
|
||||
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
|
||||
$home_in_array = explode("#",$home_info);
|
||||
$homelogo = $home_in_array[0];
|
||||
$homeid = $home_in_array[1];
|
||||
$homename = $home_in_array[2];
|
||||
$homeshort = $home_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$homelogo = $row['home_symbol'];
|
||||
$homeid = $row['home_id'];
|
||||
$homename = $row['home_name'];
|
||||
$homeshort = $row['home_short'];
|
||||
}
|
||||
if (0 == $row['guest_id'])
|
||||
{
|
||||
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
|
||||
$guest_in_array = explode("#",$guest_info);
|
||||
$guestlogo = $guest_in_array[0];
|
||||
$guestid = $guest_in_array[1];
|
||||
$guestname = $guest_in_array[2];
|
||||
$guestshort = $guest_in_array[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$guestlogo = $row['guest_symbol'];
|
||||
$guestid = $row['guest_id'];
|
||||
$guestname = $row['guest_name'];
|
||||
$guestshort = $row['guest_short'];
|
||||
}
|
||||
if ($homelogo <> '')
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
if ($guestlogo <> '')
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($row['ko_match'])
|
||||
{
|
||||
$display_ko = true;
|
||||
$ko_match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ko_match = false;
|
||||
}
|
||||
|
||||
if ($row['group_id'] == '')
|
||||
{
|
||||
$group_id = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_group = true;
|
||||
$group_id = $row['group_id'];
|
||||
}
|
||||
|
||||
|
||||
if (in_array($row['status'], $editstatus) AND $user_is_member)
|
||||
{
|
||||
$edit_mode = true;
|
||||
$edit_match = true;
|
||||
$goals_home = $row['goals_home'];
|
||||
$goals_guest = $row['goals_guest'];
|
||||
$kogoals_home = $row['kogoals_home'];
|
||||
$kogoals_guest = $row['kogoals_guest'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$edit_match = false;
|
||||
$goals_home = ($row['goals_home'] == '') ? ' ' : $row['goals_home'];
|
||||
$goals_guest = ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'];
|
||||
$kogoals_home = ($row['kogoals_home'] == '') ? ' ' : $row['kogoals_home'];
|
||||
$kogoals_guest = ($row['kogoals_guest'] == '') ? ' ' : $row['kogoals_guest'];
|
||||
}
|
||||
$template->assign_block_vars('result', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'MATCH_NUMBER' => $row['match_no'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'STATUS' => $row['status'],
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'HOME_ID' => $homeid,
|
||||
'GUEST_ID' => $guestid,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $homename,
|
||||
'GUEST_NAME' => $guestname,
|
||||
'HOME_SHORT' => $homeshort,
|
||||
'GUEST_SHORT' => $guestshort,
|
||||
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $homeid, 'mode' => 'all')),
|
||||
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
|
||||
'tid' => $guestid, 'mode' => 'all')),
|
||||
'GOALS_HOME' => $goals_home,
|
||||
'GOALS_GUEST' => $goals_guest,
|
||||
'COLOR_STYLE' => color_style($row['status']),
|
||||
'KOGOALS_HOME' => $kogoals_home,
|
||||
'KOGOALS_GUEST' => $kogoals_guest,
|
||||
'S_KO_MATCH' => $ko_match,
|
||||
'S_EDIT_MATCH' => $edit_match,
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Calculate extra bets of matchday
|
||||
// Start select team
|
||||
$sql = 'SELECT
|
||||
team_id AS option_value,
|
||||
team_name AS option_name
|
||||
FROM ' . FOOTB_TEAMS . "
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY team_name ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$option_rows = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($edit_mode)
|
||||
{
|
||||
$template->assign_block_vars('worldfootball', array('LEAGUE' => $league-1,));
|
||||
}
|
||||
|
||||
$sql = "SELECT e.*,
|
||||
t1.team_name AS result_team
|
||||
FROM " . FOOTB_EXTRA . ' AS e
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
|
||||
WHERE e.season = $season
|
||||
AND e.league = $league
|
||||
AND e.matchday_eval = $matchday
|
||||
ORDER BY e.extra_no ASC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extra_results = false;
|
||||
$extranumber = 0;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extra_results = true;
|
||||
$extranumber++ ;
|
||||
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '1':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
{
|
||||
$display_type = 1;
|
||||
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_HIT']);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
case '5':
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
$display_type = 2;
|
||||
$eval_title = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($row['extra_status'] > 0 && $row['extra_status'] < 3 && $user_is_member)
|
||||
{
|
||||
$edit_mode = true;
|
||||
$result_extra = ($row['result_team'] == NULL) ? '' : $row['result_team'];
|
||||
|
||||
$multiple = '';
|
||||
switch($row['question_type'])
|
||||
{
|
||||
case '2':
|
||||
{
|
||||
$multiple = ' multiple="multiple" size="3" ';
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
{
|
||||
$option_arr = array();
|
||||
for ($i = 65; $i <= 72; $i++)
|
||||
{
|
||||
if (strstr($row['question'], chr($i) . ':'))
|
||||
{
|
||||
$option_arr[] = array(
|
||||
'option_value' => chr($i),
|
||||
'option_name' => chr($i),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (sizeof($option_arr) > 1)
|
||||
{
|
||||
$display_type = 1;
|
||||
$option_rows = $option_arr;
|
||||
$result_extra = $row['result'];
|
||||
$multiple = ' multiple="multiple" size="3" ';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
{
|
||||
$option_arr = array();
|
||||
for ($i = 65; $i <= 72; $i++)
|
||||
{
|
||||
if (strstr($row['question'], chr($i) . ':'))
|
||||
{
|
||||
$option_arr[] = array(
|
||||
'option_value' => chr($i),
|
||||
'option_name' => chr($i),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (sizeof($option_arr) > 1)
|
||||
{
|
||||
$display_type = 1;
|
||||
$option_rows = $option_arr;
|
||||
$result_extra = $row['result'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('extra_result', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'EXTRA_NO' => $row['extra_no'],
|
||||
'S_EDIT_EXTRA' => true,
|
||||
'QUESTION' => $row['question'],
|
||||
'EXTRA_POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'EVALUATION_TITLE' => $eval_title,
|
||||
'RESULT' => ($display_type == 1) ? $result_extra : $row['result'],
|
||||
'S_DISPLAY_TYPE' => $display_type,
|
||||
)
|
||||
);
|
||||
|
||||
if ($display_type == 1)
|
||||
{
|
||||
$selected = ($row['result'] == '') ? ' selected="selected"' : '';
|
||||
|
||||
$template->assign_block_vars('extra_result.extra_option', array(
|
||||
'OPTION_VALUE' => '',
|
||||
'OPTION_NAME' => sprintf($user->lang['SELECT']),
|
||||
'S_SELECTED' => $selected));
|
||||
|
||||
foreach ($option_rows as $option_row)
|
||||
{
|
||||
if (strstr($row['result'], ';'))
|
||||
{
|
||||
$selected = '';
|
||||
$result_arr = explode(';', $row['result']);
|
||||
foreach($result_arr AS $result_value)
|
||||
{
|
||||
if ($result_value <> '')
|
||||
{
|
||||
if ($option_row['option_value'] == $result_value)
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = ($option_row['option_value'] == $row['result']) ? ' selected="selected"' : '';
|
||||
}
|
||||
$template->assign_block_vars('extra_result.extra_option', array(
|
||||
'OPTION_VALUE' => $option_row['option_value'],
|
||||
'OPTION_NAME' => $option_row['option_name'],
|
||||
'S_SELECTED' => $selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra_colorstyle = color_style($row['extra_status']);
|
||||
$extra_result = ($row['result'] == '') ? ' ' : $row['result'];
|
||||
$result_extra = ($row['result_team'] == NULL) ? ' ' : $row['result_team'];
|
||||
|
||||
$template->assign_block_vars('extra_result', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'S_EDIT_EXTRA' => false,
|
||||
'QUESTION' => $row['question'],
|
||||
'EXTRA_POINTS' => $row['extra_points'],
|
||||
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
|
||||
'RESULT' => ($display_type == 1) ? $result_extra : $extra_result,
|
||||
'COLOR_STYLE' => $extra_colorstyle,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['RESULTS']);
|
||||
switch ($league_info['bet_ko_type'])
|
||||
{
|
||||
case BET_KO_90:
|
||||
$result_explain = sprintf($user->lang['MIN90']);
|
||||
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
|
||||
break;
|
||||
case BET_KO_EXTRATIME:
|
||||
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
|
||||
$label_finalresult = sprintf($user->lang['PENALTY']);
|
||||
break;
|
||||
case BET_KO_PENALTY:
|
||||
$result_explain = sprintf($user->lang['PENALTY']);
|
||||
$display_ko = false;
|
||||
break;
|
||||
default:
|
||||
$result_explain = sprintf($user->lang['MIN90']);
|
||||
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_RESULTS' => true,
|
||||
'S_EXTRA_RESULTS' => $extra_results,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'RESULT_EXPLAIN' => $result_explain,
|
||||
'LABEL_FINALRESULT' => $label_finalresult,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['ALL_BETS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['TABLE']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_ALL_BETS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
|
||||
'S_FORM_ACTION_RESULT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'result')),
|
||||
'S_DATA_RESULTS' => $data_results,
|
||||
'S_USER_IS_MEMBER' => $user_is_member,
|
||||
'S_DISPLAY_GROUP' => $display_group,
|
||||
'S_DISPLAY_KO' => $display_ko,
|
||||
'S_EDIT_MODE' => $edit_mode,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
226
block/rules_popup.php
Normal file
226
block/rules_popup.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
// Can this user view Prediction Leagues pages?
|
||||
if (!$config['football_guest_view'])
|
||||
{
|
||||
if ($user->data['user_id'] == ANONYMOUS)
|
||||
{
|
||||
trigger_error('NO_GUEST_VIEW');
|
||||
}
|
||||
}
|
||||
if (!$config['football_user_view'])
|
||||
{
|
||||
// Only Prediction League member should see this page
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
}
|
||||
|
||||
// Football disabled?
|
||||
if ($config['football_disable'])
|
||||
{
|
||||
$message = (!empty($config['football_disable_msg'])) ? $config['football_disable_msg'] : 'FOOTBALL_DISABLED';
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
$season = $this->request->variable('s', 0);
|
||||
$league = $this->request->variable('l', 0);
|
||||
|
||||
// Check parms
|
||||
$error_message = '';
|
||||
if (!$season OR !$league)
|
||||
{
|
||||
$data_rules = false;
|
||||
if (!$season)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
}
|
||||
if (!$league)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$season_info = season_info($season);
|
||||
if (sizeof($season_info))
|
||||
{
|
||||
$season_name = $season_info['season_name'];
|
||||
$league_info = league_info($season, $league);
|
||||
if (sizeof($league_info))
|
||||
{
|
||||
$data_rules = true;
|
||||
$matchdays = $league_info['matchdays'];
|
||||
$league_name = $league_info['league_name'];
|
||||
|
||||
if ($user->data['is_registered'] and !$user->data['is_bot'])
|
||||
{
|
||||
$win_hits = '';
|
||||
$win_hits02 = '';
|
||||
$win_matchday = explode(';', "0;" . $league_info['win_matchday']);
|
||||
$win_season = explode(';',"0;" . $league_info['win_season']);
|
||||
$win_hits = $league_info['win_result'];
|
||||
$win_hits02 = $league_info['win_result_02'];
|
||||
|
||||
if($win_hits != '' AND $win_hits != 0)
|
||||
{
|
||||
$template->assign_block_vars('wintable', array(
|
||||
'WIN_DESC' => sprintf($user->lang['WIN_HITS']),
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('wintable.entry', array(
|
||||
'ROW_CLASS' => 'bg1 row_light',
|
||||
'RANK' => '1. ' . sprintf($user->lang['PLACE']),
|
||||
'WIN' => $win_hits,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if($win_hits02 != '' AND $win_hits02 != 0 AND $config['football_win_hits02'])
|
||||
{
|
||||
$template->assign_block_vars('wintable', array(
|
||||
'WIN_DESC' => sprintf($user->lang['WIN_HITS02']),
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('wintable.entry', array(
|
||||
'ROW_CLASS' => 'bg1 row_light',
|
||||
'RANK' => '1. ' . sprintf($user->lang['PLACE']),
|
||||
'WIN' => $win_hits02,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if($win_matchday[1] != '' AND $win_matchday[1] != 0)
|
||||
{
|
||||
$template->assign_block_vars('wintable', array(
|
||||
'WIN_DESC' => sprintf($user->lang['WINS_MATCHDAY']),
|
||||
)
|
||||
);
|
||||
$rank = 1;
|
||||
while ($win_matchday[$rank] != '')
|
||||
{
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('wintable.entry', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank . '. ' . sprintf($user->lang['PLACE']),
|
||||
'WIN' => $win_matchday[$rank],
|
||||
)
|
||||
);
|
||||
$rank++ ;
|
||||
if ($rank > sizeof($win_matchday)-1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($win_season[1] != '' AND $win_season[1] != 0)
|
||||
{
|
||||
$template->assign_block_vars('wintable', array(
|
||||
'WIN_DESC' => sprintf($user->lang['WINS_SEASON']),
|
||||
)
|
||||
);
|
||||
$rank = 1;
|
||||
while ($win_season[$rank] != '')
|
||||
{
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('wintable.entry', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank. '. ' . sprintf($user->lang['PLACE']),
|
||||
'WIN' => $win_season[$rank],
|
||||
)
|
||||
);
|
||||
$rank++ ;
|
||||
if ($rank > sizeof($win_season)-1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_rules = false;
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
$league_name = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_rules = false;
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
$season_name = '';
|
||||
}
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['FOOTBALL_RULES']);
|
||||
if ($data_rules)
|
||||
{
|
||||
$link_rules = append_sid($phpbb_root_path . "viewtopic.$phpEx?p=" . $league_info["rules_post_id"]);
|
||||
$points_tendency = ($league_info['points_mode'] < 3) ? sprintf($user->lang['POINTS_TENDENCY' . $league_info['points_mode']], $league_info['points_tendency']) : sprintf($user->lang['POINTS_TENDENCY'], $league_info['points_tendency']);
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_DATA_RULES' => $data_rules,
|
||||
'S_BET_IN_TIME' => $league_info['bet_in_time'],
|
||||
'S_RULES_POST_ID' => $league_info['rules_post_id'],
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
'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_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'],
|
||||
'LEAGUENAME' => $league_name,
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header(sprintf($user->lang['FOOTBALL_RULES' ]) . ' ' . $league_info['league_name'] . ' ' . $season_info['season_name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_DATA_RULES' => $data_rules,
|
||||
'S_BET_IN_TIME' => false,
|
||||
'S_RULES_POST_ID' => 0,
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'WIN_NAME' => $config['football_win_name'],
|
||||
'JOIN_MODE' => '',
|
||||
'POINTS_HIT' => '',
|
||||
'POINTS_TENDENCY' => '',
|
||||
'POINTS_DIFF' => '',
|
||||
'POINTS_LAST' => '',
|
||||
'LINK_RULES' => '',
|
||||
'SEASONNAME' => '',
|
||||
'LEAGUENAME' => '',
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header(sprintf($user->lang['FOOTBALL_RULES' ]));
|
||||
}
|
||||
$template->set_filenames(array(
|
||||
'body' => 'rules_popup.html'
|
||||
)
|
||||
);
|
||||
// $template->display('popup');
|
||||
|
||||
page_footer();
|
||||
|
||||
?>
|
||||
170
block/stat_points.php
Normal file
170
block/stat_points.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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 = false;
|
||||
$data_all = false;
|
||||
$rank = 0;
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
r.*
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE season = $season
|
||||
AND league = $league
|
||||
ORDER BY r.points DESC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, 20);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data = true;
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('top20', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'NAME' => $row['username'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'POINTS' => $row['points'],
|
||||
'WIN' => $row['win'],
|
||||
'DIRECTHITS' => $row['correct_result'],
|
||||
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
|
||||
'TOTAL' => $row['tendencies'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
r.*
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE r.season = $season
|
||||
AND r.league = $league
|
||||
ORDER BY r.points ASC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, 20);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('flop20', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'NAME' => $row['username'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'POINTS' => $row['points'],
|
||||
'DIRECTHITS' => $row['correct_result'],
|
||||
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
|
||||
'TOTAL' => $row['tendencies'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
r.*
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE league = $league
|
||||
ORDER BY r.points DESC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, 20);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_all = true;
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('alltop20', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'NAME' => $row['username'],
|
||||
'SEASON' => $row['season'],
|
||||
'MATCHDAY' => $row['matchday'],
|
||||
'POINTS' => $row['points'],
|
||||
'WIN' => $row['win'],
|
||||
'DIRECTHITS' => $row['correct_result'],
|
||||
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
|
||||
'TOTAL' => $row['tendencies'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$rank = 0;
|
||||
$sql = 'SELECT
|
||||
r.user_id,
|
||||
u.username,
|
||||
COUNT(points) AS count_zero
|
||||
FROM ' . FOOTB_RANKS . ' AS r
|
||||
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
|
||||
WHERE r.league = $league
|
||||
AND r.points = 0
|
||||
GROUP BY r.user_id
|
||||
ORDER BY count_zero DESC";
|
||||
|
||||
$result = $db->sql_query_limit($sql, 20);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
if ($row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
$row_class = 'bg3 row_user';
|
||||
}
|
||||
$template->assign_block_vars('allflop20', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'NAME' => $row['username'],
|
||||
'COUNTZERO' => $row['count_zero'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$league_info = league_info($season, $league);
|
||||
$sidename = sprintf($user->lang['STAT_POINTS']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_STAT_POINTS' => true,
|
||||
'S_MATCHDAY_HIDE' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['MY_KOEFF']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'stat_results', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['STAT_RESULTS']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_KOEFF']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_STAT_RESULTS']),
|
||||
'S_DATA_STAT_POINTS' => $data,
|
||||
'S_DATA_ALL_POINTS' => $data_all,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
146
block/stat_results.php
Normal file
146
block/stat_results.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?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 = false;
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
$rank = 0;
|
||||
// Select results and count
|
||||
$sql = 'SELECT
|
||||
COUNT(DISTINCT(m.match_no)) AS count_result,
|
||||
COUNT(m.match_no) AS count_bets,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
|
||||
)
|
||||
) AS hits,
|
||||
SUM(IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
|
||||
OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
|
||||
OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest),
|
||||
0,
|
||||
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
|
||||
)
|
||||
) AS tendencies,
|
||||
' . select_points('m',true) . '
|
||||
FROM ' . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_BETS . " AS b ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND b.goals_home <> ''
|
||||
AND b.goals_guest <> ''
|
||||
AND (m.status IN (3,6))
|
||||
AND m.matchday <= $matchday
|
||||
GROUP BY m.goals_home, m.goals_guest
|
||||
ORDER BY count_bets DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data = true;
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$template->assign_block_vars('result', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'GOALS_HOME' => $row['goals_home'],
|
||||
'GOALS_GUEST' => $row['goals_guest'],
|
||||
'RESULTS' => $row['count_result'],
|
||||
'BETS' => $row['count_bets'],
|
||||
'HITS' => $row['hits'],
|
||||
'TENDENCIES' => $row['tendencies'],
|
||||
'TOTAL' => $row['hits'] + $row['tendencies'],
|
||||
'POINTS' => $row['points'],
|
||||
'AVERAGE' => round($row['points'] / $row['count_bets'],1),
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
// Get goaldifferences by team
|
||||
$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 wins,
|
||||
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+2), 1, 0), IF((goals_home + 2) < goals_guest, 1, 0))) AS plus3,
|
||||
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+2), 1, 0), IF((goals_home + 2) = goals_guest, 1, 0))) AS plus2,
|
||||
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+1), 1, 0), IF((goals_home + 1) = goals_guest, 1, 0))) AS plus1,
|
||||
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 1) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 1), 1, 0))) AS minus1,
|
||||
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 2), 1, 0))) AS minus2,
|
||||
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) < goals_guest, 1, 0), IF(goals_home + 0 > (goals_guest + 2), 1, 0))) AS minus3,
|
||||
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 goal_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
|
||||
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))
|
||||
WHERE t.season = $season
|
||||
AND t.league = $league
|
||||
AND m.season = $season
|
||||
AND m.league = $league
|
||||
AND m.status IN (3,6)
|
||||
AND m.matchday <= $matchday
|
||||
GROUP BY t.team_id
|
||||
ORDER BY points DESC, goal_diff DESC, goals DESC";
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$rank = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rank++;
|
||||
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
$template->assign_block_vars('points', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'RANK' => $rank,
|
||||
'LOGO' => $logo,
|
||||
'TEAM' => $row['team_name_short'],
|
||||
'MATCHES' => $row['matches'],
|
||||
'PLUS3' => $row['plus3'],
|
||||
'PLUS2' => $row['plus2'],
|
||||
'PLUS1' => $row['plus1'],
|
||||
'DRAW' => $row['draw'],
|
||||
'MINUS1' => $row['minus1'],
|
||||
'MINUS2' => $row['minus2'],
|
||||
'MINUS3' => $row['minus3'],
|
||||
'GOALS_DIFF' => $row['goal_diff'],
|
||||
'POINTS' => $row['points'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sidename = sprintf($user->lang['STAT_RESULTS']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_STAT_RESULTS' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['STAT_POINTS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['BET']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_STAT_POINTS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_BET']),
|
||||
'S_DATA_STAT_RESULTS' => $data,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
420
block/table.php
Normal file
420
block/table.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?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;
|
||||
$data_form = false;
|
||||
|
||||
if ($matchday > 5)
|
||||
{
|
||||
$form_from = $matchday - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
$form_from = 1;
|
||||
}
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FOOTB_LEAGUES . "
|
||||
WHERE season = $season
|
||||
AND league = $league";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$league_type = $row['league_type'];
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
|
||||
|
||||
$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))
|
||||
)
|
||||
) - 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);
|
||||
$last_group = '';
|
||||
$current_rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($last_group != $row['group_id'])
|
||||
{
|
||||
$last_group = $row['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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$data_table = true;
|
||||
$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
|
||||
$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.matchday >= $form_from
|
||||
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);
|
||||
$last_group = '';
|
||||
$current_rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($last_group != $row['group_id'])
|
||||
{
|
||||
$last_group = $row['group_id'];
|
||||
$rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
$template->assign_block_vars('form', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$data_form = true;
|
||||
$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('form', 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' => 'rest')),
|
||||
'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 home-table-information
|
||||
$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(goals_home - goals_guest) AS goals_diff,
|
||||
SUM(goals_home) AS goals,
|
||||
SUM(goals_guest) 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 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);
|
||||
$last_group = '';
|
||||
$current_rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($last_group != $row['group_id'])
|
||||
{
|
||||
$last_group = $row['group_id'];
|
||||
$rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
$template->assign_block_vars('home', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$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('home', 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' => 'home')),
|
||||
'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 away-table-information
|
||||
$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(goals_guest - goals_home) AS goals_diff,
|
||||
SUM(goals_guest) AS goals,
|
||||
SUM(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_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);
|
||||
$last_group = '';
|
||||
$current_rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($last_group != $row['group_id'])
|
||||
{
|
||||
$last_group = $row['group_id'];
|
||||
$rank = 0;
|
||||
$last_goals = 0;
|
||||
$last_goals_againts = 0;
|
||||
$last_points = 0;
|
||||
$template->assign_block_vars('away', array(
|
||||
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($league_type != 2 OR $row['group_id'] != '')
|
||||
{
|
||||
$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('away', 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' => 'away')),
|
||||
'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);
|
||||
$sidename = sprintf($user->lang['TABLE']);
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_TABLE' => true,
|
||||
'S_SIDENAME' => $sidename,
|
||||
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'LEFT_LINK' => '< ' . sprintf($user->lang['RESULTS']),
|
||||
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
|
||||
'RIGHT_LINK' => sprintf($user->lang['RANK_MATCHDAY']) . ' >',
|
||||
'LEFT_TITLE' => sprintf($user->lang['TITLE_RESULTS']),
|
||||
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
|
||||
'S_DATA_TABLE' => $data_table,
|
||||
'S_DATA_FORM' => $data_form,
|
||||
'SEASON' => $season,
|
||||
'LEAGUE' => $league,
|
||||
'TEXT_FORM' => $text_form,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
23
block/under_construction.php
Normal file
23
block/under_construction.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Football
|
||||
* @version $Id: under_construction.php 1 2010-05-17 22:09:43Z football $
|
||||
* @copyright (c) 2010 football (http://football.bplaced.net)
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if ( !defined('IN_PHPBB') OR !defined('IN_FOOTBALL') )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['UNDER_CONSTRUCTION']);
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_DISPLAY_UNDER_CONSTRUCTION' => true,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
297
block/viewplan_popup.php
Normal file
297
block/viewplan_popup.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
// Can this user view Prediction Leagues pages?
|
||||
if (!$config['football_guest_view'])
|
||||
{
|
||||
if ($user->data['user_id'] == ANONYMOUS)
|
||||
{
|
||||
trigger_error('NO_GUEST_VIEW');
|
||||
}
|
||||
}
|
||||
if (!$config['football_user_view'])
|
||||
{
|
||||
// Only Prediction League member should see this page
|
||||
// Check Prediction League authorisation
|
||||
if ( !$this->auth->acl_get('u_use_football') )
|
||||
{
|
||||
trigger_error('NO_AUTH_VIEW');
|
||||
}
|
||||
}
|
||||
|
||||
// Football disabled?
|
||||
if ($config['football_disable'])
|
||||
{
|
||||
$message = (!empty($config['football_disable_msg'])) ? $config['football_disable_msg'] : 'FOOTBALL_DISABLED';
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
$mode = $this->request->variable('mode', '');
|
||||
$season = $this->request->variable('s', 0);
|
||||
$league = $this->request->variable('l', 0);
|
||||
$team_id = $this->request->variable('tid', 0);
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'played':
|
||||
$mode_desc = sprintf($user->lang['PLAYED_MATCHES']);
|
||||
$where = ' AND m.status IN (3,6) ';
|
||||
$data_results = true;
|
||||
break;
|
||||
case 'rest':
|
||||
$mode_desc = sprintf($user->lang['REST_MATCHES']);
|
||||
$where = ' AND m.status IN (0,1,2,4,5) ';
|
||||
$data_results = false;
|
||||
break;
|
||||
case 'home':
|
||||
$mode_desc = sprintf($user->lang['HOME_MATCHES']);
|
||||
$where = " AND m.team_id_home = $team_id AND m.status IN (3,6) ";
|
||||
$data_results = true;
|
||||
break;
|
||||
case 'away':
|
||||
$mode_desc = sprintf($user->lang['AWAY_MATCHES']);
|
||||
$where = " AND m.team_id_guest = $team_id AND m.status IN (3,6) ";
|
||||
$data_results = true;
|
||||
break;
|
||||
// ALL is Default
|
||||
default:
|
||||
$mode_desc = sprintf($user->lang['ALL_MATCHES']);
|
||||
$where = '';
|
||||
$data_results = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check parms
|
||||
$error_message = '';
|
||||
if (!$season OR !$league OR !$team_id)
|
||||
{
|
||||
$data_plan = false;
|
||||
if (!$season)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
}
|
||||
if (!$league)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
}
|
||||
if (!$team_id)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_TEAM_ID']) . '<br />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_group = false;
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
|
||||
|
||||
// Calculate matches and bets of matchday
|
||||
$sql = "SELECT
|
||||
IF(m.team_id_home = $team_id, 'H', 'A') AS match_place,
|
||||
IF(((m.status=3) OR (m.status=6)),
|
||||
IF(m.team_id_home = $team_id,
|
||||
IF(m.goals_home + 0 > m.goals_guest, 'match_win', IF(m.goals_home = m.goals_guest, 'match_draw', 'match_lost')),
|
||||
IF(m.goals_home + 0 < m.goals_guest, 'match_win', IF(m.goals_home = m.goals_guest, 'match_draw', 'match_lost'))),
|
||||
'') AS match_style,
|
||||
m.match_no,
|
||||
m.matchday,
|
||||
m.status,
|
||||
m.group_id,
|
||||
t1.team_symbol AS home_symbol,
|
||||
t2.team_symbol AS guest_symbol,
|
||||
t1.team_id AS home_id,
|
||||
t2.team_id AS guest_id,
|
||||
t1.team_name AS home_name,
|
||||
t2.team_name AS guest_name,
|
||||
t1.team_name_short AS home_short,
|
||||
t2.team_name_short AS guest_short,
|
||||
m.goals_home,
|
||||
m.goals_guest,
|
||||
CONCAT(
|
||||
CASE DATE_FORMAT(m.match_datetime,'%w')
|
||||
WHEN 0 THEN '" . $lang_dates['Sun'] . "'
|
||||
WHEN 1 THEN '" . $lang_dates['Mon'] . "'
|
||||
WHEN 2 THEN '" . $lang_dates['Tue'] . "'
|
||||
WHEN 3 THEN '" . $lang_dates['Wed'] . "'
|
||||
WHEN 4 THEN '" . $lang_dates['Thu'] . "'
|
||||
WHEN 5 THEN '" . $lang_dates['Fri'] . "'
|
||||
WHEN 6 THEN '" . $lang_dates['Sat'] . "'
|
||||
ELSE 'Error' END,
|
||||
DATE_FORMAT(m.match_datetime,' %d.%m. %H:%i')
|
||||
) AS match_time
|
||||
FROM " . FOOTB_MATCHES . ' AS m
|
||||
LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id=m.team_id_home)
|
||||
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id=m.team_id_guest)
|
||||
WHERE m.season = $season
|
||||
AND m.league = $league
|
||||
AND (m.team_id_home = $team_id OR m.team_id_guest = $team_id)
|
||||
$where
|
||||
GROUP BY m.match_no
|
||||
ORDER BY m.match_datetime ASC, m.match_no ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$data_plan = true;
|
||||
$matchnumber = 0;
|
||||
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
|
||||
do
|
||||
{
|
||||
$matchnumber++ ;
|
||||
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
|
||||
$display_link = true;
|
||||
$homelogo = $row['home_symbol'];
|
||||
$guestlogo = $row['guest_symbol'];
|
||||
if ($homelogo <> '')
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
if ($guestlogo <> '')
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
|
||||
if ($row['group_id'] == '')
|
||||
{
|
||||
$group_id = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_group = true;
|
||||
$group_id = $row['group_id'];
|
||||
}
|
||||
|
||||
if ($row['match_place'] == 'H')
|
||||
{
|
||||
$color_home = $row['match_style'];
|
||||
$color_guest = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color_home = '';
|
||||
$color_guest = $row['match_style'];
|
||||
}
|
||||
$color_goals = $row['match_style'];
|
||||
|
||||
$template->assign_block_vars('match', array(
|
||||
'ROW_CLASS' => $row_class,
|
||||
'MATCH_TIME' => $row['match_time'],
|
||||
'GROUP' => $group_id,
|
||||
'LOGO_HOME' => $logoH,
|
||||
'LOGO_GUEST' => $logoG,
|
||||
'HOME_NAME' => $row['home_short'],
|
||||
'GUEST_NAME' => $row['guest_short'],
|
||||
'GOALS_HOME' => ($row['goals_home'] == '') ? ' ' : $row['goals_home'],
|
||||
'GOALS_GUEST' => ($row['goals_guest'] == '') ? ' ' : $row['goals_guest'],
|
||||
'COLOR_HOME' => $color_home,
|
||||
'COLOR_GUEST' => $color_guest,
|
||||
'COLOR_GOALS' => $color_goals,
|
||||
)
|
||||
);
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data_plan = false;
|
||||
}
|
||||
|
||||
$season_info = season_info($season);
|
||||
if (sizeof($season_info) == 0)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
|
||||
$season_name = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$season_name = $season_info["season_name"];
|
||||
|
||||
$league_info = league_info($season, $league);
|
||||
if (sizeof($league_info) == 0)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
|
||||
$league_name = '';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$league_name = $league_info["league_name"];
|
||||
|
||||
$team_info = team_info($season, $league, $team_id);
|
||||
if (sizeof($team_info) == 0)
|
||||
{
|
||||
$error_message .= sprintf($user->lang['NO_TEAM_ID']) . '<br />';
|
||||
$team_name = '';
|
||||
$logo = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$team_name = $team_info["team_name"];
|
||||
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $team_info["team_symbol"] . "\" alt=\"" . $team_info["team_symbol"] . "\" width=\"28\" height=\"28\"/>" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sidename = sprintf($user->lang['PLAN']);
|
||||
if ($data_plan)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_DATA_PLAN' => $data_plan,
|
||||
'S_DATA_GROUP' => $data_group,
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'MODE_DESC' => $mode_desc,
|
||||
'LOGO' => $logo,
|
||||
'TEAM' => $team_name,
|
||||
'SEASON' => $season_name,
|
||||
'LEAGUE' => $league_name,
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'S_DATA_RESULTS' => $data_results,
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header($mode_desc . ' ' . $team_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SIDENAME' => $sidename,
|
||||
'S_DATA_PLAN' => $data_plan,
|
||||
'S_DATA_GROUP' => false,
|
||||
'S_ERROR_MESSAGE' => $error_message,
|
||||
'MODE_DESC' => $mode_desc,
|
||||
'LOGO' => '',
|
||||
'TEAM' => '',
|
||||
'SEASON' => '',
|
||||
'LEAGUE' => '',
|
||||
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
|
||||
'S_DATA_RESULTS' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// output page
|
||||
page_header($mode_desc);
|
||||
}
|
||||
$template->set_filenames(array(
|
||||
'body' => 'viewplan_popup.html')
|
||||
);
|
||||
|
||||
page_footer();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user