diff --git a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php index dfca9a87..faaa6ff5 100644 --- a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php +++ b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php @@ -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) { diff --git a/pfosten/app/Season.php b/pfosten/app/Season.php index 88ee8178..c8e2acf4 100644 --- a/pfosten/app/Season.php +++ b/pfosten/app/Season.php @@ -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; } + + } diff --git a/pfosten/app/Tipp.php b/pfosten/app/Tipp.php index c4a54417..589b03b1 100755 --- a/pfosten/app/Tipp.php +++ b/pfosten/app/Tipp.php @@ -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; diff --git a/pfosten/app/leagues/Match.php b/pfosten/app/leagues/Match.php index df260f4f..32fa973e 100644 --- a/pfosten/app/leagues/Match.php +++ b/pfosten/app/leagues/Match.php @@ -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); diff --git a/pfosten/resources/views/layouts/nav.blade.php b/pfosten/resources/views/layouts/nav.blade.php index d119893b..c5e58729 100644 --- a/pfosten/resources/views/layouts/nav.blade.php +++ b/pfosten/resources/views/layouts/nav.blade.php @@ -25,11 +25,9 @@ Spieler-Liga
diff --git a/pfosten/resources/views/leagues/chart.blade.php b/pfosten/resources/views/leagues/chart.blade.php index 8f2a67df..a02e6c03 100755 --- a/pfosten/resources/views/leagues/chart.blade.php +++ b/pfosten/resources/views/leagues/chart.blade.php @@ -21,34 +21,36 @@ - @foreach($leagueScores as $leagueId => $playerTuples) -| Pos | -Spieler | -Punkte | -Tordifferenz | -Torverhältnis | -Quali-Rang | -
| {{$pos+1}} | -{{$userNames[$player[0]]}} | -{{$player[1]}} | -{{$player[2]-$player[3]}} | -{{$player[2]}}:{{$player[3]}} | -{{$rankInfo[$player[0]]}} | +Pos | +Spieler | +Punkte | +Tordifferenz | +Torverhältnis | +
+ + @foreach($playerTuples as $pos => $player) +
+ + @endforeach @endforeach diff --git a/pfosten/resources/views/leagues/no_users.blade.php b/pfosten/resources/views/leagues/no_users.blade.php new file mode 100644 index 00000000..73d7a512 --- /dev/null +++ b/pfosten/resources/views/leagues/no_users.blade.php @@ -0,0 +1,20 @@ +@extends('layouts.layout') + +@section('content') +