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

+4 -3
View File
@@ -2,17 +2,18 @@
namespace App\Actions\Generate\Gutachten;
use App\Actions\Generate\MakeGutachten;
use App\Actions\Generate\Utilities\Format;
use App\Actions\Generate\Utilities\Html;
use App\Models\ProjektInhaltsverzeichnis;
class Inhalt
{
public static function create()
public static function create($projekte_id)
{
$html = '<div class="header">INHALTSVERZEICHNIS</div>';
$html .= '<table class="inhalt">';
foreach (MakeGutachten::$inhaltesverzeichnis as $inhalt) {
$inhaltesverzeichnis = ProjektInhaltsverzeichnis::where('projekte_id', $projekte_id)->orderBy('sort')->get();
foreach ($inhaltesverzeichnis as $inhalt) {
if ($inhalt->ueberschrift_anzeigen) {
$html .= '<tr>';
$html .= Html::td(Format::index($inhalt->ordnungszahl));
@@ -2,23 +2,25 @@
namespace App\Actions\Generate\Gutachten;
use App\Utilities\Html;
use Illuminate\Support\Facades\DB;
use App\Actions\Generate\Utilities\Html;
use App\Models\OrientierungZuAbschlaege;
class Paragraph6Tabelle
{
public static function load($projekts_id)
public static function load($projekte_id)
{
$data = DB::table('raumorientierung')
->join('raumalles', 'raumorientierung.id', '=', 'raumalles.raumorientierung_id')
->join('orientierungs', 'raumorientierung.orientierungs_id', '=', 'orientierungs.id')
->select('raumorientierung.top_nr', 'raumorientierung.type', 'raumalles.geschoss', 'orientierungs.name')
->where('raumorientierung.projekts_id', $projekts_id)
->whereIn('raumalles.methodes_id', [1, 5, 6, 9])
->groupBy('raumorientierung.id')
->orderBy('raumalles.methodes_id', 'ASC')
->orderBy('raumorientierung.top_nr', 'ASC')
->get();
// $data = DB::table('raumorientierung')
// ->join('raumalles', 'raumorientierung.id', '=', 'raumalles.raumorientierung_id')
// ->join('orientierungs', 'raumorientierung.orientierungs_id', '=', 'orientierungs.id')
// ->select('raumorientierung.top_nr', 'raumorientierung.type', 'raumalles.geschoss', 'orientierungs.name')
// ->where('raumorientierung.projekts_id', $projekts_id)
// ->whereIn('raumalles.methodes_id', [1, 5, 6, 9])
// ->groupBy('raumorientierung.id')
// ->orderBy('raumalles.methodes_id', 'ASC')
// ->orderBy('raumorientierung.top_nr', 'ASC')
// ->get();
$data = OrientierungZuAbschlaege::with('orientierung')->where('projekte_id', $projekte_id)->get();
$html = '<table class="table-striped bl bt m20">';
@@ -29,12 +31,15 @@ class Paragraph6Tabelle
$html .= Html::td('Typ', 'head center br bb');
$html .= '</tr>';
foreach ($data as $value) {
// dd($value);
$objekt = Raeumealle::where('projekte_id', $projekte_id)->where('top_nummer', $value->top_nummer)->pluck('geschoss', 'type');
$html .= '<tr>';
$html .= Html::td($value->top_nr, 'center br bb');
$html .= Html::td($value->top_nummer, 'center br bb');
$html .= Html::td($value->geschoss, 'center br bb');
$html .= Html::td(($value->name == 'Ohne Zuordnung') ? '' : $value->name, 'center br bb');
$html .= Html::td($value->type, 'center br bb');
$html .= Html::td($value->orientierung->name, 'center br bb');
// $html .= Html::td($value->type, 'center br bb');
$html .= '</tr>';
}
$html .= '</table>';
@@ -2,12 +2,10 @@
namespace App\Actions\Generate\Gutachten;
use App\Actions\Generate\MakeGutachten;
class Platzhalter
{
public static function replace($standardtext)
public static function replace($platzhalter, $standardtext)
{
return str_replace(array_keys(MakeGutachten::$platzhalter), array_values(MakeGutachten::$platzhalter), $standardtext);
return str_replace(array_keys($platzhalter), array_values($platzhalter), $standardtext);
}
}
+16 -19
View File
@@ -23,29 +23,20 @@ use Mpdf\Mpdf;
class MakeGutachten
{
public static $inhaltesverzeichnis;
public static $projekt;
public static $gutachter;
public static $auftraggeber;
public static $platzhalter = [];
public static function generate($filepath, $projekte_id)
{
self::$inhaltesverzeichnis = ProjektInhaltsverzeichnis::where('projekte_id', $projekte_id)->where('part', 1)->orderBy('sort')->get();
self::$projekt = Projekte::where('id', $projekte_id)->first();
self::$gutachter = Gutachter::where('id', self::$projekt->gutachter_id)->first();
self::$auftraggeber = Auftraggeber::where('id', self::$projekt->auftraggeber_id)->first();
self::$platzhalter = ProjektPlatzhalter::where('projekte_id', $projekte_id)->pluck('platzhaltertext', 'platzhalter')->toArray();
$mpdf = new Mpdf(
[
'debug' => true,
@@ -68,36 +59,42 @@ class MakeGutachten
$mpdf->SetCreator('nutzwerte.at');
$mpdf->SetAuthor(self::$gutachter->title.' '.self::$gutachter->gender.' '.self::$gutachter->name);
foreach (self::$inhaltesverzeichnis as $inhalt) {
$inhaltesverzeichnis = ProjektInhaltsverzeichnis::where('projekte_id', $projekte_id)->where('part', 1)->orderBy('sort')->get();
$platzhalter = ProjektPlatzhalter::where('projekte_id', $projekte_id)->pluck('platzhaltertext', 'platzhalter')->toArray();
foreach ($inhaltesverzeichnis as $inhalt) {
if ($inhalt->neue_seite) {
$mpdf->AddPage();
}
if ($inhalt->textblock) {
$textblock = Platzhalter::replace($inhalt->textblock);
$textblock = Platzhalter::replace($platzhalter, $inhalt->textblock);
$textblock = Format::fix_str($textblock);
}
if ($inhalt->name == 'DECKBLATT') {
$html = Deckblatt::create($textblock);
} elseif ($inhalt->name == 'INHALTSVERZEICHNIS') {
$html = Inhalt::create();
$html = Inhalt::create($projekte_id);
} else {
$html = Ueberschrift::create($inhalt);
switch ($inhalt->tabellen_id) {
case '8':
$str = RichContentRenderer::make(MakeGutachten::$auftraggeber->referenz_formatting)->toHtml();
$html .= Format::fix_str($str);
break;
}
if ($inhalt->textblock) {
$html .= $textblock;
}
switch ($inhalt->tabellen_id) {
case '3':
$html .= Paragraph6Tabelle::load($projekte_id);
break;
case '8':
$str = RichContentRenderer::make(MakeGutachten::$auftraggeber->referenz_formatting)->toHtml();
$html .= Format::fix_str($str);
break;
}
}
if ($inhalt->seitenzahl_anzeige == 1) {
@@ -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([
+6 -1
View File
@@ -18,7 +18,12 @@ class Allgemeinflaechen extends Model
parent::boot();
self::updated(function ($model) {
Projekte::where('id', $model['projekte_id'])->update(['evaluation_gutachten' => false]);
Projekte::where('id', $model['projekte_id'])->update([
'evaluation_gutachten' => false,
'pdf_nutzwerte_status' => false,
'pdf_gutachten_status' => false,
'excel_nutzwerte_status' => false,
]);
});
}
}
+20 -1
View File
@@ -11,7 +11,9 @@ class OrientierungZuAbschlaege extends Model
'orientierung_id',
'nicht_in_orientierung',
'top_nummer',
'type',
'raumart',
'nutzwert',
'a',
'b',
'c',
@@ -29,10 +31,27 @@ class OrientierungZuAbschlaege extends Model
parent::boot();
self::updated(function ($model) {
Projekte::where('id', $model['projekte_id'])->update(['evaluation_gutachten' => false]);
Projekte::where('id', $model['projekte_id'])->update([
'evaluation_gutachten' => false,
'pdf_nutzwerte_status' => false,
'pdf_gutachten_status' => false,
'excel_nutzwerte_status' => false,
]);
});
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'nicht_in_orientierung' => 'boolean',
];
}
public function orientierung()
{
return $this->hasOne(Orientierung::class, 'id', 'orientierung_id');
+6 -1
View File
@@ -19,7 +19,12 @@ class ProjektMethode extends Model
parent::boot();
self::updated(function ($model) {
Projekte::where('id', $model['projekte_id'])->update(['evaluation_gutachten' => false]);
Projekte::where('id', $model['projekte_id'])->update([
'evaluation_gutachten' => false,
'pdf_nutzwerte_status' => false,
'pdf_gutachten_status' => false,
'excel_nutzwerte_status' => false,
]);
});
}
+1
View File
@@ -35,6 +35,7 @@ class Projekte extends Model
'pdf_nutzwerte_status' => 'boolean',
'pdf_gutachten_status' => 'boolean',
'excel_nutzwerte_status' => 'boolean',
'evaluation_gutachten' => 'boolean',
];
}
+7 -1
View File
@@ -14,6 +14,7 @@ class Raeumealle extends Model
'raumart',
'faktor',
'flaeche',
'nutzwert',
];
public static function boot()
@@ -21,7 +22,12 @@ class Raeumealle extends Model
parent::boot();
self::updated(function ($model) {
Projekte::where('id', $model['projekte_id'])->update(['evaluation_gutachten' => false]);
Projekte::where('id', $model['projekte_id'])->update([
'evaluation_gutachten' => false,
'pdf_nutzwerte_status' => false,
'pdf_gutachten_status' => false,
'excel_nutzwerte_status' => false,
]);
});
}
}