Quota Fixes

This commit is contained in:
Torsten 2018-01-10 08:45:01 +01:00
parent a9efcc8e15
commit 8595808fd2
5 changed files with 112 additions and 73 deletions

View file

@ -26,7 +26,7 @@ class SeasonsController extends Controller
$currentSeasonId=-1;
if ($currentSeason) {
$quotas = Quota::getQuotas();
$quotas = Quota::getQuotasForDisplay();
$payouts = Quota::getPayouts();
}
@ -135,7 +135,6 @@ class SeasonsController extends Controller
'tagessieg' => 'required',
'pokal' => 'required',
'gruenes_trikot' => 'required',
'cleague' => 'required',
'platzierung' => 'required',
'liga' => 'required',
'liga_platz1' => 'required',
@ -156,29 +155,33 @@ class SeasonsController extends Controller
// Create and save the season
Quota::setQuota('Runden', request('round_count'));
Quota::setQuota('Einsatz', request('einsatz'));
Quota::setQuota('Tagessieg', request('tagessieg'));
Quota::setQuota('Gruenes Trikot', request('gruenes_trikot'));
Quota::setQuota('Pokal', request('pokal'));
Quota::setQuota('Champions-League', request('cleague'));
Quota::setQuota('Platzierung', request('platzierung'));
Quota::setQuota('Platz 1', request('platz1'));
Quota::setQuota('Platz 2', request('platz2'));
Quota::setQuota('Platz 3', request('platz3'));
Quota::setQuota('Platz 4', request('platz4'));
Quota::setQuota('Platz 5', request('platz5'));
Quota::setQuota('Platz 6', request('platz6'));
Quota::setQuota('Platz 7', request('platz7'));
Quota::setQuota('Platz 8', request('platz8'));
Quota::setQuota('Platz 9', request('platz9'));
Quota::setQuota('Platz 10', request('platz10'));
Quota::setQuota('Liga-Wertung', request('liga'));
Quota::setQuota('Liga Platz 1', request('liga_platz1'));
Quota::setQuota('Liga Platz 2', request('liga_platz2'));
Quota::setQuota('Liga Platz 3', request('liga_platz3'));
Quota::setQuota('Liga Platz 2_1', request('liga_platz2_1'));
Quota::setQuota('Liga Platz 3_1', request('liga_platz3_1'));
Quota::setQuota('Tagessieg', str_replace(",",".",request('tagessieg')));
Quota::setQuota('Gruenes Trikot', str_replace(",",".",request('gruenes_trikot')));
Quota::setQuota('Pokal', str_replace(",",".",request('pokal')));
Quota::setQuota('Platzierung', str_replace(",",".",request('platzierung')));
Quota::setQuota('Platz 1', str_replace(",",".",request('platz1')));
Quota::setQuota('Platz 2', str_replace(",",".",request('platz2')));
Quota::setQuota('Platz 3', str_replace(",",".",request('platz3')));
Quota::setQuota('Platz 4', str_replace(",",".",request('platz4')));
Quota::setQuota('Platz 5', str_replace(",",".",request('platz5')));
Quota::setQuota('Platz 6', str_replace(",",".",request('platz6')));
Quota::setQuota('Platz 7', str_replace(",",".",request('platz7')));
Quota::setQuota('Platz 8', str_replace(",",".",request('platz8')));
Quota::setQuota('Platz 9', str_replace(",",".",request('platz9')));
Quota::setQuota('Platz 10', str_replace(",",".",request('platz10')));
Quota::setQuota('Liga-Wertung', str_replace(",",".",request('liga')));
Quota::setQuota('Liga Platz 1', str_replace(",",".",request('liga_platz1')));
Quota::setQuota('Liga Platz 2', str_replace(",",".",request('liga_platz2')));
Quota::setQuota('Liga Platz 3', str_replace(",",".",request('liga_platz3')));
Quota::setQuota('Liga Platz 2_1', str_replace(",",".",request('liga_platz2_1')));
Quota::setQuota('Liga Platz 3_1', str_replace(",",".",request('liga_platz3_1')));
// Redirect to the home page
return redirect('/seasons');

View file

@ -203,6 +203,8 @@ class UsersController extends Controller
$startTime = microtime(true);
$season = Season::getCurrent();
if ( $seasonId !=-1 ) {
$season=Season::where('id','=',$seasonId)->first();
@ -211,12 +213,12 @@ class UsersController extends Controller
$seasonId = $season->id;
}
// Check ob mindestens eine Runde der Saison gelockt ist angezeigt werden kann
// Check ob mindestens eine Runde der Saison gelockt ist, die angezeigt werden kann
if($max_round_id==-1) {
$max_round_id = Round::getLastLockedRoundId();
if ($max_round_id==-1) {
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id order by rounds.id;";
//dd($sql);
$entries = DB::select($sql);
if (count($entries)>0) {
@ -497,13 +499,20 @@ class UsersController extends Controller
if (!$currentSeason) {
return view('users.no_ranking', compact('start_date'));
}
// Payment made ?
if (! User::payment_date(Auth::user()->id, $currentSeason->id) && Auth::user()->name!="Torsten Schneider") {
return view('users.no_payment');
}
if (Round::getLastLockedRoundId()==-1) {
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$currentSeason->id." and games.round_id=rounds.id order by rounds.id;";
// Check ob mindestens eine Runde der Saison gelockt ist angezeigt werden kann
$seasonId=$currentSeason->id;
$max_round_id = Round::getLastCompleteRoundId();
if ($max_round_id==-1) {
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id order by rounds.id;";
//dd($sql);
$entries = DB::select($sql);
if (count($entries)>0) {
@ -515,6 +524,8 @@ class UsersController extends Controller
}
$sortedPayout = Quota::getPayoutPerUser();
@ -616,8 +627,32 @@ class UsersController extends Controller
public function gshirt_ranking() {
if (Auth::guest()) { return redirect("/"); }
public function gshirt_ranking() {
if (Auth::guest()) { return redirect("/"); }
// Check ob mindestens eine Runde der Saison gelockt ist und angezeigt werden kann
$season=Season::getCurrent();
$seasonId=$season->id;
$max_round_id = Round::getLastCompleteRoundId();
if ($max_round_id==-1) {
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id order by rounds.id;";
//dd($sql);
$entries = DB::select($sql);
if (count($entries)>0) {
$start_date = $entries[0]->start_date;
return view('users.no_ranking', compact('start_date'));
} else {
return redirect("/");
}
}
$rankingDisplay = Tipp::gshirt_table();
$usernames = User::getNames();

View file

@ -31,7 +31,7 @@ class Quota extends Model
$euro_gruenes_trikot = intval($euro_pott * (($quotas["Gruenes Trikot"] / 100)));
$euro_gruenes_trikot = Quota::get6Divisor($euro_gruenes_trikot);
$euro_pokal= intval ($euro_pott * (($quotas["Pokal"] / 100)));
$euro_cleague = intval ($euro_pott * (($quotas["Champions-League"] / 100)));
$euro_pokal= Quota::get6Divisor($euro_pokal);
$euro_platzierung = intval ( $euro_pott * (($quotas["Platzierung"] / 100)));
@ -90,13 +90,13 @@ class Quota extends Model
$payouts['liga_platz1'] = $euro_liga_platz1;
$payouts['liga_platz2'] = $euro_liga_platz2;
$payouts['liga_platz3'] = $euro_liga_platz3;
$payouts['liga_platz2_1'] = $euro_liga_platz3;
$payouts['liga_platz3_1'] = $euro_liga_platz3;
$payouts['liga_platz2_1'] = $euro_liga_platz2_1;
$payouts['liga_platz3_1'] = $euro_liga_platz3_1;
$payouts['gruenes_trikot'] = $euro_gruenes_trikot;
$payouts['Champions-League'] = $euro_cleague;
$payouts['pokal'] = $euro_pokal;
return $payouts;
}
@ -131,6 +131,13 @@ class Quota extends Model
return $arr;
}
public static function getQuotasForDisplay() {
$quotas=Quota::getQuotas();
foreach($quotas as $key => $val) {
$quotas[$key]=str_replace(".",",", $val);
}
return $quotas;
}
public static function setQuotas($quotas) {
$season_id = Season::getCurrent()->id;
@ -187,12 +194,6 @@ class Quota extends Model
$quota->prc = 15;
$quota->save();
$quota = new Quota;
$quota->season_id = $season_id;
$quota->name = "Champions-League";
$quota->prc = 10;
$quota->save();
/// #######################################
// Sub-Quotas für den Spielmodus 'Tagessieg'

View file

@ -28,7 +28,7 @@
<div class="form-group" >
<h4>
<label style="float:left; width:200px;">Anzahl Runden:</label>
<input type="text" class="form-control" id="round_count" name="round_count" value="{{ App\Round::getCount() }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="round_count" name="round_count" value="{{ App\Round::getCount() }}" style="float:left; width:75px;"required>
</h4>
</div>
@ -38,45 +38,38 @@
<div class="form-group" >
<h4>
<label style="float:left; width:200px;">Einsatz pro Spieler:</label>
<input type="text" class="form-control" id="einsatz" name="einsatz" value="{{ $quotas['Einsatz'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="einsatz" name="einsatz" value="{{ $quotas['Einsatz'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;€</label>
</h4>
</div>
<p>&nbsp;</p><p>&nbsp;</p>
<h3>Spielquoten</h3>
<div class="form-group" >
<div class="form-group" style="width:450px;">
<h4>
<label style="float:left; width:200px;">Tagessieg:</label>
<input type="text" class="form-control" id="tagessieg" name="tagessieg" value="{{ $quotas['Tagessieg'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="tagessieg" name="tagessieg" value="{{ $quotas['Tagessieg'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['tagessieg']}} € </label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platzierung:</label>
<input type="text" class="form-control" id="platzierung" name="platzierung" value="{{ $quotas['Platzierung'] }}" style="float:left; width:50px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['liga_platz1']+$payouts['liga_platz2']+$payouts['liga_platz3']+$payouts['liga_platz2_1']+$payouts['liga_platz3_1'] }} € </label>
<input type="text" class="form-control" id="platzierung" name="platzierung" value="{{ $quotas['Platzierung'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz1']+$payouts['platz2']+$payouts['platz3']+$payouts['platz4']+$payouts['platz5']+$payouts['platz6']+$payouts['platz7']+$payouts['platz8']+$payouts['platz9']+$payouts['platz10'] }} € </label>
<label style="float:left; width:200px;">Grünes Trikot:</label>
<input type="text" class="form-control" id="gruenes_trikot" name="gruenes_trikot" value="{{ $quotas['Gruenes Trikot'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="gruenes_trikot" name="gruenes_trikot" value="{{ $quotas['Gruenes Trikot'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['gruenes_trikot']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Pokal:</label>
<input type="text" class="form-control" id="pokal" name="pokal" value="{{ $quotas['Pokal'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="pokal" name="pokal" value="{{ $quotas['Pokal'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['pokal'] }} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Champions League:</label>
<input type="text" class="form-control" id="cleague" name="cleague" value="{{ $quotas['Champions-League'] }}" style="float:left; width:50px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['Champions-League'] }} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga:</label>
<input type="text" class="form-control" id="liga" name="liga" value="{{ $quotas['Liga-Wertung'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga" name="liga" value="{{ $quotas['Liga-Wertung'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['liga_platz1']+$payouts['liga_platz2']+$payouts['liga_platz3']+$payouts['liga_platz2_1']+$payouts['liga_platz3_1'] }} €</label>
<p>&nbsp;</p>
@ -91,53 +84,53 @@
<div class="form-group" >
<h4>
<label style="float:left; width:200px;">Platz 1:</label>
<input type="text" class="form-control" id="platz1" name="platz1" value="{{ $quotas["Platz 1"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz1" name="platz1" value="{{ $quotas["Platz 1"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz1']}} €</label>
<!-- <label>Test</label>-->
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 2:</label>
<input type="text" class="form-control" id="platz2" name="platz2" value="{{ $quotas["Platz 2"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz2" name="platz2" value="{{ $quotas["Platz 2"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz2']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 3:</label>
<input type="text" class="form-control" id="platz3" name="platz3" value="{{ $quotas["Platz 3"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz3" name="platz3" value="{{ $quotas["Platz 3"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz3']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 4:</label>
<input type="text" class="form-control" id="platz4" name="platz4" value="{{ $quotas["Platz 4"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz4" name="platz4" value="{{ $quotas["Platz 4"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz4']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 5:</label>
<input type="text" class="form-control" id="platz5" name="platz5" value="{{ $quotas["Platz 5"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz5" name="platz5" value="{{ $quotas["Platz 5"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz5']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 6:</label>
<input type="text" class="form-control" id="platz6" name="platz6" value="{{ $quotas["Platz 6"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz6" name="platz6" value="{{ $quotas["Platz 6"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz6']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 7:</label>
<input type="text" class="form-control" id="platz7" name="platz7" value="{{ $quotas["Platz 7"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz7" name="platz7" value="{{ $quotas["Platz 7"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz7']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 8:</label>
<input type="text" class="form-control" id="platz8" name="platz8" value="{{ $quotas["Platz 8"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz8" name="platz8" value="{{ $quotas["Platz 8"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz8']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 9:</label>
<input type="text" class="form-control" id="platz9" name="platz9" value="{{ $quotas["Platz 9"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz9" name="platz9" value="{{ $quotas["Platz 9"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz9']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 10:</label>
<input type="text" class="form-control" id="platz10" name="platz10" value="{{ $quotas["Platz 10"] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="platz10" name="platz10" value="{{ $quotas["Platz 10"] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['platz10']}} €</label>
<p>&nbsp;</p>
@ -152,27 +145,27 @@
<div class="form-group" >
<h4>
<label style="float:left; width:200px;">Liga 1, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz1" name="liga_platz1" value="{{ $quotas['Liga Platz 1'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga_platz1" name="liga_platz1" value="{{ $quotas['Liga Platz 1'] }}" style="float:left; width:75px;"required>
<label style="float:left">&nbsp;% = {{$payouts['liga_platz1']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 1, Platz 2:</label>
<input type="text" class="form-control" id="liga_platz2" name="liga_platz2" value="{{ $quotas['Liga Platz 2'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga_platz2" name="liga_platz2" value="{{ $quotas['Liga Platz 2'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{$payouts['liga_platz2']}} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 1, Platz 3:</label>
<input type="text" class="form-control" id="liga_platz3" name="liga_platz3" value="{{ $quotas['Liga Platz 3'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga_platz3" name="liga_platz3" value="{{ $quotas['Liga Platz 3'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['liga_platz3'] }} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 2, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz2_1" name="liga_platz2_1" value="{{ $quotas['Liga Platz 2_1'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga_platz2_1" name="liga_platz2_1" value="{{ $quotas['Liga Platz 2_1'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['liga_platz2_1'] }} €</label>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 3, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz3_1" name="liga_platz3_1" value="{{ $quotas['Liga Platz 3_1'] }}" style="float:left; width:50px;"required>
<input type="text" class="form-control" id="liga_platz3_1" name="liga_platz3_1" value="{{ $quotas['Liga Platz 3_1'] }}" style="float:left; width:75px;"required>
<label style="float:left;">&nbsp;% = {{ $payouts['liga_platz3_1'] }} €</label>
<p>&nbsp;</p>
</h4>

View file

@ -118,21 +118,28 @@
<h3>Liga:</h3>
<div class="form-group" >
<h4>
<label style="float:left; width:200px;">Platz 1:</label>
<label style="float:left; width:200px;">Liga 1 Playoff, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz1" name="liga_platz1" value="{{ $payouts['liga_platz1'] }} €" style="float:left; width:100px;" readonly>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 2:</label>
<label style="float:left; width:200px;">Liga 1 Playoff, Platz 2:</label>
<input type="text" class="form-control" id="liga_platz2" name="liga_platz2" value="{{ $payouts['liga_platz2'] }} €" style="float:left; width:100px;" readonly>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Platz 3:</label>
<label style="float:left; width:200px;">Liga 1 Playoff, Platz 3:</label>
<input type="text" class="form-control" id="liga_platz3" name="liga_platz3" value="{{ $payouts['liga_platz3'] }} €" style="float:left; width:100px;" readonly>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 2 Playoff, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz3" name="liga_platz2_1" value="{{ $payouts['liga_platz2_1'] }} €" style="float:left; width:100px;" readonly>
<p>&nbsp;</p>
<label style="float:left; width:200px;">Liga 3 Playoff, Platz 1:</label>
<input type="text" class="form-control" id="liga_platz3" name="liga_platz3_1" value="{{ $payouts['liga_platz3_1'] }} €" style="float:left; width:100px;" readonly>
<p>&nbsp;</p>
</h4>
</div>
<p>&nbsp;</p><p>&nbsp;</p>