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();