add 2 parts for claculation pp wip

This commit is contained in:
salam committed 2026-10-31 19:22:16 +01:00
1 parent 6d2f4c1052
commit ad45880506
19 files changed
+1403 -1049

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Traits\PlayerProps;
use Filament\Notifications\Notification;
trait CopyData
{
public function copyDevelopment()
{
if ($this->player_on_field_counter < 10) {
Notification::make()->title('Needs a calculation first ')
->info()
->send();
return;
}
$copystring = "Part 1\n";
foreach ($this->calculationVariables as $k => $part) {
foreach ($part as $row) {
if ($copystring == '') {
$keys = array_keys($row);
$copystring .= implode(';', $keys)."\n";
}
$copystring .= implode(';', $row)."\n";
}
if ($k == 0) {
$copystring .= "\nPart 2\n";
}
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
Notification::make()
->title('Calculation variables copied')
->success()
->send();
}
public function copyResult()
{
if ($this->player_on_field_counter < 10) {
Notification::make()->title('Needs a calculation first ')
->info()
->send();
return;
}
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'crd', 'snt', 'tsh', 'wfl'];
$copystring = implode(';', $header)."\n";
foreach ($this->players as $row) {
$tmp = [];
$tmp[] = $row['name'];
$tmp[] = $row['foot'];
$tmp[] = $row['tot_evt'];
$tmp[] = $row['ave_min'];
if ($row['pos']) {
$tmp[] = $row['pos'];
} else {
$tmp[] = $row['pos_ori'];
}
$tmp[] = $row['active'];
$tmp[] = $row['gls'];
$tmp[] = $row['fls'];
$tmp[] = $row['ofs'];
$tmp[] = $row['crd'];
$tmp[] = $row['snt'];
$tmp[] = $row['tsh'];
$tmp[] = $row['wfl'];
$copystring .= implode(';', $tmp)."\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
Notification::make()
->title('Results copied')
->success()
->send();
}
}