import new
This commit is contained in:
1 parent
df55380236
commit
228927274d
12 files changed
+272
-207
No files matched your search
+37
-1
@@ -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),
|
||||
|
||||
+26
-4
@@ -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([
|
||||
|
||||
Reference in new issue
Block a user