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);
$matches_on_matchday = false;
$sql = 'SELECT COUNT(DISTINCT user_id) AS num_users
FROM ' . FOOTB_BETS . "
WHERE season = $season AND league = $league";
$league_info = league_info($season, $league);
if($league_info['bet_type'])
{
$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);
$total_users = (int) $db->sql_fetchfield('num_users');
$db->sql_freeresult($result);
@@ -79,7 +91,7 @@ if ($user->data['football_mobile'])
}
else
{
if ($count_matches > 11)
if ($count_matches > 12)
{
$split_after = 8;
$splits = ceil($count_matches / 8);
@@ -125,21 +137,47 @@ 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";
if($league_info['bet_type'])
{
$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
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);
$user_bets = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
@@ -181,7 +219,15 @@ foreach ($matches AS $match)
if ($bet_index == 0)
{
$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'])
{
$row_class = 'bg3 row_user';
@@ -276,11 +322,11 @@ foreach ($matches AS $match)
}
$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,
'MATCH_TIME' => $match['match_time'],
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'RESULT' => $match['goals_home']. ':'.$match['goals_guest'],
'COLOR_STYLE' => $colorstyle_match,
'MATCH_TIME' => $match['match_time'],
)
);
if ($match['status'] < 1 && !$config['football_view_tendencies'])
@@ -300,59 +346,70 @@ if ($count_matches > 0)
$total = 0;
$count_user = 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++;
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($user_bet['user_id'] == $user->data['user_id'])
if ($bet_index == 0)
{
$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;
}
$bet_index++;
$total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
if ($user_bet['status'] < 3)
{
$colorstyle_total = ' color_provisionally';
}
$template->assign_block_vars('match_panel.user_row', array(
'ROW_CLASS' => $row_class,
'USER_NAME' => $user_bet['username'],
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']);
$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'],
)
);
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;
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;
}
}
}
@@ -463,7 +520,7 @@ while ($row = $db->sql_fetchrow($result))
while ($user_row = $db->sql_fetchrow($result_bet))
{
$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'])
{
$row_class = 'bg3 row_user';