nutzwert in tabelle rauemall und orientierung

This commit is contained in:
salam committed 2025-10-22 19:16:10 +02:00
1 parent fe03a71735
commit 5583bed563
24 files changed
+726 -526

No files matched your search

@@ -64,7 +64,7 @@ class EditProjekte extends EditRecord
->modalDescription('Bitte laden sie Ihr Konto auf')
->modalSubmitActionLabel('Konto aufladen'),
/**
* GUTACHTEN
* EVALUATE
*/
Action::make('evaluate_gutachten')
->hidden(fn ($record): bool => $record->bezahlt_am && ! $record->evaluation_gutachten ? false : true)
@@ -75,86 +75,62 @@ class EditProjekte extends EditRecord
GutachtenValidation::controll($record);
$this->record->refresh();
}),
ActionGroup::make([
Action::make('gutachten')
->disabled(fn ($record): bool => ! $record->pdf_gutachten_status)
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->color(fn ($record): string => match ($record->pdf_gutachten_status) {
1 => 'primary',
default => 'gray',
})
->label('Öffnen')
->icon('icon-pdf')
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'file']))
->openUrlInNewTab(),
Action::make('make_gutachten')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->color(fn ($record): string => match ($record->evaluation_gutachten) {
1 => 'primary',
default => 'gray',
})
->disabled(fn ($record): bool => $record->evaluation_gutachten ? false : true)
->label('Berechnen')
->icon('phosphor-calculator')
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'new']))
->openUrlInNewTab(),
])->label('Gutachten')
->icon('heroicon-m-ellipsis-vertical')
->button()
->color('primary'),
/**
* GUTACHTEN
*/
Action::make('gutachten')
->hidden(fn ($record): bool => (! $record->bezahlt_am || ! $record->pdf_gutachten_status) ? true : false)
->color('primary')
->label('Gutachten')
->icon('icon-pdf')
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'file']))
->openUrlInNewTab(),
Action::make('make_gutachten')
->hidden(fn ($record): bool => (! $record->bezahlt_am || $record->pdf_gutachten_status || ! $record->evaluation_gutachten) ? true : false)
->label('Gutachten')
->icon('phosphor-calculator')
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'new']))
->openUrlInNewTab(),
/**
* NUTZWERTE
*/
ActionGroup::make([
Action::make('nutzwerte')
->disabled(fn ($record): bool => ! $record->pdf_nutzwerte_status)
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->color(fn ($record): string => match ($record->pdf_gutachten_status) {
1 => 'primary',
default => 'gray',
})
->label('Öffnen')
->icon('icon-pdf')
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'file']))
->openUrlInNewTab(),
Action::make('make_nutzwerte')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->disabled(fn ($record): bool => $record->evaluation_gutachten ? false : true)
->label('Berechnen')
->icon('phosphor-calculator')
->color(fn ($record): string => match ($record->evaluation_gutachten) {
1 => 'primary',
default => 'gray',
})
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'new']))
->openUrlInNewTab(),
])->label('Nutzwerte')
->icon('heroicon-m-ellipsis-vertical')
->button()
->color('warning'),
Action::make('nutzwerte')
->hidden(fn ($record): bool => (! $record->bezahlt_am || ! $record->pdf_nutzwerte_status) ? true : false)
->color('primary')
->label('Nutzwerte')
->icon('icon-pdf')
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'file']))
->openUrlInNewTab(),
Action::make('make_nutzwerte')
->hidden(fn ($record): bool => (! $record->bezahlt_am || $record->pdf_nutzwerte_status || ! $record->evaluation_gutachten) ? true : false)
->label('Nutzwerte')
->icon('phosphor-calculator')
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'new']))
->openUrlInNewTab(),
/**
* EXCEL
*/
ActionGroup::make([
Action::make('excel-nutzflaeche-nutzwerte')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->disabled(fn ($record): bool => $record->evaluation_gutachten ? false : true)
->label('Nutzfläche & Nutzwerte')
->icon('icon-excel')
->url(fn ($record) => route('excel.download', ['record' => $record, 'mode' => 'file']))
->hidden(fn ($record): bool => (! $record->bezahlt_am || ! $record->evaluation_gutachten) ? true : false)
->openUrlInNewTab(),
Action::make('excel-nutzflaechen-aufstellung')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->disabled(fn ($record): bool => $record->evaluation_gutachten ? false : true)
->label('Nutzflächen Aufstellung')
->icon('icon-excel')
->url(fn ($record) => route('excel.download', ['record' => $record, 'mode' => 'file']))
->hidden(fn ($record): bool => (! $record->bezahlt_am || ! $record->evaluation_gutachten) ? true : false)
->openUrlInNewTab(),
])->label('Spreadsheet')
->icon('heroicon-m-ellipsis-vertical')
->icon('icon-excel')
->button()
->color('info'),
DeleteAction::make(),
DeleteAction::make()->icon('heroicon-o-trash'),
];
}
@@ -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);
}
}
@@ -26,6 +26,7 @@ use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\Schema;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
@@ -219,6 +220,13 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
'1' => 'phosphor-file-plus',
default => ''
}),
IconColumn::make('ueberschrift_anzeigen')
->label('')
->tooltip('Überschrift anzeigen')
->icon(fn (string $state): Heroicon => match ($state) {
'1' => Heroicon::OutlinedEye,
'0' => Heroicon::OutlinedEyeSlash,
}),
TextColumn::make('name')
->wrap()
->weight(fn ($record): FontWeight => match ($record->ueberschrift_anzeigen) {
@@ -115,7 +115,7 @@ class RaeumeallesRelationManager extends RelationManager
]),
TextColumn::make('nutzwert')
->alignCenter()
->default(fn ($record): ?int => round($record->faktor * $record->flaeche))
->summarize(Sum::make()->label('Gesammt'))
->weight(FontWeight::ExtraBold),
])
->filters([
@@ -154,9 +154,14 @@ class RaeumeallesRelationManager extends RelationManager
]),
])
->recordActions([
EditAction::make()->iconButton()->after(function (Component $livewire) {
$livewire->dispatch('refreshRaeumealle');
}),
EditAction::make()->iconButton()
->mutateDataUsing(function (array $data): array {
$data['nutzwert'] = round($data['faktor'] * $data['flaeche']);
return $data;
})->after(function (Component $livewire) {
$livewire->dispatch('refreshRaeumealle');
}),
DeleteAction::make()->iconButton()->after(function (Component $livewire) {
$livewire->dispatch('refreshRaeumealle');
}),
@@ -175,9 +180,13 @@ class RaeumeallesRelationManager extends RelationManager
->icon('phosphor-calculator')
->action(function (Collection $records, array $data): void {
foreach ($records as $record) {
$nutzwert = round($data['faktor'] * $record->flaeche);
Raeumealle::where('id', '=', $record->id)
->update(
['faktor' => $data['faktor']]
[
'faktor' => $data['faktor'],
'nutzwert' => $nutzwert,
]
);
}
})->after(function (Component $livewire) {
@@ -53,6 +53,15 @@ class WidgetMerkmale extends TableWidget
->update(
[$record->code => 0]
);
$res = OrientierungZuAbschlaege::where('projekte_id', '=', $record->projekte_id)->get();
foreach ($res as $value) {
$nutzwert = round($value->a + $value->b + $value->c + $value->d + $value->e + $value->f + $value->g + $value->h + $value->i + $value->j);
OrientierungZuAbschlaege::where('id', '=', $value->id)
->update(
['nutzwert' => $nutzwert]
);
}
}),
])
->headerActions([