import new

This commit is contained in:
salam committed 2026-04-15 15:59:56 +02:00
1 parent df55380236
commit 228927274d
12 files changed
+272 -207

No files matched your search

@@ -3,25 +3,17 @@
namespace App\Filament\Resources\Projektes\Pages;
use App\Actions\Validation\GutachtenValidation;
use App\Filament\Imports\ProjektAllgemeinflaechenImporter;
use App\Filament\Imports\ProjektObjekteImDetailImporter;
use App\Filament\Resources\Projektes\ProjekteResource;
use App\Models\Konto;
use App\Models\ProjektAllgemeinflaechen;
use App\Models\Projekte;
use App\Models\ProjektObjekte;
use App\Traits\HasBackUrl;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\ImportAction;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Textarea;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rules\File;
use Livewire\Attributes\On;
class EditProjekte extends EditRecord
@@ -36,122 +28,6 @@ class EditProjekte extends EditRecord
protected function getHeaderActions(): array
{
return [
/**
* IMPORT
*/
ActionGroup::make([
Action::make('fix_line_endings')
->icon('phosphor-file-text')
->modalIcon('phosphor-file-csv')
->label('Daten direkt hochladen')
->schema([
Radio::make('tabel_mode')
->label('Tabellen Art')
->inline()
->options([
'allgemein' => 'Allgemeinflächen',
'objekte_in_detail' => 'Objekte im Detail',
]),
Textarea::make('upload_data')
->label('Daten hier einfügen')
->extraInputAttributes(['onClick' => 'this.select()'])
->rows(5),
]),
ImportAction::make('import_allgemeinflaechen')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->importer(ProjektAllgemeinflaechenImporter::class)
->csvDelimiter('|')
->modalIcon('phosphor-file-csv')
->modalHeading('Dokument Allgemeinflächen Import')
->modalContent(view('filament.pages.actions.import-allgemeinflaechen'))
->modalContentFooter(view('filament.pages.actions.footer-allgemeinflaechen'))
->label('Allgemeinflächen')
->icon('phosphor-upload')
->extraModalFooterActions([
Action::make('copy')
->tooltip('Kopiert die Spaltenname für die erste Zeile')
->color('success')
->label('Spalten Namen')
->action(function ($livewire) {
$livewire->js('window.navigator.clipboard.writeText("Geschoss|Raumart|Fläche");');
Notification::make()
->title('Spaltenname kopiert')
->success()
->send();
}),
Action::make('delete')
->label('Tabelle leeren')
->color('danger')
->requiresConfirmation()
->action(function ($record) {
ProjektAllgemeinflaechen::where('projekte_id', $record->id)->delete();
$this->record->refresh();
Notification::make()
->title('Tabelle geleert')
->success()
->send();
}),
])
->options(function ($record) {
return ['projekte_id' => $record->id];
})
->fileRules([
File::types(['csv', 'txt'])->max(1024),
]),
ImportAction::make('import_objekte')
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
->importer(ProjektObjekteImDetailImporter::class)
->csvDelimiter('|')
->modalIcon('phosphor-file-csv')
->modalHeading('Dokument Objekte im Detail Import')
->modalContent(view('filament.pages.actions.import-objektemitraeumen'))
->modalContentFooter(view('filament.pages.actions.footer-allgemeinflaechen'))
->label('Objekte')
->icon('phosphor-upload')
->extraModalFooterActions([
Action::make('copy')
->tooltip('Kopiert die Spaltenname für die erste Zeile')
->color('success')
->label('Spalten Namen')
->action(function ($livewire) {
$livewire->js('window.navigator.clipboard.writeText("Top Nummer|Geschoss|Raumart|Fläche");');
Notification::make()
->title('Spaltenname kopiert')
->success()
->send();
}),
Action::make('delete')
->tooltip('Löscht alle Objekte für dieses Projekt')
->label('Tabellen leeren')
->color('danger')
->requiresConfirmation()
->action(function ($record) {
ProjektObjekte::where('projekte_id', $record->id)->delete();
$this->record->refresh();
Notification::make()
->title('Tabellen geleert')
->success()
->send();
}),
])
->options(function ($record) {
return ['projekte_id' => $record->id];
})
->fileRules([
File::types(['csv', 'txt'])->max(1024),
]),
])->label('Import')
->icon('phosphor-upload')
->color('info')
->button(),
/**
* FREISCHALTEN
* auth()->user()->konto->guthaben
@@ -2,12 +2,17 @@
namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Filament\Imports\ImportAllgemeinDirect;
use App\Models\ProjektAllgemeinflaechen;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\Summarizers\Sum;
@@ -53,7 +58,7 @@ class ProjektAllgemeinflaechensRelationManager extends RelationManager
public function table(Table $table): Table
{
return $table
->emptyStateDescription('Schalten Sie das Projekt frei und importieren Sie die Daten der Allgemeinflächen.')
->emptyStateDescription('Bitte Projekt zuerst freischalten und dann die Daten der Allgemeinflächen hochladen.')
->striped()
->recordTitleAttribute('geschoss')
->columns([
@@ -75,6 +80,37 @@ class ProjektAllgemeinflaechensRelationManager extends RelationManager
->searchable(),
])
->headerActions([
Action::make('import-text')
->icon('phosphor-upload')
->hidden(fn (): bool => $this->ownerRecord->bezahlt_am ? false : true)
->modalIcon('phosphor-file-csv')
->color('info')
->label('Hochladen')
->modalHeading('Allgemeinflächen hochladen')
->modalDescription(new HtmlString('<b>Objekte werden immer hinzugefügt!</b><br/>Spalten-Separator ist der Strichpunkt ";" oder die Pfeife "|"'))
->schema([
Textarea::make('upload_data')
->required()
->label('Text hier einfügen:')
->extraInputAttributes(['onClick' => 'this.select()'])
->rows(5),
])
->action(function (array $data): void {
ImportAllgemeinDirect::run($data, $this->ownerRecord->id);
}),
Action::make('leeren')
->action(function () {
ProjektAllgemeinflaechen::where('projekte_id', $this->ownerRecord->id)->delete();
})
->icon('phosphor-trash')
->color('danger')
->requiresConfirmation()
->successNotification(
Notification::make()
->success()
->title('Allgemeinflächen gelöscht'),
),
CreateAction::make()
->icon('phosphor-file-plus')
->createAnother(false),
@@ -2,6 +2,7 @@
namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Filament\Imports\ImportObjekteDirect;
use App\Models\ProjektObjekteImDetail;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
@@ -10,6 +11,7 @@ use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
@@ -68,7 +70,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
public function table(Table $table): Table
{
return $table
->emptyStateDescription('Schalten Sie das Projekt frei und importieren Sie die Daten der Objekte.')
->emptyStateDescription('Bitte Projekt freischalten und Daten hochladen.')
->striped()
->recordTitleAttribute('top_nummer')
->columns([
@@ -139,20 +141,40 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
])
->deferFilters(false)
->headerActions([
Action::make('import-text')
->icon('phosphor-upload')
->modalIcon('phosphor-file-csv')
->color('info')
->label('Hochladen')
->modalHeading('Objekte im Detail hochladen')
->modalDescription(new HtmlString('<b>Objekte werden immer hinzugefügt!</b><br/>Spalten-Separator ist der Strichpunkt ";" oder die Pfeife "|"'))
->schema([
Textarea::make('upload_data')
->required()
->label('Text hier einfügen:')
->extraInputAttributes(['onClick' => 'this.select()'])
->rows(5),
])
->action(function (array $data): void {
ImportObjekteDirect::run($data, $this->ownerRecord->id);
}),
CreateAction::make()
->icon('phosphor-file-plus')
->createAnother(false),
Action::make('nutzwerte')
->label('Nutzwerte')
->icon('phosphor-gear')
->icon('phosphor-calculator')
->action(function () {
$res = ProjektObjekteImDetail::with('methode')
->where('projekte_id', $this->getOwnerRecord()->id)
->get();
foreach ($res as $row) {
ProjektObjekteImDetail::where('id', $row->id)
->update(['nutzwert' => $row->flaeche * $row->methode->faktor]);
if ($row->methode?->faktor || null) {
ProjektObjekteImDetail::where('id', $row->id)
->update(['nutzwert' => $row->flaeche * $row->methode->faktor]);
}
}
})->after(function (Component $livewire) {
@@ -58,7 +58,7 @@ class ProjektObjekteRelationManager extends RelationManager
return $table
// ->striped()
->emptyStateDescription('Schalten Sie das Projekt frei und importieren Sie die Daten der Objekte.')
->emptyStateDescription(new HtmlString('Bitte Projekt freischalten und unter <b class="text-primary-600">Objekte im Detail</b> Daten hochladen.'))
->recordTitleAttribute('top_nummer')
->description(new HtmlString('<span class="flex gap-1.5">Orientierungen, Zu- und Abschläge, '.Blade::render('<x-lucide-locate-off class="w-3 h-3 mt-1" />').' Nicht in Orientierung</span>'))
->columns([