Working on LeagueMemberSwap Form
This commit is contained in:
parent
2f26ee76d4
commit
3ec04c090d
4 changed files with 613 additions and 0 deletions
|
|
@ -125,6 +125,8 @@ class LeaguesController extends Controller
|
|||
return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function showLeagueRanking() {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueRanking()");
|
||||
|
|
@ -166,6 +168,49 @@ class LeaguesController extends Controller
|
|||
return view ('leagues.chart',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
|
||||
}
|
||||
|
||||
// Originall copied over from showLeagueRanking
|
||||
public static function showLeagueSwapForm() {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueSwapForm()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$season = Season::getCurrent();
|
||||
//$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)) {
|
||||
Log::info($a->getEndMessage());
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
$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];
|
||||
}
|
||||
|
||||
$cols=array();
|
||||
$cols[1]="greenyellow";
|
||||
$cols[2]="orange";
|
||||
$cols[3]="lightgrey";
|
||||
$cols[4]="";
|
||||
|
||||
$leagueScores=array();
|
||||
foreach([1,2,3,4] as $rank) {
|
||||
$leagueScores[$rank] = League::getRanking($rank);
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view ('leagues.chart_swapform',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
|
||||
}
|
||||
|
||||
|
||||
public static function showSingleUserMatches($userId) {
|
||||
$season = Season::getCurrent();
|
||||
$leagueNames = League::getNames();
|
||||
|
|
|
|||
97
pfosten/resources/views/leagues/chart_swapform.blade.php
Normal file
97
pfosten/resources/views/leagues/chart_swapform.blade.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="text-center">
|
||||
<div id="leagueContainer" class="container">
|
||||
|
||||
<h2>{{ $season->name }}</h2>
|
||||
<h2>Spielerliga Platztausch</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[1]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[2]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[3]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 3</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@foreach($leagueScores as $rank => $_leagueScores)
|
||||
@foreach($_leagueScores as $leagueId => $playerTuples)
|
||||
<h2>{{ $leagueNames[$leagueId] }}</h2>
|
||||
|
||||
<table class="table-bordered col-lg-12">
|
||||
<tr class="table-bordered">
|
||||
|
||||
<td>Tausch</td>
|
||||
<td class="table-bordered" style="width:50px;">Pos</td>
|
||||
<td class="table-bordered" style="width:150px;">Spieler</td>
|
||||
<td class="table-bordered" style="width:50px;">Punkte</td>
|
||||
<td class="table-bordered" style="width:150px;">Tordifferenz</td>
|
||||
<td class="table-bordered" style="width:150px;">Torverhältnis</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<!-- Start Matchgruppen-Loop-->
|
||||
@foreach($playerTuples as $pos => $player)
|
||||
<tr class="table-bordered">
|
||||
<td><input id="{{$player[0]}}__{{$userNames[$player[0]]}}__{{$leagueNames[$leagueId]}}" type="checkbox"></td>
|
||||
<td style="width:50px;background-color:{{ $cols[$rankInfo[$player[0]]] }}"> {{$pos+1}} </td>
|
||||
<td> <a name="playerid_{{$player[0]}}" class="{{ $player[0]==Auth::user()->id ? 'blink_text' : '' }}" href="/league/showSingleUserMatches/user_id={{$player[0]}}"> {{$userNames[$player[0]]}} </a> </td>
|
||||
<td> {{$player[1]}} </td>
|
||||
<td> {{$player[2]-$player[3]}} </td>
|
||||
<td> {{$player[2]}}:{{$player[3]}} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</table>
|
||||
<p> </p>
|
||||
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const checkbox = document.getElementById('leagueContainer')
|
||||
|
||||
checkbox.addEventListener('change', (event) => {
|
||||
let delta =0
|
||||
if (event.currentTarget.checked) {
|
||||
// Is going to be unchecked
|
||||
delta=-1
|
||||
} else {
|
||||
// Is going to be checked
|
||||
delta=+1
|
||||
}
|
||||
|
||||
// count checked boxes
|
||||
let inputElems = document.getElementsByTagName("input"), count = 0;
|
||||
for (let i=0; i<inputElems.length; i++) {
|
||||
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count==2) {
|
||||
let selected_players=[];
|
||||
|
||||
for (let i=0; i<inputElems.length; i++) {
|
||||
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
|
||||
selected_players.push(inputElems[i].id)
|
||||
inputElems[i].checked=false;
|
||||
}
|
||||
}
|
||||
alert("Tauschen:\n"+selected_players.join("\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
@ -91,5 +91,7 @@ Route::get('/league_settings/season={season_id}','Leagues\LeaguesController@inde
|
|||
Route::get('/league_settings/create_league/start_round_id={start_round_id}/round_count={round_count}','Leagues\LeaguesController@createLeagues');
|
||||
Route::get('/league_show_rounds','Leagues\LeaguesController@showLeagueRounds');
|
||||
Route::get('/league/show','Leagues\LeaguesController@showLeagueRanking');
|
||||
Route::get('/league/swapform','Leagues\LeaguesController@showLeagueSwapForm');
|
||||
Route::post('/league/swap','Leagues\LeaguesController@swapLeagueMembers');
|
||||
|
||||
Route::get('/league/showSingleUserMatches/user_id={userId}','Leagues\LeaguesController@showSingleUserMatches');
|
||||
Loading…
Add table
Add a link
Reference in a new issue