This commit is contained in:
salam committed 2026-09-12 09:37:39 +02:00
1 parent 86f507e996
commit cd2763cada
1 file changed
+23 -44
+23 -44
View File
@@ -25,6 +25,7 @@ use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Livewire\Attributes\On; use Livewire\Attributes\On;
use Livewire\Component; use Livewire\Component;
@@ -37,6 +38,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
use RestrictsFileUploadsToSchemaComponents; use RestrictsFileUploadsToSchemaComponents;
public array $sourceRecords = []; public array $sourceRecords = [];
public array $calculationVariables = [];
public array $filters = []; public array $filters = [];
@@ -258,6 +260,14 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->size(Size::Small) ->size(Size::Small)
->icon('phosphor-copy') ->icon('phosphor-copy')
->action(fn() => $this->copyResult()), ->action(fn() => $this->copyResult()),
Action::make('copy')
->tooltip('Copy calculation variables')
->hiddenLabel()
->size(Size::Small)
->hidden(fn() => !in_array(Auth::user()->id, [1, 2]))
->color('warning')
->icon('phosphor-copy')
->action(fn() => $this->copyDevelopment()),
]) ])
/** /**
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein * WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
@@ -401,27 +411,20 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->player_on_field_counter = 0; $this->player_on_field_counter = 0;
} }
public function copyDevelopment()
{
$copystring = '';
foreach ($this->calculationVariables as $row) {
$copystring .= implode("\t", $row) . "\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
}
public function copyResult() public function copyResult()
{ {
if ($this->player_on_field_counter < 10) { if ($this->player_on_field_counter < 10) {
return; return;
} }
// "id" => 1218016
// "name" => "Walter Nuñez"
// "pos" => "LW"
// "foot" => "Right"
// "tot_evt" => 2
// "tot_min" => 102
// "ave_min" => 51
// "gls" => 0
// "fls" => 3
// "ofs" => 0
// "crd" => 0
// "snt" => 0
// "tsh" => 0
// "color_evt" => "success"
// "area" => "attack"
// "color_pos" => "warning"
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd']; $header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd'];
$copystring = implode("\t", $header) . "\n"; $copystring = implode("\t", $header) . "\n";
foreach ($this->sourceRecords as $row) { foreach ($this->sourceRecords as $row) {
@@ -504,6 +507,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
"shots_off_target" => 0 "shots_off_target" => 0
*/ */
$results = []; $results = [];
$this->calculationVariables = [];
foreach ($player_totals as $val) { foreach ($player_totals as $val) {
if ($val->details && $val->details->is_active) { if ($val->details && $val->details->is_active) {
@@ -575,8 +579,10 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
// Calcolare la Somma di tutte le AT (colonna G della Tabella) // Calcolare la Somma di tutte le AT (colonna G della Tabella)
// Considerare la ATR calcolata allo Step 1 (colonna I della Tabella) // Considerare la ATR calcolata allo Step 1 (colonna I della Tabella)
// Aspettativa per Player: AP = AT * ATR / TOT AT // Aspettativa per Player: AP = AT * ATR / TOT AT
$results[] = $tmp; $results[] = $tmp;
// for dev copy
$this->calculationVariables = $tmp;
} }
} }
@@ -596,33 +602,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
foreach ($this->sourceRecords as $k => $record) { foreach ($this->sourceRecords as $k => $record) {
foreach ($results as $key => $result) { foreach ($results as $key => $result) {
// "id" => 44691
// "name" => "Maicon"
// "asp_team" => "1.11030870045550"
// "asp_team_riferimento" => 2.8868026211843
// "active" => 0
// "position" => "DC"
// "somma_goals" => 1044
// "somma_minuti" => 1044
// "asp_gioco" => 90
// "asp_statistica_goals" => 0.044
// "asp_teorica_goals" => 67.511
// "asp_statistica_cards" => 0.195
// "asp_teorica_cards" => 67.54875
// "asp_statistica_fouls" => 0.959
// "asp_teorica_fouls" => 67.73975
// "asp_statistica_offsides" => 0.036
// "asp_teorica_offsides" => 67.509
// "asp_statistica_total_shots" => 0.525
// "asp_teorica_total_shots" => 67.63125
// "asp_statistica_shots_on_target" => 0.263
// "asp_teorica_shots_on_target" => 67.56575
// "asp_player_goals" => 0.041110675617421
// "asp_player_cards" => 0.041126169295623
// "asp_player_fouls" => 0.041104958293849
// "asp_player_offsides" => 0.041105354678332
// "asp_player_total_shots" => 0.041028401589513
// "asp_player_shots_on_target" => 0.041094150075013
if ($record['id'] == $result['id']) { if ($record['id'] == $result['id']) {
// dd($result); // dd($result);
$this->sourceRecords[$k]['active'] = $result['active']; $this->sourceRecords[$k]['active'] = $result['active'];