bezahlung wip
This commit is contained in:
1 parent
f676ec5a51
commit
48af0fd6c8
9 files changed
+197
-115
No files matched your search
@@ -35,14 +35,12 @@ class KontosTable
|
||||
TextColumn::make('guthaben')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->label('Erstellt')
|
||||
->color('primary')
|
||||
->description('Gutachten')
|
||||
->alignCenter(),
|
||||
TextColumn::make('abgeschlossen')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->label('Kredit')
|
||||
->color('success')
|
||||
->description('Gutachten')
|
||||
->alignCenter(),
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Filament\Resources\Projektes\Pages;
|
||||
|
||||
use App\Filament\Resources\Projektes\ProjekteResource;
|
||||
use App\Models\Konto;
|
||||
use App\Models\Projekte;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProjekte extends EditRecord
|
||||
@@ -15,48 +18,109 @@ class EditProjekte extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('gutachten')
|
||||
->disabled(fn ($record): bool => ! $record->pdf_gutachten_status)
|
||||
->color(fn ($record): string => match ($record->pdf_gutachten_status) {
|
||||
1 => 'info',
|
||||
default => 'gray',
|
||||
})
|
||||
->label('Gutachten')
|
||||
->icon('icon-pdf')
|
||||
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'file']))
|
||||
->openUrlInNewTab(),
|
||||
Action::make('nutzwerte')
|
||||
->color('gray')
|
||||
->label('Nutzwerte')
|
||||
->icon('icon-pdf')
|
||||
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'file']))
|
||||
->openUrlInNewTab(),
|
||||
Action::make('excel')
|
||||
->color('gray')
|
||||
->label('Nutzdaten')
|
||||
->icon('icon-excel')
|
||||
->url(fn ($record) => route('excel.download', ['record' => $record, 'mode' => 'file']))
|
||||
->openUrlInNewTab(),
|
||||
/**
|
||||
* FREISCHALTEN
|
||||
* auth()->user()->konto->guthaben
|
||||
*/
|
||||
Action::make('freischalten')
|
||||
->hidden(fn ($record): bool => $record->bezahlt_am ? true : false)
|
||||
->visible(fn (): bool => auth()->user()->konto->guthaben)
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Gutachten freischalten?')
|
||||
->tooltip('Von Ihrem Guthaben wird ein Punkt abgezogen.')
|
||||
->modalIcon('phosphor-coins')
|
||||
->modalDescription('Von Ihrem Guthaben wird ein Punkt abgezogen.')
|
||||
->modalSubmitActionLabel('Bezahlen')
|
||||
->action(function ($record) {
|
||||
if (Konto::where('id', $record['konto_id'])->where('guthaben', '>', 0)->get()) {
|
||||
Konto::where('id', $record['konto_id'])->decrement('guthaben', 1);
|
||||
Projekte::where('id', $record['id'])->update(['bezahlt_am' => \Carbon\Carbon::now()]);
|
||||
|
||||
$this->record->refresh();
|
||||
|
||||
Notification::make()
|
||||
->title('Gutachten freischaltet')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
Action::make('bezahlen')
|
||||
->color('danger')
|
||||
->hidden(fn ($record): bool => $record->bezahlt_am ? true : false)
|
||||
->visible(fn (): bool => ! auth()->user()->konto->guthaben)
|
||||
->label('Konto laden')
|
||||
->tooltip('Konto laden um Gutachten freizuschalten.')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Kein Guthaben')
|
||||
->modalIcon('heroicon-o-exclamation-triangle')
|
||||
->modalDescription('Bitte laden sie Ihr Konto auf')
|
||||
->modalSubmitActionLabel('Konto aufladen'),
|
||||
/**
|
||||
* GUTACHTEN
|
||||
*/
|
||||
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 => 'info',
|
||||
default => 'gray',
|
||||
})
|
||||
->label('Herunterladen')
|
||||
->icon('icon-pdf')
|
||||
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'file']))
|
||||
->openUrlInNewTab(),
|
||||
Action::make('make_gutachten')
|
||||
->label('Gutachten Erstellen')
|
||||
->icon('heroicon-o-cog-8-tooth')
|
||||
->url(fn ($record) => route('standard.download', ['record' => $record, 'mode' => 'new']))
|
||||
->openUrlInNewTab(),
|
||||
Action::make('make_nutzwerte')
|
||||
->label('Nutzwerte Erstellen')
|
||||
->icon('heroicon-o-cog-8-tooth')
|
||||
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'new']))
|
||||
->openUrlInNewTab(),
|
||||
Action::make('make_excel')
|
||||
->label('Datenblatt Erstellen')
|
||||
->icon('heroicon-o-cog-8-tooth')
|
||||
->url(fn ($record) => route('excel.download', ['record' => $record, 'mode' => 'new']))
|
||||
->openUrlInNewTab(),
|
||||
DeleteAction::make()->label('Projekt löschen'),
|
||||
])->label('Berechnen')
|
||||
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
|
||||
->label('Neu 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'),
|
||||
/**
|
||||
* 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 => 'info',
|
||||
default => 'gray',
|
||||
})
|
||||
->label('Herunterladen')
|
||||
->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)
|
||||
->label('Neu Berechnen')
|
||||
->icon('phosphor-calculator')
|
||||
->url(fn ($record) => route('nutzwerte.download', ['record' => $record, 'mode' => 'new']))
|
||||
->openUrlInNewTab(),
|
||||
])->label('Nutzwerte')
|
||||
->icon('heroicon-m-ellipsis-vertical')
|
||||
->button()
|
||||
->color('primary'),
|
||||
/**
|
||||
* EXCEL
|
||||
*/
|
||||
ActionGroup::make([
|
||||
Action::make('excel')
|
||||
->hidden(fn ($record): bool => $record->bezahlt_am ? false : true)
|
||||
->color('gray')
|
||||
->label('Excel Spreadsheet')
|
||||
->icon('icon-excel')
|
||||
->url(fn ($record) => route('excel.download', ['record' => $record, 'mode' => 'file']))
|
||||
->openUrlInNewTab(),
|
||||
])->label('Nutzdaten')
|
||||
->icon('heroicon-m-ellipsis-vertical')
|
||||
->button()
|
||||
->color('primary'),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user