nutzwert in tabelle rauemall und orientierung
This commit is contained in:
1 parent
fe03a71735
commit
5583bed563
24 files changed
+726
-526
No files matched your search
+212
-46
@@ -17,6 +17,7 @@ use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Columns\CheckboxColumn;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\Summarizers\Sum;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
@@ -44,6 +45,7 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
return $table
|
||||
// ->striped()
|
||||
->recordTitleAttribute('top_nummer')
|
||||
->description('Objekte "NiO" (Nicht in Orientierung) sind auch ohne "Type"')
|
||||
->columns([
|
||||
TextColumn::make('top_nummer')
|
||||
->alignCenter()
|
||||
@@ -58,7 +60,7 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
'class' => 'bg-gray-50 dark:bg-gray-900',
|
||||
]),
|
||||
CheckboxColumn::make('nicht_in_orientierung')
|
||||
->label('Nicht in Orientierung')
|
||||
->label('NiO')
|
||||
->toggleable()
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
@@ -66,7 +68,11 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
TextColumn::make('raumart')
|
||||
->toggleable()
|
||||
->width('2rem')
|
||||
// ->rules(['required'])
|
||||
->searchable(),
|
||||
TextInputColumn::make('type')
|
||||
->toggleable()
|
||||
->disabled(fn ($record): bool => $record->nicht_in_orientierung)
|
||||
->width('2rem')
|
||||
->searchable(),
|
||||
SelectColumn::make('orientierung_id')
|
||||
->toggleable()
|
||||
@@ -78,37 +84,122 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->preloadOptions()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('a')->label($spalten['a'] ?? '')->hidden(isset($spalten['a']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()
|
||||
TextInputColumn::make('a')->label($spalten['a'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['a']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('a', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('b')->label($spalten['b'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['b']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('b', $state, $record);
|
||||
})->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('c')->label($spalten['c'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['c']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('c', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('d')->label($spalten['d'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['d']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('d', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('e')->label($spalten['e'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['e']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('e', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('f')->label($spalten['f'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['f']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('f', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('g')->label($spalten['g'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['g']) ? false : true)
|
||||
->toggleable()
|
||||
->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('g', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('h')->label($spalten['h'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['h']) ? false : true)
|
||||
->toggleable()->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('h', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('i')->label($spalten['i'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['i']) ? false : true)
|
||||
->toggleable()->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('i', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('j')->label($spalten['j'] ?? '')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->hidden(isset($spalten['j']) ? false : true)
|
||||
->toggleable()->rules(['numeric'])
|
||||
->alignCenter()
|
||||
->beforeStateUpdated(function ($record, $state) {
|
||||
$record['nutzwert'] = $this->sum_nutzwerte('j', $state, $record);
|
||||
})
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('b')->label($spalten['b'] ?? '')->hidden(isset($spalten['b']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('c')->label($spalten['c'] ?? '')->hidden(isset($spalten['c']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('d')->label($spalten['d'] ?? '')->hidden(isset($spalten['d']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('e')->label($spalten['e'] ?? '')->hidden(isset($spalten['e']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('f')->label($spalten['f'] ?? '')->hidden(isset($spalten['f']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('g')->label($spalten['g'] ?? '')->hidden(isset($spalten['g']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('h')->label($spalten['h'] ?? '')->hidden(isset($spalten['h']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('i')->label($spalten['i'] ?? '')->hidden(isset($spalten['i']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextInputColumn::make('j')->label($spalten['j'] ?? '')->hidden(isset($spalten['j']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter()->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
TextColumn::make('nutzwert')
|
||||
->extraHeaderAttributes([
|
||||
'style' => 'position: sticky; right: 0; z-index: 1;',
|
||||
@@ -118,13 +209,12 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
'style' => 'position: sticky; right: 0; z-index: 1;',
|
||||
'class' => 'bg-gray-50 dark:bg-gray-900',
|
||||
])
|
||||
->summarize(Sum::make()->label('Gesammt'))
|
||||
->alignCenter()
|
||||
->default(fn ($record): ?int => round($record->a + $record->b + $record->c + $record->d + $record->e + $record->f + $record->g + $record->h + $record->i + $record->j))
|
||||
->weight(FontWeight::ExtraBold),
|
||||
])
|
||||
->filters([
|
||||
TernaryFilter::make('nicht_in_orientierung')
|
||||
->default(0)
|
||||
->label('Objekte "Nicht in Orientierung" anzeigen'),
|
||||
])
|
||||
->headerActions([
|
||||
@@ -156,9 +246,9 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('raumart')
|
||||
->color('primary')
|
||||
->label('Raumart zuweisen')
|
||||
->schema([
|
||||
TextInput::make('raumart')
|
||||
->label('Name eingeben')
|
||||
->prefixIcon('phosphor-house-simple'),
|
||||
])
|
||||
->icon('phosphor-house-simple')
|
||||
@@ -173,12 +263,32 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->after(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
BulkAction::make('type')
|
||||
->color('primary')
|
||||
->schema([
|
||||
TextInput::make('type')
|
||||
->label('Name eingeben')
|
||||
->prefixIcon('phosphor-align-center-horizontal-simple'),
|
||||
])
|
||||
->icon('phosphor-align-center-horizontal-simple')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->where('nicht_in_orientierung', '=', false)
|
||||
->update(
|
||||
['type' => $data['type']]
|
||||
);
|
||||
}
|
||||
})
|
||||
->after(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshOrientierung');
|
||||
}),
|
||||
BulkAction::make('methode')
|
||||
->color('primary')
|
||||
->label('Orientierung zuweisen')
|
||||
->label('Orientierung')
|
||||
->schema([
|
||||
Select::make('methode_id')
|
||||
->label('Orientierung')
|
||||
->label('Orientierung wählen')
|
||||
->prefixIcon('phosphor-compass')
|
||||
->options(Orientierung::pluck('name', 'id'))
|
||||
->disableOptionWhen(fn (string $value): bool => in_array($value, [2, 11, 24, 33, 36]))
|
||||
@@ -208,7 +318,7 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
'0' => 'Nein',
|
||||
]),
|
||||
])
|
||||
->icon('phosphor-arrow-square-out')
|
||||
->icon('phosphor-check-square')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
@@ -231,9 +341,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('a', $data['a'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['a' => $data['a']]
|
||||
[
|
||||
'a' => $data['a'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -250,9 +364,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('b', $data['b'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['b' => $data['b']]
|
||||
[
|
||||
'b' => $data['b'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -269,9 +387,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('c', $data['c'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['c' => $data['c']]
|
||||
[
|
||||
'c' => $data['c'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -288,9 +410,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('d', $data['d'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['d' => $data['d']]
|
||||
[
|
||||
'd' => $data['d'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -307,9 +433,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('e', $data['e'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['e' => $data['e']]
|
||||
[
|
||||
'e' => $data['e'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -326,9 +456,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('f', $data['f'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['f' => $data['f']]
|
||||
[
|
||||
'f' => $data['f'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -345,9 +479,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('g', $data['g'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['g' => $data['g']]
|
||||
[
|
||||
'g' => $data['g'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -364,9 +502,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('h', $data['h'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['h' => $data['h']]
|
||||
[
|
||||
'h' => $data['h'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -383,9 +525,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('i', $data['i'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['i' => $data['i']]
|
||||
[
|
||||
'i' => $data['i'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -402,9 +548,13 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
->icon('phosphor-math-operations')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
$nutzwert = $this->sum_nutzwerte('j', $data['j'], $record);
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['j' => $data['j']]
|
||||
[
|
||||
'j' => $data['j'],
|
||||
'nutzwert' => $nutzwert,
|
||||
]
|
||||
);
|
||||
}
|
||||
})->after(function (Component $livewire) {
|
||||
@@ -413,4 +563,20 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function sum_nutzwerte($char, $state, $record)
|
||||
{
|
||||
$range = range('a', 'j');
|
||||
|
||||
$sum = 0;
|
||||
foreach ($range as $val) {
|
||||
if ($val == $char) {
|
||||
$sum += $state;
|
||||
} else {
|
||||
$sum += $record[$val];
|
||||
}
|
||||
}
|
||||
|
||||
return round($sum);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user