Minor view and usability fixes, refactoring for Quota/Payout
This commit is contained in:
parent
76947b1df9
commit
b9e4fcca7f
12 changed files with 5736 additions and 139 deletions
|
|
@ -187,6 +187,7 @@ class UsersController extends Controller
|
|||
$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=".$currentSeason->id." and games.round_id=rounds.id;";
|
||||
dd($sql);
|
||||
$date = DB::select($sql);
|
||||
|
||||
if (count($date)>0) {
|
||||
|
|
@ -198,7 +199,13 @@ class UsersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $currentSeason->id)) {
|
||||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
// Hier werden _alle_ Tipps der aktuellen Saison ausgerechnet, die $round_id Begrenzung wird erst später ausgewertet.
|
||||
// TODO: Nur die Runden durchrechnen, die aktuell sind, oder round_incomplete, alle anderen Runden (bis zur ersten unvollständigen) sollen in eine Cachetabelle gespeichert werden.
|
||||
$sql = "select users.id as user_id, users.name as user_name, ";
|
||||
$sql = $sql . "rounds.id as round_id, rounds.name as round_name, ";
|
||||
$sql = $sql . "games.id as game_id, games.team1, games.team2, games.score1 as game_score1, games.score2 as game_score2, games.kickoff as game_kickoff, ";
|
||||
|
|
@ -208,6 +215,7 @@ class UsersController extends Controller
|
|||
$sql = $sql . "and games.round_id=rounds.id and tipps.game_id=games.id and users.id = tipps.user_id ";
|
||||
$sql = $sql . "and payments.season_id=".$currentSeason->id." and payments.user_id = users.id ";
|
||||
$sql = $sql . "and payments.paid_date is not null ";
|
||||
$sql = $sql . "and users.deleted is null ";
|
||||
$sql = $sql . "order by rounds.id, games.id, users.id;";
|
||||
|
||||
$result=DB::select($sql);
|
||||
|
|
@ -260,14 +268,6 @@ class UsersController extends Controller
|
|||
// NOW ALL KEYS FOR ROUNDTIPPS (ROUND & USER) EXIST
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// CALCULATION OF SCORES, RANKS, ETC.
|
||||
|
||||
// FIRST LOOP: COMPUTE AGGREGATED VALUES
|
||||
|
|
@ -333,14 +333,21 @@ class UsersController extends Controller
|
|||
// If more than 6 DayScoreWinners: Restrict by dayscore (rank)
|
||||
// Compute highest dayscore
|
||||
|
||||
// Addition: no dayscorewinner && round_completed: Payout goes to next round
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$totalDayWinPayout = 0;
|
||||
|
||||
foreach ($round_ids as $round_id) {
|
||||
$totalDayWinPayout += $payouts["tagessieg"];
|
||||
|
||||
$highestDayScore = $highestDayscores[$round_id];
|
||||
$usersWithHighestDayScore = array();
|
||||
|
||||
$round_completed=false;
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$round_completed = $roundtipps[$key]['round_completed']; // TODO: Separaten info array roundData erzeugen, der Rundenspezifische, SPielerübergreifende Infos enthält, so wie round_completed.
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]['dayscore'] == $highestDayScore && $roundtipps[$key]['round_completed']) {
|
||||
if ($roundtipps[$key]['dayscore'] == $highestDayScore && $roundtipps[$key]['round_completed'] && $highestDayScore>0 ) {
|
||||
array_push($usersWithHighestDayScore, [$user_id, $roundtipps[$key]['dayScoreWithRankScore']]);
|
||||
}
|
||||
}
|
||||
|
|
@ -365,31 +372,36 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
// Compute Dayscorewin payout (Tagessieg)
|
||||
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$single_payout = 0;
|
||||
$winnerCount = sizeof($dayScoreWinnersIds);
|
||||
$single_payout=0;
|
||||
if ($winnerCount > 0) {
|
||||
$single_payout = $payouts["Tagessieg"] / $winnerCount;
|
||||
$single_payout = $totalDayWinPayout / $winnerCount;
|
||||
$single_payout = number_format((float)$single_payout, 2, '.', '');
|
||||
$single_payout = str_replace(".", ",", $single_payout);
|
||||
$totalDayWinPayout=0;
|
||||
}
|
||||
|
||||
foreach ($round_ids as $round_id) {
|
||||
foreach ($user_ids as $user_id) {
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]['is_dayscorewinner']) {
|
||||
foreach ($user_ids as $user_id) {
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]['is_dayscorewinner']) {
|
||||
$roundtipps[$key]['payout'] = $single_payout;
|
||||
|
||||
|
||||
$roundtipps[$key]['payout'] = $single_payout;
|
||||
} else {
|
||||
$roundtipps[$key]['payout'] = '';
|
||||
}
|
||||
} else {
|
||||
$roundtipps[$key]['payout'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//////////////////// END OF ROUNDTIPPS CREATION ///////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////// DISPLAY AUFBAU /////////////////////////////
|
||||
|
||||
///
|
||||
|
|
@ -471,6 +483,7 @@ class UsersController extends Controller
|
|||
$roundtipps[$key]["tipps"][6],$roundtipps[$key]["tipps"][7],
|
||||
$roundtipps[$key]["joker"][3]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$userids = array_keys($rankingDisplay);
|
||||
|
|
@ -478,6 +491,7 @@ class UsersController extends Controller
|
|||
$games=Game::where('round_id','=',$max_round_id)->get();
|
||||
$all_rounds=Round::where('season_id','=',$currentSeason->id)->get();
|
||||
|
||||
|
||||
// Sortieren nach Rankscore
|
||||
$entries = array();
|
||||
usort($rankingDisplay, array($this,"cmp"));
|
||||
|
|
@ -491,6 +505,7 @@ class UsersController extends Controller
|
|||
// von Rankingdisplay abgespeichert sind.
|
||||
|
||||
$game_results=array(); // 4 Spielergebnisse der angezeigten Runde
|
||||
$a=$rankingDisplay[0];
|
||||
array_push($game_results,$rankingDisplay[0]["result_score1"],$rankingDisplay[0]["result_score2"],$rankingDisplay[0]["result_score3"],$rankingDisplay[0]["result_score4"],$rankingDisplay[0]["result_score5"],$rankingDisplay[0]["result_score6"],$rankingDisplay[0]["result_score7"],$rankingDisplay[0]["result_score8"]);
|
||||
|
||||
return view('users.ranking', compact('all_rounds','rankingDisplay','userids','round','games','game_results'));
|
||||
|
|
@ -515,12 +530,10 @@ class UsersController extends Controller
|
|||
$currentSeason = Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
$einsatz = Quota::getQuota($currentSeason->id,"Einsatz");
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
|
||||
Log::info("EINSATZ=".$einsatz);
|
||||
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','einsatz','currentSeason'));
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','quotas','currentSeason'));
|
||||
}
|
||||
|
||||
public function mailtest() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue