Change order of tippers in all_bets site according to the tipper vs tipper matches and change background color.

This commit is contained in:
2018-04-03 22:16:31 +02:00
parent e1db71c99d
commit 8b679b1286

View File

@@ -14,11 +14,23 @@ if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
$start = $this->request->variable('start', 0); $start = $this->request->variable('start', 0);
$matches_on_matchday = false; $matches_on_matchday = false;
$league_info = league_info($season, $league);
$sql = 'SELECT COUNT(DISTINCT user_id) AS num_users if($league_info['bet_type'])
FROM ' . FOOTB_BETS . " {
WHERE season = $season AND league = $league"; $sql = 'SELECT COUNT(DISTINCT b.user_id) AS num_users
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)
WHERE b.season = $season AND b.league = $league AND m.matchday = $matchday";
}
else
{
$sql = 'SELECT COUNT(DISTINCT b.user_id) AS num_users
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_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE b.season = $season AND b.league = $league AND m.matchday = $matchday AND (m2.match_no IS NOT NULL || m3.match_no IS NOT NULL) ";
}
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('num_users'); $total_users = (int) $db->sql_fetchfield('num_users');
$db->sql_freeresult($result); $db->sql_freeresult($result);
@@ -79,7 +91,7 @@ if ($user->data['football_mobile'])
} }
else else
{ {
if ($count_matches > 11) if ($count_matches > 12)
{ {
$split_after = 8; $split_after = 8;
$splits = ceil($count_matches / 8); $splits = ceil($count_matches / 8);
@@ -125,21 +137,47 @@ if ($count_matches > 0)
{ {
$matches_on_matchday = true; $matches_on_matchday = true;
$sql = "SELECT if($league_info['bet_type'])
u.user_id, {
u.username, $sql = "SELECT
m.status, u.user_id,
b.goals_home AS bet_home, u.username,
b.goals_guest AS bet_guest, m.status,
" . select_points() . ' b.goals_home AS bet_home,
FROM ' . FOOTB_MATCHES . ' AS m b.goals_guest AS bet_guest,
LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no) IFNULL(m2.match_no,m3.match_no),
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id) " . select_points() . '
WHERE m.season = $season FROM ' . FOOTB_MATCHES . ' AS m
AND m.league = $league LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
AND m.matchday = $matchday LEFT JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
ORDER BY LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC"; LEFT JOIN ' . FOOTB_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE m.season = $season
AND m.league = $league
AND m.matchday = $matchday
ORDER BY IFNULL(m2.match_no,m3.match_no) ASC, m3.match_no ASC, LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
}
else
{
$sql = "SELECT
u.user_id,
u.username,
m.status,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
IFNULL(m2.match_no,m3.match_no),
" . 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)
LEFT JOIN ' . FOOTB_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE m.season = $season
AND m.league = $league
AND m.matchday = $matchday
AND (m3.match_no IS NOT NULL OR m2.match_no IS NOT NULL)
ORDER BY IFNULL(m2.match_no,m3.match_no) ASC, m3.match_no ASC, LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
}
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
$user_bets = $db->sql_fetchrowset($result); $user_bets = $db->sql_fetchrowset($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@@ -181,7 +219,15 @@ foreach ($matches AS $match)
if ($bet_index == 0) if ($bet_index == 0)
{ {
$count_user++; $count_user++;
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark'; $league_info = league_info($season, $league);
if ($league_info['bet_type'])
{
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
}
else
{
$row_class = (!(($count_user + ($count_user % 2)) % 4)) ? 'bg1 row_light' : 'bg2 row_dark';
}
if ($user_bet['user_id'] == $user->data['user_id']) if ($user_bet['user_id'] == $user->data['user_id'])
{ {
$row_class = 'bg3 row_user'; $row_class = 'bg3 row_user';
@@ -276,11 +322,11 @@ foreach ($matches AS $match)
} }
$colorstyle_match = color_style($match['status']); $colorstyle_match = color_style($match['status']);
$template->assign_block_vars('match_panel.match_entry', array( $template->assign_block_vars('match_panel.match_entry', array(
'HOME_NAME' => $homename, 'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname, 'GUEST_NAME' => $guestname,
'RESULT' => $match['goals_home']. ':'.$match['goals_guest'], 'RESULT' => $match['goals_home']. ':'.$match['goals_guest'],
'COLOR_STYLE' => $colorstyle_match, 'COLOR_STYLE' => $colorstyle_match,
'MATCH_TIME' => $match['match_time'], 'MATCH_TIME' => $match['match_time'],
) )
); );
if ($match['status'] < 1 && !$config['football_view_tendencies']) if ($match['status'] < 1 && !$config['football_view_tendencies'])
@@ -300,59 +346,70 @@ if ($count_matches > 0)
$total = 0; $total = 0;
$count_user = 0; $count_user = 0;
$bet_index = 0; $bet_index = 0;
foreach ($bet_line[$split_index] AS $user_bet) if(!empty($bet_line))
{ {
if ($bet_index == 0) foreach ($bet_line[$split_index] AS $user_bet)
{ {
$count_user++; if ($bet_index == 0)
$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'; $count_user++;
$league_info = league_info($season, $league);
if ($league_info['bet_type'])
{
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
}
else
{
$row_class = (!(($count_user + ($count_user % 2)) % 4)) ? '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;
} }
$template->assign_block_vars('match_panel.user_row', array( $bet_index++;
'ROW_CLASS' => $row_class, $total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
'USER_NAME' => $user_bet['username'], 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'] == '') ? '&nbsp;' : $user_bet['points'],
) )
); );
$total = 0;
}
$bet_index++;
$total += ($user_bet['points'] == '') ? 0 : $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']); if ($bet_index == $last_match_index)
$template->assign_block_vars('match_panel.user_row.bet', array( {
'BET' => $bet_home. ':'. $bet_guest, $sum_total[$user_bet['username']] += $total;
'COLOR_STYLE' => $colorstyle_bet, $matchday_sum_total += $total;
'POINTS' => ($user_bet['points'] == '') ? '&nbsp;' : $user_bet['points'], $template->assign_block_vars('match_panel.user_row.points', array(
) 'COLOR_STYLE' => $colorstyle_total,
); 'POINTS_TOTAL' => $sum_total[$user_bet['username']],
)
if ($bet_index == $last_match_index) );
{ $bet_index = 0;
$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;
} }
} }
@@ -463,7 +520,7 @@ while ($row = $db->sql_fetchrow($result))
while ($user_row = $db->sql_fetchrow($result_bet)) while ($user_row = $db->sql_fetchrow($result_bet))
{ {
$bet_number++ ; $bet_number++ ;
$row_class = (!($bet_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark'; $row_class = (!(($count_user + ($count_user % 2)) % 4)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($user_row['user_id'] == $user->data['user_id']) if ($user_row['user_id'] == $user->data['user_id'])
{ {
$row_class = 'bg3 row_user'; $row_class = 'bg3 row_user';