Show all player leagues in 1 view, reduce nav Dropdown meny item count

This commit is contained in:
Torsten 2017-11-09 11:53:20 +01:00
parent 02329d5c21
commit c337916a3b
9 changed files with 93 additions and 47 deletions

View file

@ -66,6 +66,12 @@ class LeaguesController extends Controller
}
public function createLeagues($start_round_id, $round_count) {
$users=User::getActives();
if (sizeof($users)==0){
return view("leagues.no_users");
}
League::createLeagues($start_round_id, $round_count);
Log::info("LeaguesController::createLeagues completed.");
@ -103,18 +109,15 @@ class LeaguesController extends Controller
return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames'));
}
public static function showLeagueRanking($rank, $maxRoundId=-1) {
public static function showLeagueRanking() {
$season = Season::getCurrent();
$leagues = array_reverse(League::getRanking($rank));
//$leagues = array_reverse(League::getRanking($rank));
$leagueNames = League::getNames();
$userNames = User::getNames();
$leagueScores = League::getRanking($rank);
$totalRanking = League::getTotalRankingOverall(); // Nur für Auf/Abstiegsinfo benötigt.
$rankInfo=array();
foreach($totalRanking as $index => $entry) {
$userId=$entry[0];
$rankInfo[$userId]=$totalRanking[$index][4];
@ -126,9 +129,12 @@ class LeaguesController extends Controller
$cols[3]="lightgrey";
$cols[4]="";
$leagueScores=array();
foreach([1,2,3,4] as $rank) {
$leagueScores[$rank] = League::getRanking($rank);
}
return view ('leagues.chart',compact('season','leagues', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
return view ('leagues.chart',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
}
public static function showSingleUserMatches($userId) {

View file

@ -49,11 +49,27 @@ class Season extends Model
return $seasons[1];
}
public static function hasQualifications($seasonId) {
$leagues = League::where('season_id','=',$seasonId)->get();
foreach($leagues as $league) {
if ($league->rank == League::RANK_QUALIFICATION) return true;
public static function hasQualifications($seasonId=-1) {
return Season::hasLeagueType($seasonId,League::RANK_QUALIFICATION);
}
public static function hasStandardLeague($seasonId=-1) {
return Season::hasLeagueType($seasonId,League::RANK_LEAGUE1);
}
public static function hasLeagueType($seasonId=-1, $ltype) {
$season=null;
if ($seasonId==-1) {
$season = Season::getCurrent();
if (!$season) return false;
$seasonId=$season->id;
}
$leagues = League::where('season_id', '=', $seasonId)->get();
foreach ($leagues as $league) {
if ($league->rank == $ltype) return true;
}
return false;
}
}

View file

@ -402,6 +402,9 @@ class Tipp extends Model
$totalDayWinPayout = 0;
$round_count=0;
error_log("Round ids: ".implode(",",$round_ids));
foreach ($round_ids as $round_id) {
$round_count += 1;
$totalDayWinPayout += $payouts["tagessieg"];
@ -474,6 +477,9 @@ class Tipp extends Model
}
$quotas=Quota::getQuotas($currentSeason->id);
error_log("Round-Count=".$round_count);
if ($round_count==$quotas["Runden"]) {
// Ranking Payout ausschütten
$payout_groups =array();
@ -505,7 +511,7 @@ class Tipp extends Model
$single_payout = $rankPayout / $groupsize;
foreach($payout_groups[$current_rank] as $user_id) {
$key = $round_count."_".$user_id;
$key = $lastRoundId."_".$user_id;
$roundtipps[$key]["ranking_payout"] += $single_payout;
}
$current_rank=0;

View file

@ -31,7 +31,7 @@ class Match extends Model
$currentSeason = Season::getCurrent();
$leagues = League::where('season_id', '=', $currentSeason->id)->get();
foreach ($leagues as $league) {
error_log("Match::createMatchups league_id=".$league->id);
Log::info("Creating matchups for league_id=".$league->id);
// Wenn es keine previous League gibt, dann ist $league->rank immer RANK_QUALIFICATION,
// ansonsten ist es einer von RANK_LEAGUE1, RANK_LEAGUE2, RANK_LEAGUE3
@ -41,6 +41,9 @@ class Match extends Model
if ($league->rank <= League::RANK_QUALIFICATION) {
$rounds = Round::where('id','>=',$league->start_round_id)->get();
error_log("Match::createMatchups. start_round_id = ".$league->start_round_id);
$roundNr=1;
$neededRoundCount = Match::getNumberOfNeededRounds($league->id);