Updating repo for cross-computer work
This commit is contained in:
parent
807cf49bc0
commit
1fea0f4fe7
18 changed files with 87847 additions and 5202 deletions
|
|
@ -54,6 +54,7 @@ class TippsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
|
||||
//Duplicate from Tipps model
|
||||
//TODO: Refactor usage to use only the Tipps version
|
||||
public static function createAllTips(){
|
||||
|
|
@ -67,6 +68,7 @@ class TippsController extends Controller
|
|||
Log::info($a->getEndMessage());
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
|
@ -83,13 +85,15 @@ class TippsController extends Controller
|
|||
|
||||
$rounds = null;
|
||||
|
||||
TippsController::createTipps($user->id); // ggfs. fehlender Tipp Eintraege einfügen
|
||||
TippsController::createTipps($user->id); // ggfs. fehlende Tipp Eintraege einfügen
|
||||
|
||||
$lastLockedRoundId=Round::getLastLockedRoundId();
|
||||
|
||||
$rounds = Round::where('season_id', '=', $activeSeason->id)->get();
|
||||
$max_identical_jokertipps=$activeSeason->maxIdenticalJokertipps();
|
||||
|
||||
return view('tipps.index', compact('rounds', 'activeSeason', 'user'));
|
||||
|
||||
return view('tipps.index', compact('rounds', 'activeSeason', 'user', 'max_identical_jokertipps'));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -115,17 +119,39 @@ class TippsController extends Controller
|
|||
$tipp = Tipp::where('id', request('id'))->first();
|
||||
$game = Game::where('id', $tipp->game_id)->first();
|
||||
$round= Round::where('id',$game->round_id)->first();
|
||||
if (Round::hasLockedGame($round->id)) { return redirect('/tipps'); } // Für Schlauberger, die die Tippmaske auflassen.
|
||||
//if (Round::hasLockedGame($round->id)) { return redirect('/tipps'); } // Für Schlauberger, die die Tippmaske auflassen.
|
||||
|
||||
$tipp->score1= request('score1');
|
||||
$tipp->score2= request('score2');
|
||||
|
||||
if (request()->has('joker')) {
|
||||
$tipp->joker=true;
|
||||
Log::info("Request has joker");
|
||||
} else {
|
||||
$tipp->joker = false;
|
||||
Log::info("Request has NO joker");
|
||||
}
|
||||
|
||||
// Neuerung 2020-01-09: Joker nur speichern, wenn Ergebnis nicht schon zu oft "gejokert" wurde.
|
||||
Log::info("Checking for joker");
|
||||
if ($tipp->joker) {
|
||||
Log::info("Joker found.");
|
||||
$jokertipps=Tipp::getJokerUsageArray($user->id,$game->round_id);
|
||||
$key=$tipp->score1.":".$tipp->score2;
|
||||
Log::info("Key(Gamescore):".$key);
|
||||
if (array_key_exists($key,$jokertipps)) {
|
||||
Log::info("Key found in jokertipps array");
|
||||
$value=$jokertipps[$key];
|
||||
Log::info("Stored value:".$value);
|
||||
$limit=Season::getCurrent()->maxIdenticalJokertipps();
|
||||
if (intval($value)>=intval($limit)) {
|
||||
Log::info("**JOKERLIMIT REACHED FOR GAMESCORE:".$key);
|
||||
return redirect('/tipps/joker_impossible');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tipp->save();
|
||||
|
||||
|
||||
|
|
@ -158,6 +184,10 @@ class TippsController extends Controller
|
|||
return redirect($tippLink);
|
||||
}
|
||||
|
||||
public static function joker_impossible() {
|
||||
return view('tipps.joker_impossible');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ use App\MyClasses\TimeLogger;
|
|||
class UsersController extends Controller
|
||||
{
|
||||
public function main() {
|
||||
$a=new TimeLogger("UsersController::main()");
|
||||
Log::info($a->getStartMessage());
|
||||
//$a=new TimeLogger("UsersController::main()");
|
||||
//Log::info($a->getStartMessage());
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
$roundname="";
|
||||
|
|
@ -94,8 +94,7 @@ class UsersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
//Log::info($a->getEndMessage());
|
||||
|
||||
return view('main',compact('roundname','display_rounds','message_text_joker','message_text_tipps','nextRoundName','nextRoundLockTime', 'hourDiffToLock'));
|
||||
}
|
||||
|
|
@ -247,6 +246,7 @@ class UsersController extends Controller
|
|||
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;
|
||||
|
|
@ -582,6 +582,10 @@ class UsersController extends Controller
|
|||
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('/');
|
||||
|
|
@ -637,14 +641,16 @@ class UsersController extends Controller
|
|||
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'];
|
||||
|
|
|
|||
44
pfosten/app/MyClasses/TimeLogger.php
Normal file
44
pfosten/app/MyClasses/TimeLogger.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace App\MyClasses;
|
||||
|
||||
/* USAGE IN CLASS
|
||||
|
||||
--START OF FILE
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
--START OF METHOD
|
||||
$a=new TimeLogger("method XXX start");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
--END OF METHOD
|
||||
Log::info($a->getEndMessage());
|
||||
*/
|
||||
|
||||
class TimeLogger
|
||||
{
|
||||
public $startTime;
|
||||
public $pkey;
|
||||
public $functionName;
|
||||
|
||||
public function __construct($_functionName) {
|
||||
$this->startTime = microtime(true);
|
||||
$this->functionName =$_functionName;
|
||||
$this->pkey="".rand(1000,9999);
|
||||
}
|
||||
|
||||
public function getStartMessage() {
|
||||
return "[CLOCK] [".$this->pkey."-".$this->functionName."] [started]";
|
||||
}
|
||||
|
||||
public function getEndMessage() {
|
||||
$time= ( microtime(true) - $this->startTime);
|
||||
$timestr=number_format( $time, 4);
|
||||
|
||||
$retval="[CLOCK] [".$this->pkey."-". $this->functionName."] [ended] [elapsed: ".$timestr."]";
|
||||
if ($time > 1.5) {
|
||||
$retval=$retval." [PERFORMANCE_WARNING]";
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Season;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Game;
|
||||
use App\Season;
|
||||
|
||||
use Log;
|
||||
use DB;
|
||||
|
|
@ -66,6 +66,10 @@ class Round extends Model
|
|||
return $lastCompleteRound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getFirstIncompleteRound($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
|
|
@ -225,6 +229,7 @@ class Round extends Model
|
|||
return $roundnames;
|
||||
}
|
||||
|
||||
|
||||
public static function getLastRoundId($seasonId=-1) {
|
||||
$season= Season::getCurrent();
|
||||
if ($seasonId!=-1) { $season = Season::where('id','=',$seasonId)->first(); }
|
||||
|
|
@ -233,4 +238,9 @@ class Round extends Model
|
|||
return $round->id;
|
||||
}
|
||||
|
||||
|
||||
public static function getSeasonId($round_id) {
|
||||
$round=Round::where('id',$round_id)->first();
|
||||
return $round->season_id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use \App\Leagues\League;
|
|||
class Season extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name','rounds'
|
||||
'name','rounds',"max_identical_jokertipps"
|
||||
];
|
||||
/*
|
||||
public function isActive() {
|
||||
|
|
@ -89,4 +89,32 @@ class Season extends Model
|
|||
return $quota>0;
|
||||
}
|
||||
|
||||
// implemented 2020-01-08 because of needed first round_id of the season
|
||||
public static function getFirstRoundId($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season = Season::getCurrent();
|
||||
} else {
|
||||
$season = Season::where('id','=',$seasonId)->first();
|
||||
}
|
||||
|
||||
if (!$season) return -1;
|
||||
$seasonId=$season->id;
|
||||
|
||||
$firstRound = Round::where('season_id','=',$seasonId)->orderBy('id')->first();
|
||||
return $firstRound->id;
|
||||
}
|
||||
|
||||
public static function maxIdenticalJokertipps($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season = Season::getCurrent();
|
||||
} else {
|
||||
$season = Season::where('id','=',$seasonId)->first();
|
||||
}
|
||||
|
||||
return $season->max_identical_jokertipps;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ class Setting extends Model
|
|||
protected $fillable = [
|
||||
'current_season_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use DB;
|
|||
use Carbon;
|
||||
use Log;
|
||||
use App\MyClasses\TimeLogger;
|
||||
use Symfony\Component\CssSelector\Tests\Node\SelectorNodeTest;
|
||||
|
||||
class Tipp extends Model
|
||||
{
|
||||
|
|
@ -77,6 +78,8 @@ class Tipp extends Model
|
|||
])->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) {
|
||||
$score=0;
|
||||
$tippTendenz = $tipp1 - $tipp2;
|
||||
|
|
@ -788,4 +791,69 @@ class Tipp extends Model
|
|||
return $rankingDisplay2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Creates array of countings of all joker usages
|
||||
public static function getJokerUsageArray($user_id,$round_id) {
|
||||
$seasonId=Round::getSeasonId($round_id);
|
||||
$firstRoundId=Season::getFirstRoundId($seasonId);
|
||||
|
||||
if ($firstRoundId==-1) return 0; // No first round detected.
|
||||
|
||||
$sql= <<<EOD
|
||||
SELECT
|
||||
count(*) as cnt,
|
||||
concat(tipps.score1,':',tipps.score2) as game_result
|
||||
FROM
|
||||
tipps,games,rounds
|
||||
WHERE
|
||||
tipps.user_id=$user_id
|
||||
AND
|
||||
tipps.game_id = games.id
|
||||
AND
|
||||
games.round_id = rounds.id
|
||||
AND
|
||||
joker = true
|
||||
AND
|
||||
rounds.id >= $firstRoundId
|
||||
AND
|
||||
rounds.id <= $round_id
|
||||
GROUP BY 2
|
||||
ORDER BY 1 DESC
|
||||
;
|
||||
EOD;
|
||||
|
||||
$result = DB::select($sql);
|
||||
$joker_usage_array=array();
|
||||
|
||||
foreach ($result as $line) {
|
||||
$key = $line->game_result;
|
||||
$value = $line->cnt;
|
||||
|
||||
$joker_usage_array[$key]=$value;
|
||||
}
|
||||
|
||||
return $joker_usage_array;
|
||||
}
|
||||
|
||||
|
||||
// Creates string from array of countings of all joker usages
|
||||
public static function getJokerUsageString($user_id, $round_id) {
|
||||
$joker_usage_array=Tipp::getJokerUsageArray($user_id,$round_id);
|
||||
//Log::info("RoundId: ".$round_id.", Joker usage array size:".sizeof($joker_usage_array));
|
||||
$str_result="";
|
||||
foreach ($joker_usage_array as $key => $value) {
|
||||
if (strlen($str_result)>0) {
|
||||
$str_result=$str_result.", ";
|
||||
}
|
||||
$str_result=$str_result.$value."x".$key;
|
||||
}
|
||||
|
||||
|
||||
return $str_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class User extends Authenticatable
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'firstname', 'lastname', 'email', 'password', 'gets_reminders', 'iban', 'bankname' , 'blz', 'kontonr'
|
||||
'name', 'firstname', 'lastname', 'email', 'password', 'gets_reminders', 'iban', 'bankname' , 'blz', 'kontonr', 'mobile'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -285,6 +285,7 @@ class User extends Authenticatable
|
|||
$payref = array();
|
||||
foreach($payments as $payment) {
|
||||
if ($payment->paid_date) {
|
||||
//Log::info("(".$payment->user_id.") PAID DATE: ".$payment->paid_date);
|
||||
$payref[$payment->user_id] = 'ok';
|
||||
}
|
||||
}
|
||||
|
|
@ -336,5 +337,4 @@ class User extends Authenticatable
|
|||
return $usernames;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
87553
pfosten/d0274241_2019-12-12.sql
Normal file
87553
pfosten/d0274241_2019-12-12.sql
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMaxIdenticalJokertippsToSeasons extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('seasons', function (Blueprint $table) {
|
||||
$table->integer('max_identical_jokertipps')->default(6);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMobileFieldToUsers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('mobile')->default('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -17,8 +17,13 @@
|
|||
<div>
|
||||
|
||||
@foreach($rounds as $round)
|
||||
|
||||
<div><a class="text lead col-md-12" name="{{$round->id}}" style="font-size: 38px">{{ $round->name }} </a></div>
|
||||
<div>Runde sperrt sich: {{$round->getLockTime()}}</div>
|
||||
<div> </div>
|
||||
<div>Bereits verwendete Joker: {{ App\Tipp::getJokerUsageString($user->id, $round->id) }} </div>
|
||||
<div>Maximale Anzahl gleicher Joker: {{ $max_identical_jokertipps }}</div>
|
||||
<div> </div>
|
||||
|
||||
<span class="col-md-12">
|
||||
|
||||
|
|
@ -37,6 +42,7 @@
|
|||
</tr>
|
||||
|
||||
@foreach($round->games as $game)
|
||||
|
||||
<tr class="table-bordered">
|
||||
<td class="table-bordered" style="width:600px;"><label class="text" href="/games/edit/{{ $game->id }}">{{ $game->team1 }} : {{ $game->team2 }}</label> </td>
|
||||
<td class="table-bordered" style="width:600px;"><label class="text" > {{ App\User::toGermanDate($game->kickoff) }}</label></td>
|
||||
|
|
@ -44,6 +50,9 @@
|
|||
<td class="table-bordered" style="width:350px;">{{ $game->hasResult() ? $game->score1 . ' : ' . $game->score2 : ' ' }}</td>
|
||||
|
||||
<td class="table-bordered" style="width:75px;">
|
||||
|
||||
<!-- <p>tipp_id: { { App\Tipp::getTipp($user->id,$game->id)->id </p> } } -->
|
||||
|
||||
@if(App\Round::hasLockedGame($round->id)==true)
|
||||
<span>{{ App\Tipp::resultString(App\Tipp::getTipp( $user->id,$game->id)->id) }} </span>
|
||||
@else
|
||||
|
|
|
|||
12
pfosten/resources/views/tipps/joker_impossible.blade.php
Executable file
12
pfosten/resources/views/tipps/joker_impossible.blade.php
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="jumbotron text-center">
|
||||
<div class="container">
|
||||
|
||||
<h2>Ungültige Tippeingabe: Joker wurde zu oft verwendet.</h2>
|
||||
<div><a href="/tipps" class="btn btn-primary">Zu den Tipps</a></div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
@endsection
|
||||
|
|
@ -46,7 +46,10 @@
|
|||
<input type="text" class="form-control" id="kontonr" name="kontonr" value="{{ $user->kontonr }}" >
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<label style="float:left; width:150px" for="kontonr">Handynummer:</label>
|
||||
<input type="text" class="form-control" id="mobile" name="mobile" value="{{ $user->mobile }}" >
|
||||
</div>
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@
|
|||
<label style="float:left; width:150px" for="kontonr">Kontonummer:</label>
|
||||
<input type="text" class="form-control" id="kontonr" name="kontonr" value="{{ $user->kontonr }}" >
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="float:left; width:150px" for="kontonr">Handynummer:</label>
|
||||
<input type="text" class="form-control" id="mobile" name="mobile" value="{{ $user->mobile }}" >
|
||||
</div>
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ Route::get('/users/payout_with_iban','UsersController@money_ranking_with_iban');
|
|||
Route::get('/users/payout/{user_id}','UsersController@money_ranking_detail');
|
||||
|
||||
Route::get('/tipps','TippsController@index');
|
||||
Route::get('/tipps/joker_impossible','TippsController@joker_impossible');
|
||||
Route::get('/tipps/edit/{tipp_id}','TippsController@edit');
|
||||
Route::post('/tipps/store','TippsController@store');
|
||||
|
||||
|
|
|
|||
2595
pfosten/vendor/composer/autoload_classmap.php
vendored
2595
pfosten/vendor/composer/autoload_classmap.php
vendored
File diff suppressed because it is too large
Load diff
2595
pfosten/vendor/composer/autoload_static.php
vendored
2595
pfosten/vendor/composer/autoload_static.php
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue