Working on Roundmail system
This commit is contained in:
parent
3fa31921f0
commit
6d7ee1a47c
11 changed files with 224 additions and 24 deletions
|
|
@ -10,9 +10,12 @@ use App\Round;
|
|||
use App\Game;
|
||||
use App\Tipp;
|
||||
use App\Quota;
|
||||
use App\Mail\Roundmail;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
|
||||
use Carbon;
|
||||
|
||||
class UsersController extends Controller
|
||||
|
|
@ -23,17 +26,25 @@ class UsersController extends Controller
|
|||
|
||||
$currentSeason=Season::getCurrent();
|
||||
|
||||
$display_rounds=array();
|
||||
if ($currentSeason) {
|
||||
$round_id = Round::getLastCompleteRoundId();
|
||||
|
||||
if ($round_id > -1) {
|
||||
$round = Round::where("id", "=", $round_id)->first();
|
||||
$report = $round->report;
|
||||
$rounds = Round::where("id", "<=", $round_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");}
|
||||
|
||||
return view('main',compact('roundname','report'));
|
||||
return view('main',compact('roundname','display_rounds'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
|
@ -392,4 +403,17 @@ class UsersController extends Controller
|
|||
return view('users.show_payouts', compact('payouts','active_user_count','einsatz','currentSeason'));
|
||||
}
|
||||
|
||||
public function mailtest() {
|
||||
// Works:
|
||||
// $user = User::where('id','=',1)->first();
|
||||
// \Mail::to($user)->send(new Roundmail);
|
||||
|
||||
$users = User::whereIn('id',array(1,2,7,57))->get();
|
||||
foreach($users as $user) {
|
||||
Log::info("Sending Roundmail to: ".$user->name);
|
||||
\Mail::to($user)->send(new Roundmail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,21 @@ class Round extends Model
|
|||
return $lastCompleteRound;
|
||||
}
|
||||
|
||||
public static function getFirstIncompleteRound() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$rounds = Round::where('season_id','=',$season_id)->orderBy('id')->get();
|
||||
foreach($rounds as $round) {
|
||||
$games = Game::where('round_id','=',$round->id);
|
||||
foreach ($games as $game) {
|
||||
if ($game->score1 == -1 || $game->score2 == -1) {
|
||||
return $round->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function getLastLockedRoundId() {
|
||||
$season = Season::getCurrent();
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,34 @@ class User extends Authenticatable
|
|||
return $dbDate;
|
||||
}
|
||||
|
||||
public function hello() {
|
||||
return "Hello";
|
||||
public static function hasMissingTipp($user_id) {
|
||||
$round_id = Round::getFirstIncompleteRound();
|
||||
$games = Game::where('round_id','=',$round_id);
|
||||
|
||||
foreach ($games as $game) {
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->first();
|
||||
|
||||
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function hasMissingJoker($user_id) {
|
||||
$round_id = Round::getFirstIncompleteRound();
|
||||
$games = Game::where('round_id','=',$round_id);
|
||||
|
||||
$joker=0;
|
||||
foreach ($games as $game) {
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->first();
|
||||
if ($tipp->joker == true) { $joker=1; }
|
||||
}
|
||||
|
||||
if ($joker==1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ return [
|
|||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'info@hoschis-tippspiel.de'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Hoschis Tippspiel'),
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -16,14 +16,11 @@ class CreateQuotasTable extends Migration
|
|||
Schema::create('quotas', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->integer('season_id');
|
||||
$table->string('qtype',100);
|
||||
$table->integer('season_id')->default(0);
|
||||
$table->string('name',100);
|
||||
$table->integer('order')->default(1);
|
||||
$table->integer('order')->default(0);
|
||||
$table->integer('prc')->default(0);
|
||||
|
||||
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
19
pfosten/resources/views/emails/roundmail.blade.php
Normal file
19
pfosten/resources/views/emails/roundmail.blade.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rundmail Test</h1>
|
||||
|
||||
<h3>Um nicht alle Spieler mit Spam zu belästigen, sende ich die Test-Rundmails in den nächsten Tagen</h3>
|
||||
<h3>an Euch Administratoren (Volker Geissler, Wilfried Moitzheim, Michael Schmitz).</h3>
|
||||
<p> </p>
|
||||
<h3>Seid tapfer, ich belästige euch mit dem Test-Spam nur für ein paar Tage ;-)</h3>
|
||||
<p> </p>
|
||||
<h3>Wenn diese Auto-Mails vor unleserlichen Sonderzeichen nur so strotzen, lasst es mich wissen: torsten.schneider@programmschmiede.de</h3>
|
||||
<p> </p>
|
||||
<h3>-Torsten.</h3>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
@endif
|
||||
|
||||
|
||||
</section>
|
||||
@if (Auth::check())
|
||||
|
||||
<div class="container-fluid jumbotron col-md-12">
|
||||
<span class="col-md-2"></span>
|
||||
<span class="text-center col-md-8">
|
||||
<p> {{ $roundname }}</p>
|
||||
<p> {!! $report !!}</p>
|
||||
</span>
|
||||
</div>
|
||||
@foreach($display_rounds as $round)
|
||||
<div class="container-fluid col-md-12">
|
||||
<span class="col-md-2"></span>
|
||||
<span class="text-center col-md-8">
|
||||
<h2> {{ $round['name'] }}</h2>
|
||||
<div style="font-size: 18px;"> {!! $round['report'] !!}</div>
|
||||
</span>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@endsection
|
||||
21
pfosten/resources/views/roundmails/index.blade.php
Normal file
21
pfosten/resources/views/roundmails/index.blade.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="jumbotron text-center container">
|
||||
<!-- <div class="container"> -->
|
||||
|
||||
<span class="lead col-md-10" >Rundmails</span><a class="lead col-md-2" href="/roundmails/show/-1">Neue Rundmail</a>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<div class="col-md-10">
|
||||
<h4>(Neue Rundmail erstellen)</h4>
|
||||
<h4>(Datum-sortierte Liste der letzten Themen)</h4>
|
||||
<h4>(Mail-Liste)</h4>
|
||||
</div>
|
||||
|
||||
<!-- </div> -->
|
||||
|
||||
|
||||
</section>
|
||||
@endsection
|
||||
92
pfosten/resources/views/roundmails/show.blade.php
Normal file
92
pfosten/resources/views/roundmails/show.blade.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="text-center container">
|
||||
<div class="lead col-md-12" ><h2>Mail</h2></div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<form method="POST" action="/roundmails/send" class="text-center col-md-12">
|
||||
{{ csrf_field() }}
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="col-md-2" style="width:200px;">Datum der Mail</label>
|
||||
<input class="col-md-8" style="width:400px" value="xxxxxxx" readonly></input>
|
||||
</div>
|
||||
<p> </p>
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="col-md-2" style="width:200px;">Thema:</label>
|
||||
<input class="col-md-8" style="width:400px" name="topic" value="">
|
||||
</div>
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
|
||||
<label>Empfänger:</label>
|
||||
<p> </p>
|
||||
<textarea id="recipients" name="recipients" class="form-control" style="min-height:150px;height:auto;">dummy@doof.de</textarea>
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
|
||||
|
||||
|
||||
<button onClick="setAdminRecipient(); return false;">Alle Administatoren</button>
|
||||
<button onClick="setActiveRecipient(); return false;">Alle aktiven Spieler</button>
|
||||
<button onClick="setInactiveRecipient(); return false;">Alle inaktiven Spieler (keine Zahlung)</button>
|
||||
<button onClick="setMissingRecipient(); return false;">Alle Spieler mit fehlenden Eingaben</button>
|
||||
|
||||
|
||||
<p> </p>
|
||||
<label>Nachricht</label>
|
||||
<textarea name="message" class="form-control" style="min-height:250px;height:auto;">I am a message text</textarea>
|
||||
|
||||
|
||||
<p></p>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">Senden</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function setAdminRecipient()
|
||||
{
|
||||
var elem = document.getElementById("recipients");
|
||||
elem.innerHTML = "{{ $adminMailList }}";
|
||||
}
|
||||
|
||||
function setActiveRecipient()
|
||||
{
|
||||
var elem = document.getElementById("recipients");
|
||||
elem.innerHTML = "{{ $activeMailList }}";
|
||||
}
|
||||
|
||||
function setInactiveRecipient()
|
||||
{
|
||||
var elem = document.getElementById("recipients");
|
||||
elem.innerHTML = "{{ $inactiveMailList }}";
|
||||
}
|
||||
|
||||
function setMissingRecipient()
|
||||
{
|
||||
var elem = document.getElementById("recipients");
|
||||
elem.innerHTML = "{{ $missingMailList }}";
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</section>
|
||||
@endsection
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
@section('content')
|
||||
|
||||
<div style="float:left;left:10%">
|
||||
<div style="float:left;position:relative;">
|
||||
|
||||
@foreach($all_rounds as $r)
|
||||
@if (App\Round::hasLockedGame($r->id) )
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div style="float:left; position:relative;left:47%">
|
||||
<div style="float:left; position:relative; left:-50%;">
|
||||
<div style="float:left; position:relative; left:5%;">
|
||||
<div style="float:left;">
|
||||
|
||||
<h3>{{ App\Season::getCurrent()->name }}</h3>
|
||||
<h4>{{ $round->name }}</h4>
|
||||
|
|
|
|||
|
|
@ -49,3 +49,8 @@ Route::get('/users/show_payouts','UsersController@show_payouts');
|
|||
Route::get('/tipps','TippsController@index');
|
||||
Route::get('/tipps/edit/{tipp_id}','TippsController@edit');
|
||||
Route::post('/tipps/store','TippsController@store');
|
||||
|
||||
Route::get('/email','UsersController@mailtest2');
|
||||
|
||||
Route::get('/roundmails','RoundmailController@index');
|
||||
Route::get('/roundmails/show/{mail_id}','RoundmailController@show');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue