Fixed new seasons' display bug specific to server
This commit is contained in:
parent
1716443bf9
commit
ccc955ef0e
4 changed files with 1277 additions and 3 deletions
|
|
@ -312,9 +312,9 @@ class UsersController extends Controller
|
|||
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;";
|
||||
$sql="SELECT DATE_FORMAT(date_sub(games.kickoff, INTERVAL 1 MINUTE),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=11 and games.round_id=rounds.id order by games.id limit 1;";
|
||||
//dd($sql);
|
||||
$entries = DB::select($sql);
|
||||
$entries = DB::select(DB::raw($sql));
|
||||
|
||||
if (count($entries)>0) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
|
|
|
|||
801
pfosten/app/Http/Controllers/UsersControllerWeb.php
Normal file
801
pfosten/app/Http/Controllers/UsersControllerWeb.php
Normal file
|
|
@ -0,0 +1,801 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\User;
|
||||
use App\Season;
|
||||
use App\Payment;
|
||||
use App\Round;
|
||||
use App\Game;
|
||||
use App\Tipp;
|
||||
use App\Quota;
|
||||
use App\Mail\RoundmailMailer;
|
||||
|
||||
use Password;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Auth\Passwords\PasswordBroker;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
|
||||
use Carbon;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
public function main() {
|
||||
//$a=new TimeLogger("UsersController::main()");
|
||||
//Log::info($a->getStartMessage());
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
$roundname="";
|
||||
$report="";
|
||||
|
||||
// display_rounds berechnen für Nav und Rundenberichte
|
||||
$display_rounds=array();
|
||||
if ($currentSeason) {
|
||||
$round_id = Round::getLastCompleteRoundId();
|
||||
|
||||
if ($round_id > -1) {
|
||||
$rounds = Round::where("id", "<=", $round_id)->where('season_id','=',$currentSeason->id)->get();
|
||||
foreach($rounds as $round) {
|
||||
$dpr =array();
|
||||
$dpr["name"]=$round->name;
|
||||
$dpr["report"]=$round->report;
|
||||
array_push($display_rounds, $dpr);
|
||||
}
|
||||
$display_rounds = array_reverse($display_rounds);
|
||||
Log::info("Loaded report:".$report." round-id=".$round_id);
|
||||
$roundname = $round->name;
|
||||
} else { Log::info("No round identified. Last Locked=".$round_id); $report="";}
|
||||
} else {Log::info("No current season");}
|
||||
|
||||
$nextRoundName="";
|
||||
$nextRound = Round::getFirstTippableRound();
|
||||
|
||||
$nextRoundName = "";
|
||||
$nextRoundLockTime = "";
|
||||
$diffToLock ="";
|
||||
$hourDiffToLock = 999;
|
||||
if ($nextRound) {
|
||||
$nextRoundName = $nextRound->name;
|
||||
$nextRoundLockTime = $nextRound->getLockTime();
|
||||
$hourDiffToLock=$nextRoundLockTime->diffInHours(Carbon\Carbon::now());
|
||||
if ($hourDiffToLock==0) {
|
||||
$diffMin=$nextRoundLockTime->diffInMinutes(Carbon\Carbon::now());
|
||||
if ($diffMin==0) { $diffMin=1;}
|
||||
if ($diffMin==1) {
|
||||
$hourDiffToLock = $nextRoundLockTime->diffInMinutes(Carbon\Carbon::now())." Minute";
|
||||
} else {
|
||||
$hourDiffToLock = $nextRoundLockTime->diffInMinutes(Carbon\Carbon::now())." Minuten";
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($hourDiffToLock==1) {
|
||||
$hourDiffToLock = $hourDiffToLock." Stunde";
|
||||
} else{
|
||||
$hourDiffToLock = $hourDiffToLock." Stunden";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user=Auth::user();
|
||||
$message_text_tipps="";
|
||||
$message_text_joker="";
|
||||
if ($user && $currentSeason) {
|
||||
if (User::hasMissingTipp($user->id)) {
|
||||
$message_text_tipps="Fehlende Tipps für ".$nextRoundName;
|
||||
}
|
||||
if (User::hasMissingJoker($user->id)) {
|
||||
$message_text_joker="Fehlender Joker für ".$nextRoundName;
|
||||
}
|
||||
}
|
||||
|
||||
//Log::info($a->getEndMessage());
|
||||
|
||||
return view('main',compact('roundname','display_rounds','message_text_joker','message_text_tipps','nextRoundName','nextRoundLockTime', 'hourDiffToLock'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function index() {
|
||||
$a=new TimeLogger("UserController::index()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$activeUsers = User::getActives();
|
||||
|
||||
$b=new TimeLogger("UsersController::index-db_subqueries");
|
||||
Log::info($b->getStartMessage());
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
if (!$currentSeason) { return redirect('/'); }
|
||||
|
||||
$active_user_count = sizeof( $activeUsers );
|
||||
//$total_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->get() );
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get();
|
||||
$total_user_count = sizeof($users);
|
||||
|
||||
Log::info($b->getEndMessage());
|
||||
|
||||
|
||||
Log::info($a->getStartMessage());
|
||||
$missingTipps = User::getMissingTippsAndJokers($activeUsers);
|
||||
|
||||
Log::info("Missing tipps id overview:");
|
||||
foreach($missingTipps["MISSING_TIPP"] as $uid => $val) {
|
||||
Log::info($uid);
|
||||
}
|
||||
|
||||
$c=new TimeLogger("UsersController::index-missingTipp Loop");
|
||||
Log::info($c->getStartMessage());
|
||||
|
||||
$actIds=array();
|
||||
foreach ($activeUsers as $aUser) {
|
||||
Log::info("Active user: ".$aUser->id." ".$aUser->name);
|
||||
$actIds[$aUser->id]=$aUser->id;
|
||||
}
|
||||
|
||||
foreach($users as $index => $user) {
|
||||
Log::info("Filling in data for user_id ".$user->id);
|
||||
if (!array_key_exists($user->id, $actIds)) {
|
||||
Log::info("Inactive id: " . $user->id);
|
||||
$users[$index]->missingTippText = "inaktiv";
|
||||
$users[$index]->tippStyling = "grey";
|
||||
$users[$index]->missingJokerText = "inaktiv";
|
||||
$users[$index]->jokerStyling = "grey";
|
||||
|
||||
} else {
|
||||
|
||||
if (array_key_exists($user->id, $missingTipps["MISSING_TIPP"])) {
|
||||
Log::info("..adding missing tipp");
|
||||
$users[$index]->missingTippText = "Tipps fehlen";
|
||||
$users[$index]->tippStyling = "red";
|
||||
} else {
|
||||
Log::info("..adding existing tipp");
|
||||
$users[$index]->missingTippText = "Runde getippt";
|
||||
$users[$index]->tippStyling = "green";
|
||||
}
|
||||
|
||||
Log::info("UsersController.index: Joker Display Check for UserId=".$user->id);
|
||||
if (array_key_exists($user->id, $missingTipps["MISSING_JOKER"])) {
|
||||
Log::info("UsersController.index: MISSING JOKER DETECTED -> ".$user->id);
|
||||
$users[$index]->missingJokerText = "Joker fehlt";
|
||||
$users[$index]->jokerStyling = "red";
|
||||
} else {
|
||||
Log::info("UsersController.index: JOKER EXISTS -> ".$user->id);
|
||||
$users[$index]->missingJokerText = "Joker gesetzt";
|
||||
$users[$index]->jokerStyling = "green";
|
||||
}
|
||||
}
|
||||
}
|
||||
Log::info($c->getEndMessage());
|
||||
|
||||
$round = Round::getFirstTippableRound();
|
||||
$firstTippableRound=new Round();
|
||||
$firstTippableRound->name="-";
|
||||
if ($round) { $firstTippableRound = $round; }
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view('users.index', compact('users','active_user_count','total_user_count', 'firstTippableRound'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function index_deleted() {
|
||||
$a=new TimeLogger("UserController::index_deleted()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$users = User::whereNotNull('deleted')->orderBy('deleted','DESC')->get();
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
if (!$currentSeason) { return redirect('/'); }
|
||||
|
||||
return view('users.index_deleted', compact('users'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public function showUsers() {
|
||||
$users = DB::table('users')->orderBy('lastname')->get();
|
||||
return view('users.list', compact('users'));
|
||||
}
|
||||
*/
|
||||
// Route-Model binding, because parameter in web.php route has same name as functionparameter
|
||||
public function showUser(User $userObject) {
|
||||
//return $userObject; // If you want it as a JSON object
|
||||
//$user = DB::table('users')->find($id);
|
||||
return view('users.show', compact('userObject'));
|
||||
}
|
||||
|
||||
public function edit($user_id) {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$user = User::where('id',$user_id)->first();
|
||||
$season_id = Season::getCurrent()->id;
|
||||
|
||||
$paid_date_str="";
|
||||
$val=User::payment_date($user_id, $season_id);
|
||||
if ($val) { $paid_date_str=User::toGermanDate($val);}
|
||||
|
||||
return view ('users.edit', compact('user','paid_date_str'));
|
||||
}
|
||||
|
||||
public function store() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("UsersController::store()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
$season_id = Season::getCurrent()->id;
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'id' => 'required',
|
||||
'firstname' => 'required',
|
||||
'lastname' => 'required',
|
||||
'email'=> 'required'
|
||||
]);
|
||||
|
||||
|
||||
$user=User::where('id', request('id'))->first();
|
||||
|
||||
$user->name=request('firstname')." ".request('lastname');
|
||||
$user->firstname=request('firstname');
|
||||
$user->lastname=request('lastname');
|
||||
$user->email=request('email');
|
||||
|
||||
if (request()->has('iban')) { $user->iban = request('iban'); }
|
||||
if (request()->has('bankname')) { $user->bankname = request('bankname'); }
|
||||
if (request()->has('blz')) { $user->blz = request('blz'); }
|
||||
if (request()->has('kontonr')) { $user->kontonr = request('kontonr'); }
|
||||
if (request()->has('mobile')) { $user->mobile = request('mobile'); }
|
||||
|
||||
if (request()->has('admin')) {
|
||||
$user->admin = true;
|
||||
|
||||
} else {
|
||||
$user->admin=false;
|
||||
}
|
||||
$user->save();
|
||||
|
||||
Payment::set_payment_date(request('id'), $season_id, request('paid'));
|
||||
|
||||
//Tipp::createAllTips();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return redirect('/users');
|
||||
}
|
||||
|
||||
|
||||
public function ranking($max_round_id, $seasonId=-1) {
|
||||
if (!Auth::user()) { return redirect("/"); }
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
|
||||
|
||||
$season = Season::getCurrent();
|
||||
if ( $seasonId !=-1 ) {
|
||||
$season=Season::where('id','=',$seasonId)->first();
|
||||
$seasonId = $season->id;
|
||||
} else {
|
||||
$seasonId = $season->id;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
return view('users.no_ranking', compact('start_date'));
|
||||
} else {
|
||||
return redirect("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$max_round_id=min($max_round_id, Round::getLastLockedRoundId());
|
||||
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $season->id) && Auth::user()->name!="Torsten Schneider") {
|
||||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
$response = Tipp::getRoundTipps($max_round_id);
|
||||
$roundtipps = $response['roundtipps'];
|
||||
|
||||
$roundData = $response['roundData'];
|
||||
$user_ids = $response['user_ids'];
|
||||
$round_ids = $response['round_ids'];
|
||||
|
||||
///////////////////////////// DISPLAY AUFBAU /////////////////////////////
|
||||
|
||||
///
|
||||
// AUFBAU RANKINGLISTE A.K.A. RANKINGDISPLAY AB HIER NUR NOCH ANZEIGE-SPEZIFIKA !
|
||||
// Aufbau der Rankingliste in rankingDisplay, sowie aufaddieren der jeweiligen Punkte.
|
||||
// Loop through games and users (again)
|
||||
$rankingDisplay=array();
|
||||
|
||||
$isFinalRound=false;
|
||||
foreach ($user_ids as $user_id) {
|
||||
$round_id = $max_round_id;
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]["ranking_payout"]>0) {
|
||||
$isFinalRound=true;
|
||||
}
|
||||
}
|
||||
|
||||
$payoutList = Quota::getPayoutList($response);
|
||||
|
||||
Log::info("Starting Display Loop");
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$rankscore_total= 0;
|
||||
$payout_sum = 0;
|
||||
|
||||
$round_id = $max_round_id;
|
||||
|
||||
$key = $round_id . "_" . $user_id;
|
||||
|
||||
if (!array_key_exists($user_id, $rankingDisplay)) {
|
||||
$rankingDisplay[$user_id] = array();
|
||||
|
||||
$rankingDisplay[$user_id]["user_id"] = $user_id;
|
||||
$rankingDisplay[$user_id]["round_id"] = $round_id;
|
||||
$rankingDisplay[$user_id]["rank"] = $roundtipps[$key]["rank"];
|
||||
$rankingDisplay[$user_id]["payout"] = $roundtipps[$key]["payout"];
|
||||
$rankingDisplay[$user_id]["user_name"] = $roundtipps[$key]["user_name"];
|
||||
$rankingDisplay[$user_id]["is_dayscorewinner"] = $roundtipps[$key]["is_dayscorewinner"];
|
||||
|
||||
$rankingDisplay[$user_id]["grank"] = $roundtipps[$key]["grank"];
|
||||
$rankingDisplay[$user_id]["gshirt_score"] = $roundtipps[$key]["gshirt_score"];
|
||||
$rankingDisplay[$user_id]["gshirt_totalscore"] = $roundtipps[$key]["gshirt_totalscore"];
|
||||
$rankingDisplay[$user_id]["gshirt_foulcount"] = $roundtipps[$key]["gshirt_foulcount"];
|
||||
$rankingDisplay[$user_id]["gshirt_leader"] = $roundtipps[$key]["gshirt_leader"];
|
||||
|
||||
$rankingDisplay[$user_id]["ranking_payout"] = $roundtipps[$key]["ranking_payout"];
|
||||
|
||||
$rankingDisplay[$user_id]["rankscore"] = $roundtipps[$key]["rankscore"]; // Summe Rangwertung alle 4 Spiele/Tipps der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayscore"] = $roundtipps[$key]["dayscore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayScoreWithRankScore"] = $roundtipps[$key]["dayScoreWithRankScore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
}
|
||||
|
||||
$rankingDisplay[$user_id]["totalRankScore"] = $roundtipps[$key]['totalRankScore'];
|
||||
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score1"] = $roundtipps[$key]["tipps"][0];
|
||||
$rankingDisplay[$user_id]["tipp_score2"] = $roundtipps[$key]["tipps"][1];
|
||||
$rankingDisplay[$user_id]["joker1"] = $roundtipps[$key]["joker"][0];
|
||||
$rankingDisplay[$user_id]["result_score1"] = $roundtipps[$key]["results"][0];
|
||||
$rankingDisplay[$user_id]["result_score2"] = $roundtipps[$key]["results"][1];
|
||||
|
||||
// Determine coloration for Game1
|
||||
$rankingDisplay[$user_id]["trendCol1"] = Tipp::trendCol($roundtipps[$key]["results"][0],$roundtipps[$key]["results"][1],
|
||||
$roundtipps[$key]["tipps"][0],$roundtipps[$key]["tipps"][1],
|
||||
$roundtipps[$key]["joker"][0]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score3"] = $roundtipps[$key]["tipps"][2];
|
||||
$rankingDisplay[$user_id]["tipp_score4"] = $roundtipps[$key]["tipps"][3];
|
||||
$rankingDisplay[$user_id]["joker2"] = $roundtipps[$key]["joker"][1];
|
||||
$rankingDisplay[$user_id]["result_score3"] = $roundtipps[$key]["results"][2];
|
||||
$rankingDisplay[$user_id]["result_score4"] = $roundtipps[$key]["results"][3];
|
||||
|
||||
// Determine coloration for Game2
|
||||
$rankingDisplay[$user_id]["trendCol2"] = Tipp::trendCol($roundtipps[$key]["results"][2],$roundtipps[$key]["results"][3],
|
||||
$roundtipps[$key]["tipps"][2],$roundtipps[$key]["tipps"][3],
|
||||
$roundtipps[$key]["joker"][1]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score5"] = $roundtipps[$key]["tipps"][4];
|
||||
$rankingDisplay[$user_id]["tipp_score6"] = $roundtipps[$key]["tipps"][5];
|
||||
$rankingDisplay[$user_id]["joker3"] = $roundtipps[$key]["joker"][2];
|
||||
$rankingDisplay[$user_id]["result_score5"] = $roundtipps[$key]["results"][4];
|
||||
$rankingDisplay[$user_id]["result_score6"] = $roundtipps[$key]["results"][5];
|
||||
// Determine coloration for Game3
|
||||
$rankingDisplay[$user_id]["trendCol3"] = Tipp::trendCol($roundtipps[$key]["results"][4],$roundtipps[$key]["results"][5],
|
||||
$roundtipps[$key]["tipps"][4],$roundtipps[$key]["tipps"][5],
|
||||
$roundtipps[$key]["joker"][2]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score7"] = $roundtipps[$key]["tipps"][6];
|
||||
$rankingDisplay[$user_id]["tipp_score8"] = $roundtipps[$key]["tipps"][7];
|
||||
$rankingDisplay[$user_id]["joker4"] = $roundtipps[$key]["joker"][3];
|
||||
$rankingDisplay[$user_id]["result_score7"] = $roundtipps[$key]["results"][6];
|
||||
$rankingDisplay[$user_id]["result_score8"] = $roundtipps[$key]["results"][7];
|
||||
// Determine coloration for Game4
|
||||
$rankingDisplay[$user_id]["trendCol4"] = Tipp::trendCol($roundtipps[$key]["results"][6],$roundtipps[$key]["results"][7],
|
||||
$roundtipps[$key]["tipps"][6],$roundtipps[$key]["tipps"][7],
|
||||
$roundtipps[$key]["joker"][3]);
|
||||
|
||||
if ($isFinalRound==true) {
|
||||
// Add GShirt, Playoff, Pokal payout
|
||||
Log::info("!> ".$user_id);
|
||||
$rankingDisplay[$user_id]['gshirt_payout'] = 0;
|
||||
$rankingDisplay[$user_id]['pokal'] = 0;
|
||||
$rankingDisplay[$user_id]['playoff'] = 0;
|
||||
$userPayouts = $payoutList[$user_id];
|
||||
|
||||
$hasGreenShirtGame=Season::hasGreenShirtGame();
|
||||
foreach ($userPayouts as $payoutItem) {
|
||||
Log::info($user_id." - ".$payoutItem['roundname']);
|
||||
if ($hasGreenShirtGame) {
|
||||
if ($payoutItem['roundname'] == "Grünes Trikot") {
|
||||
$rankingDisplay[$user_id]["gshirt_payout"] = $payoutItem['payout'];
|
||||
Log::info("GreenShirt goes to: ".$user_id);
|
||||
}
|
||||
}
|
||||
if ($payoutItem['roundname'] == 'Pokal') {
|
||||
$rankingDisplay[$user_id]["pokal"] = $payoutItem['payout'];
|
||||
Log::info("Pokal goes to: ".$user_id);
|
||||
}
|
||||
|
||||
if (strpos($payoutItem['roundname'], 'Liga') !== false) {
|
||||
$rankingDisplay[$user_id]["playoff"] = $payoutItem['payout'];
|
||||
Log::info($payoutItem['roundname']." goes to: ".$user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$userids = array_keys($rankingDisplay);
|
||||
$round=Round::where('id','=',$max_round_id)->first();
|
||||
$games=Game::where('round_id','=',$max_round_id)->get();
|
||||
$all_rounds=Round::where('season_id','=',$season->id)->get();
|
||||
|
||||
|
||||
// Sortieren nach Rankscore
|
||||
$entries = array();
|
||||
usort($rankingDisplay, array($this,"cmp"));
|
||||
|
||||
foreach($rankingDisplay as $entry) {
|
||||
array_push($entries, $entry);
|
||||
}
|
||||
$rankingDisplay = $entries;
|
||||
|
||||
// Store game results as separate array. Wir nutzen aus, dass die Ergebnisse in jeder Zeile
|
||||
// von Rankingdisplay abgespeichert sind.
|
||||
$game_results=array(); // 4 Spielergebnisse der angezeigten Runde
|
||||
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"]);
|
||||
|
||||
Log::info("UserController::ranking: ExecutionTime: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n");
|
||||
//dd($rankingDisplay);
|
||||
return view('users.ranking', compact('all_rounds','rankingDisplay','userids','round','games','game_results','isFinalRound'));
|
||||
}
|
||||
|
||||
public function cmp($user1, $user2) {
|
||||
return ($user1['totalRankScore'] < $user2['totalRankScore']);
|
||||
}
|
||||
public function cmpDayWin($user1, $user2) {
|
||||
return ($user1[1] < $user2[1]); // Feld0: user_id, Feld1: dayScoreWithRankScore
|
||||
}
|
||||
public function cmpRank($rank1, $rank2) {
|
||||
return ($rank1[1] < $rank2[1]);
|
||||
}
|
||||
|
||||
public function show_payouts() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
$quotas = Quota::getQuotas();
|
||||
$payouts = Quota::getPayouts();
|
||||
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','quotas','currentSeason'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function mailtest() {
|
||||
// Works:
|
||||
// $user = User::where('id','=',1)->first();
|
||||
// \Mail::to($user)->send(new RoundmailMailer);
|
||||
|
||||
$users = User::whereIn('id',array(1))->get();
|
||||
foreach($users as $user) {
|
||||
Log::info("Sending RoundmailMailer to: ".$user->name);
|
||||
\Mail::to($user)->send(new RoundmailMailer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function test() {
|
||||
//Password::sendResetLink(['email','magus@zauberturm.de']);
|
||||
$request = new Request();
|
||||
$request->merge(['email'=>'magus@zauberturm.de']);
|
||||
|
||||
$broker = $this->getBroker();
|
||||
|
||||
$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
|
||||
$message->subject($this->getEmailSubject());
|
||||
});
|
||||
}
|
||||
|
||||
// App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail
|
||||
public function reset() {
|
||||
return view('auth.passwords.email');
|
||||
}
|
||||
|
||||
public function processReset(Request $request) {
|
||||
$response = $this->broker()->sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
}
|
||||
|
||||
//route: useredit => useredit view
|
||||
public function useredit($user_id) {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$user=Auth::user();
|
||||
|
||||
$paid_date_str="";
|
||||
$val=User::payment_date($user_id, Season::getCurrent()->id);
|
||||
if ($val) { $paid_date_str=User::toGermanDate($val);}
|
||||
|
||||
return view ('users.useredit', compact('user','paid_date_str'));
|
||||
}
|
||||
|
||||
public function send_reset_links_from_settings() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
$this->sendResetLink(Auth::user());
|
||||
}
|
||||
|
||||
public function storeUserEdit() {
|
||||
Log::info("storeUserEdit");
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
Log::info("Auth ok");
|
||||
|
||||
Log::info("Request:");
|
||||
Log::info(request());
|
||||
|
||||
$season_id = Season::getCurrent()->id;
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'email'=> 'required'
|
||||
|
||||
]);
|
||||
|
||||
$user=Auth::user();
|
||||
|
||||
$user->email=request('email');
|
||||
|
||||
if (request()->has('gets_reminders')) {
|
||||
Log::info("No reminder");
|
||||
$user->gets_reminders = true;
|
||||
} else {
|
||||
Log::info("Set reminder");
|
||||
$user->gets_reminders=false;
|
||||
}
|
||||
|
||||
if (request()->has('iban')) {
|
||||
$user->iban = request('iban');
|
||||
}
|
||||
if (request()->has('blz')) {
|
||||
$user->blz=request('blz');
|
||||
}
|
||||
if (request()->has('bankname')) {
|
||||
$user->bankname=request('bankname');
|
||||
}
|
||||
if (request()->has('kontonr')) {
|
||||
$user->kontonr=request('kontonr');
|
||||
}
|
||||
if (request()->has('mobile')) {
|
||||
$user->mobile=request('mobile');
|
||||
}
|
||||
|
||||
Log::info("Setting gets_reminders to: " . request('gets_reminders'));
|
||||
$user->save();
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function delete($user_id) {
|
||||
if (!Auth::user()->admin) redirect("/users");
|
||||
User::softDelete($user_id);
|
||||
return redirect("/users");
|
||||
}
|
||||
|
||||
public function restore($user_id) {
|
||||
if (!Auth::user()->admin) redirect("/users");
|
||||
$user=User::where('id','=',$user_id)->first();
|
||||
$user->deleted = null;
|
||||
$user->save();
|
||||
return redirect("/users");
|
||||
}
|
||||
|
||||
|
||||
public function money_ranking() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$currentSeason = Season::getCurrent();
|
||||
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');
|
||||
}
|
||||
|
||||
// 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) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
return view('users.no_ranking', compact('start_date'));
|
||||
} else {
|
||||
return redirect("/");
|
||||
}
|
||||
}
|
||||
|
||||
$sortedPayout = Quota::getPayoutPerUser();
|
||||
|
||||
return view ('users.payout_ranking_index',compact('sortedPayout'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function money_ranking_with_iban() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $currentSeason->id) && Auth::user()->name!="Torsten Schneider") {
|
||||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
$response = Tipp::getRoundTipps();
|
||||
if (sizeof($response)==0) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
$roundtipps = $response['roundtipps'];
|
||||
$roundData = $response['roundData'];
|
||||
$user_ids = $response['user_ids'];
|
||||
$round_ids = $response['round_ids'];
|
||||
|
||||
$payoutTotal = array();
|
||||
$cnt=0;
|
||||
foreach($round_ids as $round_id) {
|
||||
foreach($user_ids as $user_id) {
|
||||
$key=$round_id."_".$user_id;
|
||||
|
||||
$payout = str_replace(",",".",$roundtipps[$key]['payout']);
|
||||
if (strlen($payout)==0) { $payout=0; }
|
||||
|
||||
if (!array_key_exists($user_id, $payoutTotal)) {
|
||||
$payoutTotal[$user_id]['amount']=0;
|
||||
$payoutTotal[$user_id]['name']=$roundtipps[$key]['user_name'];
|
||||
$payoutTotal[$user_id]['user_id']=$roundtipps[$key]['user_id'];
|
||||
}
|
||||
|
||||
$payoutTotal[$user_id]['amount'] += $payout;
|
||||
|
||||
$payout_ranking = $roundtipps[$key]['ranking_payout'];
|
||||
$payoutTotal[$user_id]['amount'] += $payout_ranking;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sortedPayout=array();
|
||||
foreach($payoutTotal as $payout) {
|
||||
$payment=array();
|
||||
$payment['user_id']=$payout['user_id'];
|
||||
$payment['name']=$payout['name'];
|
||||
$payment['amount']=$payout['amount'];
|
||||
|
||||
$user=User::where('id','=',$payout['user_id'])->first();
|
||||
$payment['iban']=$user->iban;
|
||||
$payment['blz']=$user->blz;
|
||||
$payment['bankname']=$user->bankname;
|
||||
$payment['kontonr']=$user->kontonr;
|
||||
|
||||
|
||||
array_push($sortedPayout,$payment);
|
||||
}
|
||||
|
||||
usort($sortedPayout,array($this,'cmpPayment'));
|
||||
|
||||
$users=User::getActives();
|
||||
|
||||
|
||||
return view ('users.payout_ranking_index_with_iban',compact('sortedPayout','users'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function cmpPayment($payment1, $payment2) {
|
||||
return ($payment1['amount'] < $payment2['amount']);
|
||||
}
|
||||
|
||||
|
||||
public function money_ranking_detail($user_id) {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $currentSeason->id) && Auth::user()->name!="Torsten Schneider") {
|
||||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$payouts = Quota::getPayoutPerUserDetails($user_id);
|
||||
|
||||
|
||||
|
||||
$user = User::where('id','=',$user_id)->first();
|
||||
|
||||
return view ('users.payout_ranking_detail',compact('payouts','user'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
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();
|
||||
$roundnames = array();
|
||||
|
||||
foreach ($rankingDisplay[0] as $user_round) {
|
||||
array_push($roundnames, $user_round['round_name']);
|
||||
}
|
||||
|
||||
return view ('users.gshirt_ranking', compact('rankingDisplay','usernames', 'roundnames'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -94,4 +94,7 @@ 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');
|
||||
Route::get('/league/showSingleUserMatches/user_id={userId}','Leagues\LeaguesController@showSingleUserMatches');
|
||||
|
||||
/* Cache clearing on remote server */
|
||||
Route::get('/clear-cache', function() { Artisan::call('cache:clear');Artisan::call('config:clear'); return "Cache cleared, Config reloaded"; });
|
||||
|
|
|
|||
470
tools/pfosten_2022-06-11_091759.sql
Normal file
470
tools/pfosten_2022-06-11_091759.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue