Tippstart auf Tippable round, Link Roundmail: Tipps@Tippspiel

This commit is contained in:
Torsten 2017-08-26 15:15:54 +02:00
parent 0abaeb2eba
commit 6aad1a7ab2
13 changed files with 149 additions and 34 deletions

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Roundmail; use App\Roundmail;
use App\User; use App\User;
use App\Round;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Mail\RoundmailMailer; use App\Mail\RoundmailMailer;
@ -98,7 +99,7 @@ class RoundmailController extends Controller
$missingJokerMailList = implode(",",$missingJokerMailList); $missingJokerMailList = implode(",",$missingJokerMailList);
$adminMailList = implode(",",$adminMailList); $adminMailList = implode(",",$adminMailList);
$tippSpielLink="http://hoschis-tippspiel.de/tipps#".Round::getFirstTippableRound()->id;
$topic=""; $topic="";
$mail_message=""; $mail_message="";
@ -118,7 +119,7 @@ class RoundmailController extends Controller
return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode')); return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode','tippSpielLink'));
} }
@ -189,4 +190,7 @@ class RoundmailController extends Controller
} }
public function checkReminder() {
Log::info("RoundmailController::checkReminder was triggered");
}
} }

View file

@ -23,7 +23,6 @@ class TippsController extends Controller
$rounds = Round::all()->where('season_id', '=', $activeSeason->id); $rounds = Round::all()->where('season_id', '=', $activeSeason->id);
foreach($rounds as $round) { foreach($rounds as $round) {
$games=Game::all()->where('round_id','=',$round->id); $games=Game::all()->where('round_id','=',$round->id);
foreach($games as $game) { foreach($games as $game) {
@ -74,14 +73,9 @@ class TippsController extends Controller
TippsController::createTipps($user->id); // ggfs. fehlender Tipp Eintraege einfügen TippsController::createTipps($user->id); // ggfs. fehlender Tipp Eintraege einfügen
$lastLockedRoundId=Round::getLastLockedRoundId();
if ($activeSeason) { $rounds = Round::where('season_id', '=', $activeSeason->id)->get();
$activeSeasonId = Season::getCurrent()->id;
$rounds = Round::all()->where('season_id', '=', $activeSeasonId);
}
Log::info("REDIRECTING to TIPPS index");
return view('tipps.index', compact('rounds', 'activeSeason', 'user')); return view('tipps.index', compact('rounds', 'activeSeason', 'user'));
} }

View file

@ -18,8 +18,6 @@ use Illuminate\Contracts\Auth\Guard;
use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Auth\Passwords\PasswordBroker; use Illuminate\Auth\Passwords\PasswordBroker;
use DB; use DB;
use Auth; use Auth;
use Log; use Log;
@ -53,8 +51,9 @@ class UsersController extends Controller
} else {Log::info("No current season");} } else {Log::info("No current season");}
$nextRoundName=""; $nextRoundName="";
$nextRoundId = Round::getFirstIncompleteRound(); $nextRound = Round::getFirstTippableRound();
if ($nextRoundId>-1) { $nextRoundName = Round::where('id','=',$nextRoundId)->first()->name; }
if ($nextRound) { $nextRoundName = $nextRound->name; }
$user=Auth::user(); $user=Auth::user();
$message_text_tipps=""; $message_text_tipps="";
@ -134,10 +133,7 @@ class UsersController extends Controller
$paid_date_str=""; $paid_date_str="";
$val=User::payment_date($user_id, $season_id); $val=User::payment_date($user_id, $season_id);
Log::info("UserController:edit => payment_date=".$val);
if ($val) { $paid_date_str=User::toGermanDate($val);} if ($val) { $paid_date_str=User::toGermanDate($val);}
Log::info("German Date=".$paid_date_str);
return view ('users.edit', compact('user','paid_date_str')); return view ('users.edit', compact('user','paid_date_str'));
} }
@ -489,4 +485,22 @@ class UsersController extends Controller
); );
} }
//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());
}
} }

View file

@ -66,6 +66,8 @@ class Round extends Model
return -1; return -1;
} }
public static function getLastLockedRoundId() { public static function getLastLockedRoundId() {
$season = Season::getCurrent(); $season = Season::getCurrent();
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get(); $rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
@ -78,6 +80,18 @@ class Round extends Model
return $lastLockedRoundId; return $lastLockedRoundId;
} }
public static function getFirstTippableRound() {
$season = Season::getCurrent();
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
$locked = false;
foreach ($rounds as $round) {
if (!Round::hasLockedGame($round->id) ) {
return $round;
}
}
return null;
}
public static function getClosestRoundToNow() { public static function getClosestRoundToNow() {
$sql="select round_id,DATEDIFF(NOW(),kickoff) from games order by 2 desc limit 1;"; $sql="select round_id,DATEDIFF(NOW(),kickoff) from games order by 2 desc limit 1;";
$result=DB::select($sql); $result=DB::select($sql);

View file

@ -191,7 +191,6 @@ class Tipp extends Model
['user_id','=',$user_id]] ['user_id','=',$user_id]]
)->first(); )->first();
if (! $tipp) { if (! $tipp) {
Log::info('Creating missing tip: game_id=' . $game->id . ", user_id=" . $user->id);
$tipp=Tipp::create([ $tipp=Tipp::create([
'user_id' => $user_id, 'user_id' => $user_id,
'game_id'=> $game->id, 'game_id'=> $game->id,

View file

@ -131,7 +131,7 @@ class User extends Authenticatable
} }
public static function hasMissingTipp($user_id) { public static function hasMissingTipp($user_id) {
$round_id = Round::getFirstIncompleteRound(); $round_id = Round::getFirstTippableRound()->id;
$games = Game::where('round_id','=',$round_id)->get(); $games = Game::where('round_id','=',$round_id)->get();
foreach ($games as $game) { foreach ($games as $game) {
@ -146,8 +146,7 @@ class User extends Authenticatable
} }
public static function hasMissingJoker($user_id) { public static function hasMissingJoker($user_id) {
$round_id = Round::getFirstIncompleteRound(); $round_id = Round::getFirstTippableRound()->id;
//Log::info("round_id for jokercheck=".$round_id);
$games = Game::where('round_id','=',$round_id." user_id=".$user_id)->get(); $games = Game::where('round_id','=',$round_id." user_id=".$user_id)->get();
$joker=0; $joker=0;
foreach ($games as $game) { foreach ($games as $game) {

View file

@ -16,8 +16,8 @@ return [
| |
*/ */
//'driver' => env('MAIL_DRIVER', 'smtp'), 'driver' => env('MAIL_DRIVER', 'smtp'),
'driver' => env('MAIL_DRIVER', 'log'), //'driver' => env('MAIL_DRIVER', 'log'),

View file

@ -13,10 +13,10 @@
<a class="lead" href="/roundmails">Rundmail</a> &nbsp; &nbsp; &nbsp; <a class="lead" href="/roundmails">Rundmail</a> &nbsp; &nbsp; &nbsp;
@endif @endif
<a class="lead" href="/users/show_payouts">Quoten</a> &nbsp; &nbsp; &nbsp; <a class="lead" href="/users/show_payouts">Quoten</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/tipps">Tipps</a> &nbsp; &nbsp; &nbsp; <a class="lead" href="/tipps#{{\App\Round::getFirstTippableRound()->id}}">Tipps</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/users/ranking/-1" >Rangliste</a> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <a class="lead" href="/users/ranking/-1" >Rangliste</a> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
<label class="lead text ml-auto" >Spieler: {{ Auth::user()->name }}</label><a class="lead" href="/logout">(abmelden)</a> <label class="lead text ml-auto" >Spieler: <a href="/users/useredit/{{ Auth::user()->id }}">{{ Auth::user()->name }}</a></label><a class="lead" href="/logout">(abmelden)</a>
@endif @endif
</div> </div>

View file

@ -43,13 +43,14 @@
<div>
<button onClick="setAdminRecipient(); return false;">Alle Administatoren</button>&nbsp; <button onClick="setAdminRecipient(); return false;">Alle Administatoren</button>&nbsp;
<button onClick="setActiveRecipient(); return false;">Alle aktiven Spieler</button>&nbsp; <button onClick="setActiveRecipient(); return false;">Alle aktiven Spieler</button>&nbsp;
<button onClick="setInactiveRecipient(); return false;">Alle inaktiven Spieler (keine Zahlung)</button>&nbsp; <button onClick="setInactiveRecipient(); return false;">Alle inaktiven Spieler (keine Zahlung)</button>&nbsp;
<button onClick="setMissingTippRecipient(); return false;">Alle Spieler mit fehlenden Tipps</button>&nbsp; <button onClick="setMissingTippRecipient(); return false;">Alle Spieler mit fehlenden Tipps</button>&nbsp;
<button onClick="setMissingJokerRecipient(); return false;">Alle Spieler mit fehlenden Jokern</button>&nbsp; <button onClick="setMissingJokerRecipient(); return false;">Alle Spieler mit fehlenden Jokern</button>&nbsp;
<div>
<button onClick="setTippLink(); return false;">Tipplink hinzufügen</button>&nbsp;
<p>&nbsp;</p> <p>&nbsp;</p>
<label>Nachricht</label> <label>Nachricht</label>
<textarea id="message" name="message" class="form-control" style="min-height:250px;height:auto;">{{$mail_message}}</textarea> <textarea id="message" name="message" class="form-control" style="min-height:250px;height:auto;">{{$mail_message}}</textarea>
@ -96,6 +97,11 @@
var elem = document.getElementById("recipients"); var elem = document.getElementById("recipients");
elem.innerHTML = "{{ $missingJokerMailList }}"; elem.innerHTML = "{{ $missingJokerMailList }}";
} }
function setTippLink()
{
var elem = document.getElementById("message");
elem.innerHTML += "Link zur Tippseite: {{ $tippSpielLink }}";
}
</script> </script>

View file

@ -21,6 +21,9 @@
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-primary">Anmelden</button> <button type="submit" class="btn btn-primary">Anmelden</button>
</div> </div>
<div>
<a href="/password/reset">Passwort vergessen ?</a>
</div>
</form> </form>

View file

@ -17,8 +17,8 @@
<div> <div>
@foreach($rounds as $round) @foreach($rounds as $round)
<div><a class="text lead col-md-12" name="{{$round->id}}" style="font-size: 38px">{{ $round->name }} </a></div>
<div><label class="text lead">{{ $round->name }} </label></div>
<span class="col-md-12"> <span class="col-md-12">

View file

@ -0,0 +1,80 @@
@extends('layouts.layout')
@section('content')
<div class="col-md-8">
<h1>Spielerdaten</h1>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div>
<form method="POST" action="#" id="playerform">
{{ csrf_field() }}
<a href="/">Neues Passwort anfordern</a>
<div class="form-group">
<div>
<label style="float:left; width:150px" for="name">Login:</label>
<input type="text" class="form-control" id="name" name="name" value="{{ $user->name }}" readonly>
</div>
<div>
<label style="float:left; width:150px" for="firstname">Vorname:</label>
<input type="text" class="form-control" id="firstname" name="firstname" value="{{ $user->firstname }}" readonly>
</div>
<div>
<label style="float:left; width:150px" for="lastname">Nachname:</label>
<input type="text" class="form-control" id="lastname" name="lastname" value="{{ $user->lastname }}" readonly>
</div>
<p>&nbsp;</p>
<div>
<label style="float:left; width:150px" for="name">Zahlung für Saison:</label>
<div class='input-group has_datepicker' id='datetimepicker1'>
<input style="float:left;width:150px" type="text" class="form-control" id="paid" name="paid" value="{{ $paid_date_str }}" readonly >
<span class="input-group-addon" style="float:left;width:50px;">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<p>&nbsp;</p>
<div>
<label style="float:left; width:150px" for="name">Email:</label>
<input type="text" class="form-control" id="email" style="width:600px" name="email" value="{{ $user->email }}" required>
</div>
<p>&nbsp;</p>
<div>
<label style="float:left; width:150px;" for="admin">Admin:</label>
{{ Form::checkbox('admin', 'admin', $user->admin, array('disabled') ) }} <!-- name, value, checked -->
<!-- <input style="width:150px" type="checkbox" class="form-control" id="admin" name="admin" value="{{ $user->admin }}" > -->
</div>
<input type="hidden" name="id" value="{{ $user->id }}">
</div>
<div class="form-group">
<p>&nbsp;</p>
<p>&nbsp;</p>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>
</div>
</form>
<div>
<a href="/" class="btn btn-primary" style="float:none; width:100px">Zurück</a>
</div>
</div>
</div>
@endsection

View file

@ -45,6 +45,7 @@ Route::get('/users/edit/{user_id}','UsersController@edit');
Route::post('/users/store','UsersController@store'); Route::post('/users/store','UsersController@store');
Route::get('/users/ranking/{round_id}','UsersController@ranking'); Route::get('/users/ranking/{round_id}','UsersController@ranking');
Route::get('/users/show_payouts','UsersController@show_payouts'); Route::get('/users/show_payouts','UsersController@show_payouts');
Route::get('/users/useredit/{user_id}','UsersController@useredit');
Route::get('/tipps','TippsController@index'); Route::get('/tipps','TippsController@index');
Route::get('/tipps/edit/{tipp_id}','TippsController@edit'); Route::get('/tipps/edit/{tipp_id}','TippsController@edit');
@ -55,6 +56,7 @@ Route::get('/email','UsersController@mailtest');
Route::get('/roundmails','RoundmailController@index'); Route::get('/roundmails','RoundmailController@index');
Route::get('/roundmails/show/{mail_id}','RoundmailController@show'); Route::get('/roundmails/show/{mail_id}','RoundmailController@show');
Route::post('/roundmails/send','RoundmailController@send'); Route::post('/roundmails/send','RoundmailController@send');
Route::post('/roundmails/send','RoundmailController@checkReminder');
// php artisan route:list // php artisan route:list
//Auth::routes(); //Auth::routes();
@ -64,7 +66,7 @@ Route::get('/password/reset/{token}','Auth\ResetPasswordController@showResetForm
Route::post('/password/reset','Auth\ResetPasswordController@reset'); Route::post('/password/reset','Auth\ResetPasswordController@reset');
Route::get('/register','Auth\RegisterController@showRegistrationForm')->name('register'); Route::get('/register','Auth\RegisterController@showRegistrationForm')->name('register');
Route::get('/users/send_reset_links_from_settings','UsersController@send_reset_links_from_settings');
//Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm'); //Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm');