Ranking: Changing degree of headings

This commit is contained in:
Torsten 2017-11-30 11:07:27 +01:00
parent faf00dc0cb
commit abf66ea3c9
5 changed files with 74 additions and 31 deletions

View file

@ -67,6 +67,7 @@ class LeaguesController extends Controller
public function createLeagues($start_round_id, $round_count) { public function createLeagues($start_round_id, $round_count) {
$users=User::getActives(); $users=User::getActives();
if (sizeof($users)==0){ if (sizeof($users)==0){
return view("leagues.no_users"); return view("leagues.no_users");

View file

@ -14,8 +14,9 @@ class Test extends Model
$users = User::all(); $users = User::all();
$cnt=0; $cnt=0;
foreach ($users as $user) { foreach ($users as $user) {
Payment::set_payment_date($user->id, $seasonId, '01.01.2017'); if (!$user->deleted)
$cnt+=1; { Payment::set_payment_date($user->id, $seasonId, '01.01.2017'); $cnt+=1;}
} }
return $cnt." Users in season_id ".$seasonId." set to paid"; return $cnt." Users in season_id ".$seasonId." set to paid";
} }

View file

@ -37,9 +37,12 @@ class User extends Authenticatable
// Only the current season. // Only the current season.
public static function is_season_paid($user_id) { public static function is_season_paid($user_id,$seasonId=-1) {
$season=Season::getCurrent();
if ($seasonId!=-1) { $season=Season::where('id','=',$seasonId)->first();}
$retval="Ja"; $retval="Ja";
if (User::payment_date($user_id, Season::getCurrent()->id)==null) { $retval="Nein"; } if (User::payment_date($user_id, $season->id)==null) { $retval="Nein"; }
return $retval; return $retval;
} }
@ -217,6 +220,13 @@ class User extends Authenticatable
} }
public static function isDeleted($user_id) {
$user=User::where('id','=',$user_id)->first();
if (!$user) return true;
if ($user->deleted) return true;
return false;
}
public static function softDelete($user_id) { public static function softDelete($user_id) {
$user = User::where('id','=',$user_id)->first(); $user = User::where('id','=',$user_id)->first();
if ($user) { $user->deleted = Carbon\Carbon::now();} if ($user) { $user->deleted = Carbon\Carbon::now();}
@ -228,7 +238,7 @@ class User extends Authenticatable
public static function getNames() { public static function getNames() {
$users=User::getActives(); $users=User::all();
$usernames = array(); $usernames = array();
foreach($users as $user) { foreach($users as $user) {
$usernames[$user->id] = $user->name; $usernames[$user->id] = $user->name;

View file

@ -179,8 +179,8 @@ class League extends Model
// Für Auf/Abstiegsberechnung - wird auf previous Season angewendet. // Für Auf/Abstiegsberechnung - wird auf previous Season angewendet.
// Unified bezieht sich (nur) auf Gruppen-Übergreifende Listung (also alle Untergruppen) // getUnifiedRanking bezieht sich (nur) auf Gruppen-Übergreifende Listung (also alle Untergruppen)
// Rank = -1 bedeutet über alle Rank (benötigt für Auf- und Abstieg über alle Ligen) // Rank = -1 bedeutet über alle Ranks (benötigt für Auf- und Abstieg über alle Ligen)
public static function getUnifiedRanking($rank, $seasonId=-1) { public static function getUnifiedRanking($rank, $seasonId=-1) {
$leagueScores = League::getRanking($rank, $seasonId); $leagueScores = League::getRanking($rank, $seasonId);
$unifiedScores = array(); $unifiedScores = array();
@ -214,9 +214,13 @@ class League extends Model
$tpl[5] = $rankEntry[4]; // league_pos (for multiple leagues per rank, usually ranks 3 and 4) $tpl[5] = $rankEntry[4]; // league_pos (for multiple leagues per rank, usually ranks 3 and 4)
if ($rank==4) { $hasRank4=true;} if ($rank==4) { $hasRank4=true;}
// only add to list if user has paid for season
if (User::is_season_paid($tpl[0])=="Ja") {
array_push($totalRanking, $tpl); array_push($totalRanking, $tpl);
} }
} }
}
usort($totalRanking, array('App\Leagues\League','cmpScore')); usort($totalRanking, array('App\Leagues\League','cmpScore'));
usort($totalRanking, array('App\Leagues\League','cmpScoreForPos')); // Dieser Sort funktioniert nur auf bereits sortierter Liste !! Nur für GruppenRank=3 usort($totalRanking, array('App\Leagues\League','cmpScoreForPos')); // Dieser Sort funktioniert nur auf bereits sortierter Liste !! Nur für GruppenRank=3
@ -296,9 +300,13 @@ class League extends Model
// TODO: 22 Mitspieler festgelegt sind. // TODO: 22 Mitspieler festgelegt sind.
public static function createLeagues($start_round_id, $round_count) { public static function createLeagues($start_round_id, $round_count) {
Log::info("Leagues\League::createLeagues, start_round_id=".$start_round_id.", round_count=".$round_count);
$currentSeason=Season::getCurrent(); $currentSeason=Season::getCurrent();
$previousSeason=Season::getPrevious(); $previousSeason=Season::getPrevious();
$userNames = User::getNames();
// Eventuell vorhandene Ligen loeschen // Eventuell vorhandene Ligen loeschen
$leagues=League::where('season_id','=',$currentSeason->id)->get(); $leagues=League::where('season_id','=',$currentSeason->id)->get();
if ($leagues) { if ($leagues) {
@ -362,6 +370,7 @@ class League extends Model
// - 2.) unified Liste bauen // - 2.) unified Liste bauen
// - 3.) Wenn Vorsaison keine Quali war, dann Auf & Abstieg umsetzen ( unfified Liste als Basis ) // - 3.) Wenn Vorsaison keine Quali war, dann Auf & Abstieg umsetzen ( unfified Liste als Basis )
// - 4.) Member den Ligen zuordnen // - 4.) Member den Ligen zuordnen
Log::info("League::createLeagues => Previous season detected. Creating Leagues 1, 2 and 3");
// Erzeugung der Ligen // Erzeugung der Ligen
$createdLeagues=array(); $createdLeagues=array();
@ -410,16 +419,37 @@ class League extends Model
} }
} }
Log::info("Creating unified List from previous season");
$unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !! $unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !!
Log:info("Unified List:");
$userNames = User::getNames();
$unifiedList2=array(); // We will only transfer users over to here that have paid the current season and are not deleted.
$count=0;
foreach($unifiedList as $listEntry) {
$userId = $listEntry[0];
if (User::is_season_paid($userId) && !User::isDeleted($userId)) {
$count+=1;
array_push($unifiedList2, $listEntry);
Log::info($count.".) [".$userId."] ".$userNames[$userId]);
} else {
Log::info($count.".) [".$userId."] ".$userNames[$userId]." [DELETED]");
}
}
$unifiedList = $unifiedList2;
// Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind. // Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind.
Log::info("Adding new users not within previous season");
foreach( League::getNewUsers() as $entry) { foreach( League::getNewUsers() as $entry) {
array_push($unifiedList, $entry); array_push($unifiedList, $entry);
$userId=$entry[0];
Log::info("( [".$userId."] ".$userNames[$userId]." )");
} }
$currentCount = 1; $currentCount = 1;
$nr=1; $nr=1;
@ -449,7 +479,8 @@ class League extends Model
$leagueIndex+=1; $leagueIndex+=1;
} }
Log::info("#".$leagueCount." Liga ".$leagueNr."-".$subLeague.")".$nr." ".$entry[0]); Log::info("#".$leagueCount." Liga ".$leagueNr."-".$subLeague.") ".$nr." ".$entry[0]." (".$userNames[$entry[0]].")");
$league=$createdLeagues[$leagueIndex]; $league=$createdLeagues[$leagueIndex];
$leagueMember = LeagueMember::create([ $leagueMember = LeagueMember::create([
'user_id' => $entry[0], 'user_id' => $entry[0],

View file

@ -44,110 +44,110 @@
<table> <table>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Rang</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Rang</span>
</div> </div>
</th> </th>
<!-- <!--
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">dayScoreWithRankScore</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">dayScoreWithRankScore</span>
</div> </div>
</th> </th>
--> -->
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Tagessieg</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Tagessieg</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:150px;">Spieler</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:150px;">Spieler</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Gesamt</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Gesamt</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Tag</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Tag</span>
</div> </div>
</th> </th>
<th>&nbsp;</th><!-- Spacer Column --> <th>&nbsp;</th><!-- Spacer Column -->
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[0]->team1}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[0]->team1}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[0]->team2}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[0]->team2}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[1]->team1}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[1]->team1}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[1]->team2}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[1]->team2}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[2]->team1}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[2]->team1}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[2]->team2}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[2]->team2}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[3]->team1}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[3]->team1}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[3]->team2}}</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">{{$games[3]->team2}}</span>
</div> </div>
</th> </th>
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span>
</div> </div>
</th> </th>
<th>&nbsp;</th><!-- Spacer Column --> <th>&nbsp;</th><!-- Spacer Column -->
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Aussch&uuml;ttung Tagessieg</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Aussch&uuml;ttung Tagessieg</span>
</div> </div>
</th> </th>
@if($isFinalRound) @if($isFinalRound)
<th style="height:140px;white-space: nowrap;"> <th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;"> <div style="transform:translate(10px, 51px) rotate(270deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Aussch.Platzierung</span> <span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Aussch.Platzierung</span>
</div> </div>
</th> </th>