Fixed new player bug
This commit is contained in:
parent
622ecaf97c
commit
25cd90a1fb
5 changed files with 93 additions and 17 deletions
|
|
@ -114,7 +114,7 @@ class LeaguesController extends Controller
|
|||
//$leagues = array_reverse(League::getRanking($rank));
|
||||
$leagueNames = League::getNames();
|
||||
$userNames = User::getNames();
|
||||
|
||||
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<=', 4)->orderBy('id')->get();
|
||||
if (!sizeof($leagues)) return redirect("/");
|
||||
|
||||
|
|
|
|||
|
|
@ -144,10 +144,12 @@ class User extends Authenticatable
|
|||
|
||||
foreach ($games as $game) {
|
||||
|
||||
|
||||
$tipp = Tipp::where([['game_id','=',$game->id],['user_id','=',$user_id]])->first();
|
||||
|
||||
//if(!$tipp) { Log::info("Tipp doesnt exist: game_id=".$game->id.", user_id=".$user_id); }
|
||||
if(!$tipp) {
|
||||
Log::info("Tipp doesnt exist: game_id=".$game->id.", user_id=".$user_id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
|
||||
//Log::info("!!! User ".$user_id." has a missing tipp for game_id ".$game->id.", round = ".$round_id);
|
||||
|
|
@ -169,7 +171,8 @@ class User extends Authenticatable
|
|||
$tipp = Tipp::where([['game_id','=',$game->id],['user_id','=',$user_id]])->first();
|
||||
|
||||
if(!$tipp) {
|
||||
//Log::info("tipp is null! OMG! // Infos: user_id=".$user_id.", game_id=".$game->id.", round_id=".$round_id);
|
||||
Log::info("tipp is null! OMG! // Infos: user_id=".$user_id.", game_id=".$game->id.", round_id=".$round_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($tipp->joker == true) { $joker=1; }
|
||||
|
|
@ -186,12 +189,14 @@ class User extends Authenticatable
|
|||
|
||||
// aktiv = hat die Saison bezahlt.
|
||||
public static function getActives($seasonId=-1) {
|
||||
$currentSeason=Season::getCurrent();
|
||||
if ($seasonId != -1) { $currentSeason = Season::where('id','=',$seasonId); }
|
||||
if (!$currentSeason) return array();
|
||||
$season=Season::getCurrent();
|
||||
if (!$season) return array();
|
||||
|
||||
if ($seasonId != -1) { $season = Season::where('id','=',$seasonId)->first(); }
|
||||
$seasonId = $season->id;
|
||||
|
||||
$users = User::all();
|
||||
$payments = Payment::where('season_id','=',$currentSeason->id)->get();
|
||||
$payments = Payment::where('season_id','=',$seasonId)->get();
|
||||
|
||||
$payref = array();
|
||||
foreach($payments as $payment) {
|
||||
|
|
@ -216,6 +221,9 @@ class User extends Authenticatable
|
|||
$user = User::where('id','=',$user_id)->first();
|
||||
if ($user) { $user->deleted = Carbon\Carbon::now();}
|
||||
$user->save();
|
||||
|
||||
$season = Season::getCurrent();
|
||||
Payment::set_payment_date($user_id,$season->id,null);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -268,6 +268,28 @@ class League extends Model
|
|||
}
|
||||
|
||||
|
||||
public static function getNewUsers($seasonId=-1) {
|
||||
$users=User::getActives($seasonId);
|
||||
$previousSeason=Season::getPrevious($seasonId);
|
||||
$old_users=User::getActives($previousSeason->id);
|
||||
|
||||
$new_users=array();
|
||||
foreach($users as $user) {
|
||||
$exists=0;
|
||||
foreach($old_users as $old_user) {
|
||||
if ($old_user->id == $user->id) { $exists=1;}
|
||||
}
|
||||
if (!$exists) {
|
||||
if (User::payment_date($user->id, $seasonId)) {
|
||||
$entry = [$user->id];
|
||||
array_push($new_users, $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $new_users;
|
||||
}
|
||||
|
||||
// ausfaktoriert aus LeaguesController::createLeagues()
|
||||
// TODO: $round_count ist nur im Quali-Modus relevant und steuert, wieviele Quali-Gruppen benötigt werden.
|
||||
// TODO: Sobald es Liga1 und Liga2 gibt, wird der round_count immer 21 sein, da Liga1 und Liga2 auf
|
||||
|
|
@ -329,6 +351,7 @@ class League extends Model
|
|||
'league_id' => $league_ids[$league_index]
|
||||
]);
|
||||
$leagueMember->save();
|
||||
error_log("Saving user_id ".$user->id);
|
||||
$league_index+=1;
|
||||
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
||||
}
|
||||
|
|
@ -388,6 +411,15 @@ class League extends Model
|
|||
}
|
||||
|
||||
$unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !!
|
||||
|
||||
// Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind.
|
||||
|
||||
foreach( League::getNewUsers() as $entry) {
|
||||
array_push($unifiedList, $entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$currentCount = 1;
|
||||
|
||||
$nr=1;
|
||||
|
|
@ -404,6 +436,11 @@ class League extends Model
|
|||
if ($nr==45) {
|
||||
$leagueNr=3; $leagueCount=1; $leagueIndex=2;
|
||||
$neededSize3=intdiv(($active_member_count-44),$neededLeagues); // $neededLeagues = needed Groups for rank 3 leagues
|
||||
|
||||
if ( ($active_member_count-44) % 2) {
|
||||
$neededSize3+=1;
|
||||
}
|
||||
|
||||
Log::info("Needed min/switch size for rank 3 leagues: ".$neededSize3);
|
||||
}
|
||||
if ($nr>45 && $leagueCount > $neededSize3) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,17 @@ class Match extends Model
|
|||
Log::info("Match::createMatchups( league_id=".$league->id.", numberOfrounds=".sizeof($rounds));
|
||||
$allPairings=Match::getAllPairings($league->id);
|
||||
|
||||
Log::info("Rounds:");
|
||||
$counter=1;
|
||||
foreach($rounds as $round) {
|
||||
Log::info($counter);
|
||||
Log::info($round."\n");
|
||||
$counter+=1;
|
||||
}
|
||||
|
||||
Log::info("League-id=".$league->id.", Size of allPairings:".sizeof($allPairings));
|
||||
foreach ($rounds as $round) {
|
||||
Log::info("Fetching roundNr/index=".$roundNr);
|
||||
$pairings = $allPairings[$roundNr];
|
||||
// Save pairings
|
||||
foreach($pairings as $pair) {
|
||||
|
|
@ -126,7 +136,7 @@ class Match extends Model
|
|||
public static function getAllPairings($leagueId) {
|
||||
$members = LeagueMember::getMembers($leagueId);
|
||||
|
||||
$roundCount=sizeof($members)-1;
|
||||
$roundCount=Match::getNumberOfNeededRounds($leagueId);
|
||||
|
||||
if (sizeof($members) % 2 == 1) { // ungerade memberzahl => freilos einfügen
|
||||
error_log("Adding -1 free entry");
|
||||
|
|
@ -148,8 +158,8 @@ class Match extends Model
|
|||
array_push($roundRobin, $userId);
|
||||
}
|
||||
|
||||
error_log("RoundNr ".$currentRoundNr." Array start:");
|
||||
error_log(implode(",",$roundRobin));
|
||||
//error_log("RoundNr ".$currentRoundNr." Array start:");
|
||||
//error_log(implode(",",$roundRobin));
|
||||
|
||||
$_roundNr = $currentRoundNr;
|
||||
while ($_roundNr >= 1) {
|
||||
|
|
@ -197,12 +207,12 @@ class Match extends Model
|
|||
|
||||
}
|
||||
|
||||
//foreach ($all as $roundNr => $pairings) {
|
||||
// foreach ($pairings as $slotIdx => $pairing) {
|
||||
// error_log($pairing[0]." vs ".$pairing[1]);
|
||||
// }
|
||||
// error_log("");
|
||||
//}
|
||||
foreach ($all as $roundNr => $pairings) {
|
||||
foreach ($pairings as $slotIdx => $pairing) {
|
||||
error_log($pairing[0]." vs ".$pairing[1]);
|
||||
}
|
||||
error_log("");
|
||||
}
|
||||
|
||||
return $all; // $all[$roundnr]= Array of Tuples ( UserId1, UserId2 )
|
||||
//return null;
|
||||
|
|
|
|||
21
pfosten/resources/views/users/confirm_delete.php
Normal file
21
pfosten/resources/views/users/confirm_delete.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="jumbotron text-center">
|
||||
<div class="container">
|
||||
<h1 class="jumbotron-heading"></h1>
|
||||
<p class="lead text-muted" style="color:red;">Dein Zahlungseingang für die Saison wurde noch nicht registriert.</p>
|
||||
<div><p></p><p></p><p></p></div>
|
||||
|
||||
<div>
|
||||
<a href="/" class="btn btn-primary">Ok</a>
|
||||
</div>
|
||||
<div><p></p><p></p><p></p></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
Loading…
Add table
Add a link
Reference in a new issue