pdf nutzwerte wip

This commit is contained in:
salam committed 2025-11-10 15:41:59 +01:00
1 parent 054654fb9c
commit 53cdc0413e
7 files changed
+74 -21

No files matched your search

@@ -8,6 +8,7 @@ use App\Models\ProjektMerkmale;
use App\Models\ProjektMethode;
use App\Models\ProjektObjekte;
use App\Models\ProjektObjekteImDetail;
use DB;
class ZuUndAbschlaege
{
@@ -42,24 +43,57 @@ class ZuUndAbschlaege
foreach ($objekte as $objekt) {
$detail = ProjektObjekteImDetail::where('projekt_objekte_id', $objekt->id)->get();
// $detail = ProjektObjekteImDetail::join('projekt_methodes', 'projekt_objekte_im_details.raumart', '=', 'projekt_methodes.name')
// ->where('projekt_methodes.projekte_id', $projekte_id)
// ->where('projekt_objekte_im_details.projekt_objekte_id', $objekt->id)
// ->get();
// dd($detail);
$detail = DB::table('projekt_objekte_im_details')
->join('projekt_methodes', 'projekt_objekte_im_details.raumart', '=', 'projekt_methodes.raumart')
->select(
'projekt_objekte_im_details.geschoss',
'projekt_objekte_im_details.raumart',
'projekt_objekte_im_details.faktor',
'projekt_objekte_im_details.flaeche',
'projekt_objekte_im_details.nutzwert',
)
->where('projekt_methodes.methode_id', 1)
->where('projekt_methodes.projekte_id', $projekte_id)
->where('projekt_objekte_im_details.projekt_objekte_id', $objekt->id)
->get();
$flaeche = $detail->sum('flaeche');
$geschoss = $detail->first()->geschoss;
$html .= '<tr>';
$html .= Html::td($objekt['top_nummer'], 'left bl br bb');
$html .= Html::td($objekt['top_nummer'], 'center bl br bb');
$html .= Html::td($geschoss, 'center br bb');
$html .= Html::td($objekt['type'], 'wp20 br bb');
// Nutzfläache
$html .= Html::td(Format::dezimal($flaeche, 2).' m&sup2;', 'center br bb');
$html .= Html::td(Format::dezimal($flaeche, 2).' m&sup2;', 'center br bb w30');
// Loggia
// $loggia = Raumalles::loggia($id);
// $gesnutzfl = $loggia + $objekt->qm_m1;
// $loggia = $loggia != 0 ? $loggia : '';
// $html .= Html::td($loggia, 'right br bb');
// // Gesammtnutzfläche = Nutzfläache + Loggia
// $html .= Html::td(Format::numeric($gesnutzfl, 2), 'right br bb');
// dd($objekt);
if ($has_loggien) {
$loggien = DB::table('projekt_objekte_im_details')
->join('projekt_methodes', 'projekt_objekte_im_details.raumart', '=', 'projekt_methodes.raumart')
->select('projekt_objekte_im_details.flaeche')
->where('projekt_methodes.methode_id', 2)
->where('projekt_methodes.projekte_id', $projekte_id)
->where('projekt_objekte_im_details.projekt_objekte_id', $objekt->id)
->get();
$flaeche_loggien = $loggien->sum('flaeche');
if ($flaeche_loggien) {
$html .= Html::td($flaeche_loggien, 'right br bb');
} else {
$html .= Html::td('', 'br bb');
}
$gesammt = $flaeche + $flaeche_loggien;
$html .= Html::td(Format::dezimal($gesammt, 2).' m&sup2;', 'center br bb w30');
}
$nutwert = 0;
foreach ($markmale_codes as $code) {
$nutwert += $objekt[$code];
@@ -32,7 +32,7 @@ class Zusammenstellung
$nutzwert = $objektimdetail->sum('nutzwert');
$tmp = '';
$tmp = 0;
$str = '';
if ($nutzwert > 0) {
@@ -54,6 +54,7 @@ class Zusammenstellung
$html .= Html::td($prozent ?? '', 'center bb br');
$html .= '</tr>';
}
$html .= '<tr>';
$html .= Html::td('', 'head bl bb', 4);
$html .= Html::td(array_sum($summe_nutzwert), 'head center bb');
@@ -57,7 +57,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->columnSpan(2),
TextInput::make('flaeche')
->suffix(new HtmlString(' m&sup2;'))
->rules(['required', 'flaeche' => 'decimal:2'])
->rules(['required'])
->label('Fläche')
->validationMessages([
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
@@ -69,7 +69,6 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->columnSpan(2),
TextInput::make('faktor')
->suffixIcon('phosphor-function')
->rules(['required', 'faktor' => 'decimal:0,2'])
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
})->validationMessages([
@@ -97,10 +96,16 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->extraInputAttributes(['onClick' => 'this.select()'])
->suffixIcon('phosphor-function')
->width('1rem')
->rules(['required', 'faktor' => 'decimal:0,2'])
->rules(['required'])
->searchable()
->afterStateUpdated(function (Component $livewire) {
->afterStateUpdated(function ($record, Component $livewire) {
$object = ProjektObjekteImDetail::find($record['id']);
$object->nutzwert = round($object->faktor * $object->flaeche, 2);
$object->save();
$livewire->dispatch('refreshProjektObjekteImDetail');
})->validationMessages([
'required' => 'Die Eingabe eines Faktors ist erforderlich.',
'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
@@ -113,11 +118,17 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->suffix(new HtmlString(' m&sup2;'))
->width('2rem')
->alignment('right')
->rules(['required', 'flaeche' => 'decimal:2'])
->rules(['required'])
->label('Fläche')
->searchable()
->afterStateUpdated(function (Component $livewire) {
->afterStateUpdated(function ($record, Component $livewire) {
$object = ProjektObjekteImDetail::find($record['id']);
$object->nutzwert = round($object->faktor * $object->flaeche, 2);
$object->save();
$livewire->dispatch('refreshProjektObjekteImDetail');
})->validationMessages([
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
@@ -131,7 +142,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
SelectFilter::make('top_nummer')
->label('Top Nummer')
->relationship('top_nummer', 'top_nummer', fn (Builder $query) => $query->where('projekte_id', $this->getOwnerRecord()->id))
->searchable(),
->preload(),
SelectFilter::make('geschoss')
->preload()
->options(function (): array {
@@ -143,6 +154,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
return ProjektObjekteImDetail::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('raumart')->orderBy('raumart')->pluck('raumart', 'raumart')->toArray();
}),
])
->deferFilters(false)
->headerActions([
CreateAction::make()
->icon('phosphor-file-plus')
@@ -150,7 +162,8 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
])
->recordActions([
EditAction::make()->iconButton()
->mutateDataUsing(function (array $data): array {
->mutateDataUsing(function ($data): array {
$data['nutzwert'] = round($data['faktor'] * $data['flaeche']);
return $data;