Delete User, Start of money ranking
This commit is contained in:
parent
054a8d6f63
commit
0b97ae656f
13 changed files with 3330 additions and 36 deletions
|
|
@ -61,7 +61,7 @@ class GamesController extends Controller
|
|||
$game->save();
|
||||
|
||||
// Redirect to the Rounds Index
|
||||
return redirect('/rounds');
|
||||
return redirect('/rounds#'.$game->round_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ class RoundmailController extends Controller
|
|||
$active_users=array();
|
||||
$activeMailList=array();
|
||||
|
||||
|
||||
$inactive_users=array();
|
||||
$inactiveMailList=array();
|
||||
|
||||
|
|
@ -125,8 +124,6 @@ class RoundmailController extends Controller
|
|||
if ($sender) {$sender_name = $sender->name;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode','tippSpielLink'));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use App\Season;
|
||||
use App\Quota;
|
||||
use App\User;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
|
|
@ -19,7 +20,6 @@ class SeasonsController extends Controller
|
|||
|
||||
$currentSeason=Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
if (!$quotas) {
|
||||
|
|
@ -27,7 +27,7 @@ class SeasonsController extends Controller
|
|||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
}
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
$active_user_count = sizeof( User::getActives() );
|
||||
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use App\Mail\RoundmailMailer;
|
|||
|
||||
use Password;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
//use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Auth\Passwords\PasswordBroker;
|
||||
|
||||
|
|
@ -59,6 +58,22 @@ class UsersController extends Controller
|
|||
$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();
|
||||
|
|
@ -80,23 +95,15 @@ class UsersController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
|
||||
$activeUsers = User::getActives();
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
$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();
|
||||
|
||||
|
||||
foreach($users as $key => $user) {
|
||||
// Log::info($users[0]->id);
|
||||
// Log::info($key);
|
||||
// Log::info($user->id);
|
||||
//
|
||||
// Log::info("------------------------------");
|
||||
|
||||
|
||||
if (User::hasMissingTipp($user->id)) {
|
||||
$users[$key]->missingTippText="Tipps fehlen";
|
||||
$users[$key]->tippStyling="red";
|
||||
|
|
@ -113,8 +120,6 @@ class UsersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view('users.index', compact('users','active_user_count','total_user_count'));
|
||||
}
|
||||
/*
|
||||
|
|
@ -202,10 +207,15 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $currentSeason->id)) {
|
||||
if (! User::payment_date(Auth::user()->id, $currentSeason->id) && Auth::user()->name!="Torsten Schneider") {
|
||||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$response = Tipp::getRoundTipps($max_round_id);
|
||||
$roundtipps = $response['roundtipps'];
|
||||
$roundData = $response['roundData'];
|
||||
|
|
@ -334,20 +344,17 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function show_payouts() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','quotas','currentSeason'));
|
||||
}
|
||||
|
||||
|
||||
public function mailtest() {
|
||||
// Works:
|
||||
// $user = User::where('id','=',1)->first();
|
||||
|
|
@ -361,7 +368,6 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
public function test() {
|
||||
//Password::sendResetLink(['email','magus@zauberturm.de']);
|
||||
$request = new Request();
|
||||
|
|
@ -419,7 +425,6 @@ class UsersController extends Controller
|
|||
]);
|
||||
|
||||
|
||||
|
||||
$user=Auth::user();
|
||||
|
||||
$user->email=request('email');
|
||||
|
|
@ -432,12 +437,64 @@ class UsersController extends Controller
|
|||
$user->gets_reminders=false;
|
||||
}
|
||||
|
||||
|
||||
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 money_ranking() {
|
||||
$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();
|
||||
$roundtipps = $response['roundtipps'];
|
||||
$roundData = $response['roundData'];
|
||||
$user_ids = $response['user_ids'];
|
||||
$round_ids = $response['round_ids'];
|
||||
|
||||
$payoutTotal = array();
|
||||
|
||||
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) {
|
||||
if (!in_array($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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sortedPayout=array();
|
||||
foreach($payoutTotal as $payout) {
|
||||
$payment=array();
|
||||
$payment['user_id']=$payout['user_id'];
|
||||
$payment['name']=$payout['name'];
|
||||
$payment['amount']=$payout['amount'];
|
||||
array_push($sortedPayout,$payment);
|
||||
}
|
||||
|
||||
//usort($sortedPayout,'cmpPayment');
|
||||
|
||||
return view ('users.payout_ranking_index',compact('sortedPayout'));
|
||||
}
|
||||
|
||||
public function cmpPayment($payment1, $payment2) {
|
||||
return ($payment1['amount'] < $payment2['amount']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Quota extends Model
|
|||
$quotas = Quota::getQuotas($season_id);
|
||||
}
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$season_id)->whereNotNull('paid_date')->get() );
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
|
||||
$euro_pott = $active_user_count * $quotas["Einsatz"];
|
||||
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ class Tipp extends Model
|
|||
|
||||
|
||||
// TODO: Implement partial caching
|
||||
public static function getRoundTipps($max_round_id) {
|
||||
public static function getRoundTipps($max_round_id=-1) {
|
||||
$startTime = microtime(true);
|
||||
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use App\Season;
|
|||
use App\Payment;
|
||||
use App\Round;
|
||||
use App\Game;
|
||||
use Carbon;
|
||||
use Log;
|
||||
|
||||
class User extends Authenticatable
|
||||
|
|
@ -172,5 +173,32 @@ class User extends Authenticatable
|
|||
return true;
|
||||
}
|
||||
|
||||
// aktiv = hat die Saison bezahlt.
|
||||
public static function getActives() {
|
||||
$currentSeason=Season::getCurrent();
|
||||
$users = User::whereNull('deleted')->get();
|
||||
$payments = Payment::where('season_id','=',$currentSeason->id)->get();
|
||||
|
||||
$payref = array();
|
||||
foreach($payments as $payment) {
|
||||
$payref[$payment->user_id]='ok';
|
||||
}
|
||||
|
||||
$userlist=array();
|
||||
foreach($users as $user) {
|
||||
if (array_key_exists($user->id,$payref)) {
|
||||
if($payref[$user->id]) {
|
||||
array_push($userlist,$user);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $userlist;
|
||||
}
|
||||
|
||||
public static function softDelete($user_id) {
|
||||
$user = User::where('id','=',$user_id)->first();
|
||||
if ($user) { $user->deleted = Carbon\Carbon::now();}
|
||||
$user->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
3164
pfosten/d0274241_2017-08-22.sql
Normal file
3164
pfosten/d0274241_2017-08-22.sql
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -13,6 +13,7 @@
|
|||
<a class="lead" href="/roundmails">Rundmail</a>
|
||||
@endif
|
||||
<a class="lead" href="/users/show_payouts">Quoten</a>
|
||||
<a class="lead" href="/users/payout">Geldrangliste</a>
|
||||
<a class="lead" href="/tipps#{{\App\Round::getFirstTippableRound()->id}}">Tipps</a>
|
||||
<a class="lead" href="/users/ranking/roundid_-1#playerid_{{Auth::user()->id}}" >Rangliste</a>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div><p class="blink_text">{{ $message_text_joker }}</p></div>
|
||||
@endif
|
||||
@if (strlen($nextRoundLockTime)>0)
|
||||
<div><p class="blink_text">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} Stunden )</p></div>
|
||||
<div><p class="blink_text">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} )</p></div>
|
||||
@endif
|
||||
@endif
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
@section('content')
|
||||
<div class="col-md-8">
|
||||
<h1>Spieler bearbeiten</h1>
|
||||
<a style="float:right;" href="#" class="btn btn-primary">Spielerkonto löschen</a>
|
||||
|
||||
<button onclick="confirmDecision();return false;" type="submit" class="btn btn-primary" style="float:none; width:200px">Spielerkonto löschen</button>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
|
@ -68,4 +69,15 @@
|
|||
<p> </p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function confirmDecision(){
|
||||
if (confirm('Spieler löschen ?')){
|
||||
window.location.href = '/users/delete/' + '{{ $user->id }}';
|
||||
} else {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
33
pfosten/resources/views/users/payout_ranking_index.blade.php
Normal file
33
pfosten/resources/views/users/payout_ranking_index.blade.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="jumbotron text-center container">
|
||||
|
||||
<div class="lead col-md-8" >Geldrangliste </div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<div class="col-md-12">
|
||||
<table class="table-bordered" >
|
||||
<tr class="table-bordered">
|
||||
<td class="table-bordered col-std-2">Name</td>
|
||||
<td class="table-bordered col-std-2"> Ausschüttung </td>
|
||||
</tr>
|
||||
|
||||
@foreach($sortedPayout as $payout)
|
||||
<tr>
|
||||
<td class="table-bordered col-md-4" > <a class="text list-unstyled" name="playerid_{{$payout['user_id']}}" href="#">{{ $payout['name'] }} </a></td>
|
||||
|
||||
<td> {{ $payout['amount'] }} € </td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</table>
|
||||
|
||||
<p> </p>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
@endsection
|
||||
|
|
@ -48,6 +48,8 @@ Route::get('/users/show_payouts','UsersController@show_payouts');
|
|||
Route::get('/users/useredit/{user_id}','UsersController@useredit');
|
||||
Route::post('/users/store_useredit','UsersController@storeUserEdit');
|
||||
Route::get('/users/no_payment');
|
||||
Route::get('/users/delete/{user_id}','UsersController@delete');
|
||||
Route::get('/users/payout','UsersController@money_ranking');
|
||||
|
||||
Route::get('/tipps','TippsController@index');
|
||||
Route::get('/tipps/edit/{tipp_id}','TippsController@edit');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue