Compare commits
76
Commits
dev-4.3.0
...
d23e6c3914
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d23e6c3914 | ||
|
|
15690b1da9 | ||
|
|
c1c1a4f143 | ||
|
|
5beb2b1d97 | ||
|
|
efee20c16b | ||
|
|
b01288b5e0 | ||
|
|
6a183d6498 | ||
|
|
9c4c28e566 | ||
|
|
a61344395a | ||
|
|
6e4e6b645c | ||
|
|
085299336e | ||
|
|
81912d2433 | ||
|
|
ea57f9400e | ||
|
|
cd51eb3f97 | ||
|
|
1cc84716a1 | ||
|
|
0ee952212b | ||
|
|
e95de52768 | ||
|
|
9581176a0c | ||
|
|
554166803b | ||
|
|
5031d3bde0 | ||
|
|
09f9767eb7 | ||
|
|
b3bbeb5b0b | ||
|
|
c17facf063 | ||
|
|
6b33c1b4dd | ||
|
|
72e0502bb9 | ||
|
|
3b47979265 | ||
|
|
b15573cda6 | ||
|
|
67c4e69f7b | ||
|
|
7f8417e915 | ||
|
|
f8dba18854 | ||
|
|
daff70b4fe | ||
|
|
7919d04dc3 | ||
|
|
cea00f9679 | ||
|
|
a0d26648ee | ||
|
|
e55cdd1988 | ||
|
|
d1ef092bc3 | ||
|
|
78f4d813f9 | ||
|
|
8d6a4041c1 | ||
|
|
29db141b84 | ||
|
|
ab3d526217 | ||
|
|
6c9281516e | ||
|
|
afc91545a9 | ||
|
|
12d98b4d7e | ||
|
|
6c7fe56579 | ||
|
|
e09987f5a8 | ||
|
|
5c514e9ff5 | ||
|
|
bc60461dac | ||
|
|
6848fbd95f | ||
|
|
012ebb6538 | ||
|
|
c1ef1d71ad | ||
|
|
aebb2f9aaa | ||
|
|
cfc7c7eee2 | ||
|
|
1b9384dad1 | ||
|
|
fed54514c8 | ||
|
|
12f05ceb09 | ||
|
|
5f56ef94a6 | ||
|
|
79bb186234 | ||
|
|
a012c16425 | ||
|
|
a8205a4f96 | ||
|
|
dbcebbb2c4 | ||
|
|
63c7b8dfb1 | ||
|
|
e9aa66a860 | ||
|
|
51c4055c47 | ||
|
|
2348663fd8 | ||
|
|
a83cec94ab | ||
|
|
710e27c344 | ||
|
|
83bbd6f7d3 | ||
|
|
28ffbdb696 | ||
|
|
575fb27018 | ||
|
|
fe3429cd4e | ||
|
|
551b592b3b | ||
|
|
6ed0a5b93a | ||
|
|
97fd7cd0da | ||
|
|
f5d7b21671 | ||
|
|
444711b049 | ||
|
|
0a7abb1389 |
@@ -56,6 +56,8 @@ MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
APP_ADMIN_MAIL=
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
|
||||
@@ -23,3 +23,6 @@ Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
/docker-compose.yaml
|
||||
|
||||
# HTML-Report von composer test:coverage
|
||||
/storage/coverage
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# CLAUDE.md
|
||||
|
||||
Laravel 12 + Inertia/Vue, mandantenfähig (custom `tenant`-Scoping über `app('tenant')`, gesetzt in
|
||||
`app/Middleware/IdentifyTenant.php`). PHP 8.5 — Tests/Artisan laufen im Container:
|
||||
`docker exec mareike-mareike-app-1 php artisan test`.
|
||||
|
||||
## Projektkonventionen (verbindlich)
|
||||
|
||||
Die verbindlichen Konventionen (Actions/Request-Command-Response, Controller, Repositories, Models/Resources, Tenant,
|
||||
Routing, Mails) stehen in `.ai/conventions.md` und werden hier eingebunden — **immer beachten**:
|
||||
|
||||
@.ai/conventions.md
|
||||
|
||||
## Bereichs-Dokumentation
|
||||
|
||||
- [Zahlungsmodule](app/EventPaymentModules/CLAUDE.md) — interface-gesteuerte Zahlungsarten (Optionen, Config,
|
||||
Anmelde-Zusammenfassung, GiroCode/Fähigkeits-Interfaces, neues Modul hinzufügen).
|
||||
|
||||
## Umsatzsteuer / Steuerinformationen
|
||||
|
||||
Rechtlich korrekter Begriff ist **Umsatzsteuer (USt)**, nicht MwSt. Ziel: tagesbasierte Anmelde-Rechnungen („Teilnahme
|
||||
Veranstaltung X in Gruppe Y" × Anwesenheitstage × Beitrag/Tag). Grundlage ist gebaut, die Rechnungs-PDF/-berechnung
|
||||
folgt noch.
|
||||
|
||||
### Tenant-Einstellungen (Tab „Steuerinformationen")
|
||||
|
||||
Felder auf `tenants` (Self-Service `TenantData.vue` + verwaltet `TenantEdit.vue`, Partial `TenantTaxInfo.vue`,
|
||||
Controller `TenantTax*` / `ManagedTenantTax*`, Action `UpdateTenantTax`):
|
||||
|
||||
- `tax_liable` (bool) — ob USt-Pflicht besteht.
|
||||
- `vat_rate` (int, %) — USt-Satz, nur relevant wenn `tax_liable` (0–100, geclamped).
|
||||
- `vat_pricing_mode` (Enum `App\Enumerations\VatPricingMode`, natives PHP-Enum: `inclusive` | `add_on`).
|
||||
- `tax_exemption_reason` (FK → `tax_exemption_reasons.slug`, nullable) — Grund wenn **nicht** steuerpflichtig.
|
||||
DB-Default neuer Tenants: `ustg_4_25a` (Jugendhilfe).
|
||||
- `tax_exemption_note` (text, nullable) — Freitext, nur bei Grund `custom` (`requires_note`).
|
||||
|
||||
### Preismodus — **das Kernverhalten**
|
||||
|
||||
Es wird **immer der finale Brutto-Beitrag** pro Anmeldung gespeichert (`EventParticipant.amount`, keine USt-Spalten am
|
||||
Teilnehmer). Der Modus wirkt **nur bei der Preisermittlung im Anmeldeprozess**:
|
||||
|
||||
- **`inclusive`** (Brutto / „zusammenfassen", Supermarkt-Prinzip, Default): der konfigurierte Beitrag **ist** der
|
||||
Endpreis, USt ist bereits enthalten → Preis bleibt gleich; die USt wird erst **auf der Rechnung herausgerechnet**:
|
||||
`USt = brutto × Satz / (100 + Satz)`, `netto = brutto − USt`.
|
||||
- **`add_on`** (Netto / „aufaddieren"): der konfigurierte Beitrag ist netto → Endpreis = `Beitrag × (1 + Satz/100)`. Die
|
||||
USt wird bei der Anmeldung **aufgeschlagen** → Teilnehmer zahlt mehr.
|
||||
|
||||
Umsetzung in `App\Resources\EventResource::calculateAmount()`: nach allen Multiplikatoren (Early-Bird, `pay_per_day`,
|
||||
Geschwister) gilt
|
||||
`if ($event->tax_liable && $event->vat_pricing_mode === VatPricingMode::AddOn->value) $fee->multiply(1 + $event->vat_rate/100);`
|
||||
danach `round(…, 2)`. Bei `inclusive`/nicht steuerpflichtig bleibt der Beitrag unverändert.
|
||||
|
||||
### Event-Snapshot (unveränderlich)
|
||||
|
||||
Bei Event-Anlage (`CreateEventCommand::execute()`) werden `tax_liable`, `vat_rate`, `vat_pricing_mode`,
|
||||
`tax_exemption_reason`, `tax_exemption_note` aus dem Tenant **auf das Event kopiert und dort eingefroren** (Spalten auf
|
||||
`events`). Preisermittlung und spätere Rechnungen lesen vom Event, nicht vom Tenant → spätere Tenant-Änderungen berühren
|
||||
bestehende Events/Rechnungen nicht.
|
||||
|
||||
### Befreiungsgründe (DB-gestützt)
|
||||
|
||||
Tabelle `tax_exemption_reasons`, Model `App\Enumerations\TaxExemptionReason` (Eloquent, `slug` PK; `name`,
|
||||
`invoice_text`, `requires_note`, `sort_order`). `options()` liefert `{value,label,text}` sortiert nach `sort_order`. FK
|
||||
von `tenants` **und** `events`. Seed in Migration `170010`, verfeinert in `170020`. Gründe (in Reihenfolge):
|
||||
`ustg_19` (§ 19 Kleinunternehmer), `ustg_4_24` (§ 4 Nr. 24 Jugendherbergen),
|
||||
`ustg_4_25a` (§ 4 Nr. 25 Buchst. a — Jugendhilfe-Veranstaltungen, Default), `ustg_4_22a` (§ 4 Nr. 22 Buchst. a —
|
||||
Vorträge/Kurse), `custom` (Freitext). Jeder Grund kapselt den Rechnungs-Pflichthinweis nach **§ 14 Abs. 4 Nr. 8 UStG**
|
||||
(`invoice_text`; bei `custom` der Tenant-Freitext via `invoiceText(?note)`). Gemeinnützigkeit allein befreit **nicht** —
|
||||
es braucht immer einen konkreten Rechtsgrund.
|
||||
|
||||
### Noch offen (nächster Schritt)
|
||||
|
||||
Die eigentliche **Rechnung**: tagesbasierte Positionen, USt aus dem gespeicherten Brutto herausrechnen (Satz vom
|
||||
Event-Snapshot); bei Befreiung kein USt-Ausweis, stattdessen der Pflichthinweis des Grundes.
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\CreateTenant;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Tenant;
|
||||
|
||||
class CreateTenantAction
|
||||
{
|
||||
public function __construct(private CreateTenantRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): CreateTenantResponse
|
||||
{
|
||||
$response = new CreateTenantResponse();
|
||||
|
||||
$tenant = Tenant::create([
|
||||
'name' => $this->request->name,
|
||||
'slug' => $this->request->slug,
|
||||
'url' => $this->request->url,
|
||||
'email' => '',
|
||||
'email_finance' => '',
|
||||
'account_name' => '',
|
||||
'account_iban' => '',
|
||||
'account_bic' => '',
|
||||
'city' => '',
|
||||
'postcode' => '',
|
||||
'is_active_local_group' => true,
|
||||
'has_active_instance' => true,
|
||||
]);
|
||||
|
||||
$paymentMethodDefaults = PaymentMethod::defaults();
|
||||
foreach (PaymentMethod::all() as $paymentMethod) {
|
||||
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null, 'configuration' => []];
|
||||
|
||||
AvailablePaymentMethod::create([
|
||||
'tenant' => $tenant->slug,
|
||||
'slug' => $paymentMethod->slug,
|
||||
'name' => $defaults['name'],
|
||||
'description' => $defaults['description'],
|
||||
'active' => true,
|
||||
'configuration' => PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []),
|
||||
]);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Stamm wurde angelegt.';
|
||||
$response->slug = $tenant->slug;
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\CreateTenant;
|
||||
|
||||
class CreateTenantRequest
|
||||
{
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $slug,
|
||||
public string $url,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\CreateTenant;
|
||||
|
||||
class CreateTenantResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
public ?string $slug = null;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\RemovePaymentMethodUsage;
|
||||
|
||||
use App\Mail\EventReportMails\PaymentMethodsExhaustedMail;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class RemovePaymentMethodUsageAction
|
||||
{
|
||||
public function execute(AvailablePaymentMethod $availablePaymentMethod): void
|
||||
{
|
||||
foreach ($availablePaymentMethod->events()->get() as $event) {
|
||||
$event->paymentMethods()->detach($availablePaymentMethod->slug);
|
||||
|
||||
$remainingActive = $event->paymentMethods()->where('active', true)->count();
|
||||
if ($remainingActive === 0 && $event->registration_allowed) {
|
||||
$event->registration_allowed = false;
|
||||
$event->save();
|
||||
|
||||
$recipients = $event->eventManagers;
|
||||
if ($event->costUnit !== null) {
|
||||
$recipients = $recipients->merge($event->costUnit->treasurers);
|
||||
}
|
||||
|
||||
foreach ($recipients->unique('id') as $recipient) {
|
||||
Mail::to($recipient->email)->send(new PaymentMethodsExhaustedMail($event));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\ToggleUserActive;
|
||||
|
||||
class ToggleUserActiveAction
|
||||
{
|
||||
public function __construct(private ToggleUserActiveRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): ToggleUserActiveResponse
|
||||
{
|
||||
$response = new ToggleUserActiveResponse();
|
||||
|
||||
if ($this->request->currentUserId === $this->request->user->id) {
|
||||
$response->message = 'Du kannst dich nicht selbst deaktivieren.';
|
||||
return $response;
|
||||
}
|
||||
|
||||
$this->request->user->update(['active' => !$this->request->user->active]);
|
||||
|
||||
$status = $this->request->user->active ? 'aktiviert' : 'deaktiviert';
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Benutzer*in wurde ' . $status . '.';
|
||||
$response->active = $this->request->user->active;
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\ToggleUserActive;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class ToggleUserActiveRequest
|
||||
{
|
||||
public function __construct(
|
||||
public User $user,
|
||||
public int $currentUserId,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\ToggleUserActive;
|
||||
|
||||
class ToggleUserActiveResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
public ?bool $active = null;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
use App\Domains\Admin\Actions\RemovePaymentMethodUsage\RemovePaymentMethodUsageAction;
|
||||
use App\Models\PaymentMethod;
|
||||
|
||||
class UpdateAvailablePaymentMethodAction
|
||||
{
|
||||
public function __construct(private UpdateAvailablePaymentMethodRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateAvailablePaymentMethodResponse
|
||||
{
|
||||
$response = new UpdateAvailablePaymentMethodResponse();
|
||||
$paymentMethod = $this->request->availablePaymentMethod;
|
||||
$wasActive = $paymentMethod->active;
|
||||
|
||||
// Nur bekannte Options-Keys übernehmen -- das Options-Schema des Zahlungsmoduls ist die Autorität.
|
||||
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $this->request->configuration);
|
||||
|
||||
// Guard: Aktivierung nur erlaubt, wenn alle Pflicht-Optionen befüllt sind.
|
||||
if ($this->request->active && !PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration)) {
|
||||
$response->success = false;
|
||||
$response->message = 'Bitte zuerst alle Pflichtfelder ausfüllen, bevor die Zahlungsmethode aktiviert wird.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$paymentMethod->update([
|
||||
'name' => $this->request->name,
|
||||
'description' => $this->request->description,
|
||||
'active' => $this->request->active,
|
||||
'configuration' => $configuration,
|
||||
]);
|
||||
|
||||
if ($wasActive && !$this->request->active) {
|
||||
(new RemovePaymentMethodUsageAction())->execute($paymentMethod);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Zahlungsmethode wurde gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
|
||||
class UpdateAvailablePaymentMethodRequest
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
public AvailablePaymentMethod $availablePaymentMethod,
|
||||
public string $name,
|
||||
public ?string $description,
|
||||
public bool $active,
|
||||
public array $configuration = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
|
||||
|
||||
class UpdateAvailablePaymentMethodResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||
|
||||
use App\Models\DocumentAsset;
|
||||
|
||||
/**
|
||||
* Legt ein Bild für die Dokumentvorlagen an oder ersetzt es.
|
||||
*
|
||||
* Gespeichert wird der base64-Payload in der Datenbank -- so überlebt das Bild ein Release (das als
|
||||
* `git checkout` alles unter `public/` überschreibt) und wandert mit jedem Dump mit.
|
||||
*/
|
||||
class UpdateDocumentAssetAction
|
||||
{
|
||||
/** Über 2 MB wird die Vorlage träge und das PDF unnötig groß. */
|
||||
private const int MAX_BYTES = 2 * 1024 * 1024;
|
||||
|
||||
/** @var array<string, string> */
|
||||
private const array ALLOWED_MIME_TYPES = [
|
||||
'image/png' => 'png',
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/gif' => 'gif',
|
||||
'image/svg+xml' => 'svg',
|
||||
];
|
||||
|
||||
public function __construct(private readonly UpdateDocumentAssetRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateDocumentAssetResponse
|
||||
{
|
||||
$response = new UpdateDocumentAssetResponse();
|
||||
|
||||
$name = $this->normalizeName($this->request->name);
|
||||
|
||||
if ($name === null) {
|
||||
$response->message = 'Bitte einen Namen aus Kleinbuchstaben, Ziffern, Bindestrich oder Unterstrich angeben.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$asset = DocumentAsset::where('name', $name)->first();
|
||||
$file = $this->request->file;
|
||||
|
||||
if ($file === null && $asset === null) {
|
||||
$response->message = 'Für ein neues Bild wird eine Datei benötigt.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$attributes = ['name' => $name, 'label' => $this->request->label];
|
||||
|
||||
if ($file !== null) {
|
||||
if (!array_key_exists($file->getMimeType(), self::ALLOWED_MIME_TYPES)) {
|
||||
$response->message = 'Nur PNG, JPEG, GIF oder SVG sind zulässig.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ($file->getSize() > self::MAX_BYTES) {
|
||||
$response->message = 'Das Bild darf höchstens 2 MB groß sein.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$attributes['mime'] = $file->getMimeType();
|
||||
$attributes['data'] = base64_encode(file_get_contents($file->getRealPath()));
|
||||
}
|
||||
|
||||
$response->asset = $asset === null
|
||||
? DocumentAsset::create($attributes)
|
||||
: tap($asset)->update($attributes);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Das Bild wurde gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/** Namen sind Slugs, damit `{asset:name}` eindeutig erkennbar bleibt. */
|
||||
private function normalizeName(string $name): ?string
|
||||
{
|
||||
$name = strtolower(trim($name));
|
||||
|
||||
return preg_match('/^[a-z0-9_-]+$/', $name) === 1 ? $name : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
class UpdateDocumentAssetRequest
|
||||
{
|
||||
public function __construct(
|
||||
/** Slug, unter dem das Bild in der Vorlage als `{asset:name}` referenziert wird. */
|
||||
public readonly string $name,
|
||||
public readonly ?string $label = null,
|
||||
public readonly ?UploadedFile $file = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||
|
||||
use App\Models\DocumentAsset;
|
||||
|
||||
class UpdateDocumentAssetResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
|
||||
public ?string $message = null;
|
||||
|
||||
public ?DocumentAsset $asset = null;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||
|
||||
use App\Models\DocumentTemplate;
|
||||
|
||||
/**
|
||||
* Speichert die Blockinhalte einer Dokumentvorlage.
|
||||
*
|
||||
* Es werden nur bereits angelegte, als editierbar markierte Blöcke geschrieben. Neue Blöcke entstehen
|
||||
* nicht über das Formular -- welche Blöcke eine Dokumentart hat, gibt die Vorlage vor (das Layout
|
||||
* verweist mit `{block:...}` auf sie).
|
||||
*/
|
||||
class UpdateDocumentTemplateAction
|
||||
{
|
||||
public function __construct(private readonly UpdateDocumentTemplateRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateDocumentTemplateResponse
|
||||
{
|
||||
$response = new UpdateDocumentTemplateResponse();
|
||||
|
||||
$existing = DocumentTemplate::forType($this->request->documentType);
|
||||
|
||||
// Erst prüfen, dann schreiben -- sonst bliebe bei einem Fehler ein halb gespeicherter Stand übrig.
|
||||
$rejection = $this->rejectBareAssetInStyle();
|
||||
if ($rejection !== null) {
|
||||
$response->message = $rejection;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
foreach ($this->request->blocks as $block => $content) {
|
||||
$template = $existing->get($block);
|
||||
|
||||
if ($template === null || !$template->editable) {
|
||||
$response->skipped[] = $block;
|
||||
continue;
|
||||
}
|
||||
|
||||
$template->update(['content' => (string) $content]);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = $response->skipped === []
|
||||
? 'Die Vorlage wurde gespeichert.'
|
||||
: 'Die Vorlage wurde gespeichert; nicht editierbare Blöcke blieben unverändert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Bild-Platzhalter, der im CSS nicht in `url(...)` steht, expandiert zu einem Data-URI, das
|
||||
* dompdf nicht auslagern kann -- der Parser läuft dann minutenlang und der FPM-Worker stirbt am
|
||||
* Zeitlimit (502). Solches CSS wird gar nicht erst gespeichert.
|
||||
*
|
||||
* @return string|null Fehlermeldung, oder null wenn nichts zu beanstanden ist.
|
||||
*/
|
||||
private function rejectBareAssetInStyle(): ?string
|
||||
{
|
||||
$style = $this->request->blocks[DocumentTemplate::BLOCK_STYLE] ?? null;
|
||||
|
||||
if ($style === null || preg_match('/(?<![("\'])\{asset:([a-z0-9_-]+)}/i', (string) $style, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'Im CSS-Block steht der Bild-Platzhalter {asset:%1$s} direkt im Text. Dort gehört er in url("{asset:%1$s}").',
|
||||
$match[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||
|
||||
class UpdateDocumentTemplateRequest
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $blocks Blockinhalte, adressiert über den Block-Slug.
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $documentType,
|
||||
public readonly array $blocks,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||
|
||||
class UpdateDocumentTemplateResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
|
||||
public ?string $message = null;
|
||||
|
||||
/** @var array<int, string> Blöcke, die nicht gespeichert wurden (unbekannt oder nicht editierbar). */
|
||||
public array $skipped = [];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantContact;
|
||||
|
||||
use App\Support\Text;
|
||||
|
||||
class UpdateTenantContactAction
|
||||
{
|
||||
public function __construct(private UpdateTenantContactRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantContactResponse
|
||||
{
|
||||
$response = new UpdateTenantContactResponse();
|
||||
|
||||
$this->request->tenant->update([
|
||||
'email' => $this->request->email,
|
||||
'email_finance' => $this->request->emailFinance,
|
||||
'invoice_sender_name' => Text::nullIfBlank($this->request->invoiceSenderName),
|
||||
// Leergelassene optionale Felder als NULL, damit sie im Briefkopf sauber wegfallen.
|
||||
'address_1' => Text::nullIfBlank($this->request->address1),
|
||||
'address_2' => Text::nullIfBlank($this->request->address2),
|
||||
'address_3' => Text::nullIfBlank($this->request->address3),
|
||||
'postcode' => $this->request->postcode,
|
||||
'city' => $this->request->city,
|
||||
'phone' => Text::nullIfBlank($this->request->phone),
|
||||
]);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Kontaktdaten wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantContact;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantContactRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public string $email,
|
||||
public string $emailFinance,
|
||||
public string $postcode,
|
||||
public string $city,
|
||||
/** Bezeichnung des Rechnungsstellers; leer bedeutet "Name des Mandanten verwenden". */
|
||||
public ?string $invoiceSenderName = null,
|
||||
/** Straße und Hausnummer -- Pflichtangabe auf Rechnungen nach § 14 Abs. 4 UStG. */
|
||||
public ?string $address1 = null,
|
||||
/** Optionale Zusatzzeile, z.B. "c/o ...". */
|
||||
public ?string $address2 = null,
|
||||
public ?string $address3 = null,
|
||||
public ?string $phone = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantContact;
|
||||
|
||||
class UpdateTenantContactResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGdpr;
|
||||
|
||||
class UpdateTenantGdprAction
|
||||
{
|
||||
public function __construct(private UpdateTenantGdprRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantGdprResponse
|
||||
{
|
||||
$response = new UpdateTenantGdprResponse();
|
||||
|
||||
$this->request->tenant->update([
|
||||
'gdpr_text' => $this->request->gdprText,
|
||||
]);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Datenschutzerklärung wurde gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGdpr;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantGdprRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public string $gdprText,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGdpr;
|
||||
|
||||
class UpdateTenantGdprResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
||||
|
||||
class UpdateTenantGeneralAction
|
||||
{
|
||||
public function __construct(private UpdateTenantGeneralRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantGeneralResponse
|
||||
{
|
||||
$response = new UpdateTenantGeneralResponse();
|
||||
|
||||
$this->request->tenant->update([
|
||||
'name' => $this->request->name,
|
||||
'slug' => $this->request->slug,
|
||||
'url' => $this->request->url,
|
||||
]);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Allgemeine Daten wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantGeneralRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public string $name,
|
||||
public string $slug,
|
||||
public string $url,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
||||
|
||||
class UpdateTenantGeneralResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantImpress;
|
||||
|
||||
class UpdateTenantImpressAction
|
||||
{
|
||||
public function __construct(private UpdateTenantImpressRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantImpressResponse
|
||||
{
|
||||
$response = new UpdateTenantImpressResponse();
|
||||
|
||||
$this->request->tenant->update([
|
||||
'impress_text' => $this->request->impressText,
|
||||
]);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Impressum wurde gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantImpress;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantImpressRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public string $impressText,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantImpress;
|
||||
|
||||
class UpdateTenantImpressResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantPayment;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Scopes\SiteScope;
|
||||
|
||||
class UpdateTenantPaymentAction
|
||||
{
|
||||
public function __construct(private UpdateTenantPaymentRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantPaymentResponse
|
||||
{
|
||||
$response = new UpdateTenantPaymentResponse();
|
||||
|
||||
$this->request->tenant->update([
|
||||
'account_iban' => $this->request->accountIban,
|
||||
'account_bic' => $this->request->accountBic,
|
||||
'account_name' => $this->request->accountName,
|
||||
]);
|
||||
|
||||
$this->syncTransferPaymentConfiguration();
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'IBAN-Informationen wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Überweisungs-Zahlungsart
|
||||
* (Kontoinhaber/IBAN/BIC), damit sie nicht doppelt gepflegt werden müssen. Bestehende weitere
|
||||
* Config-Werte (z.B. Symbol) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter sein, daher
|
||||
* ohne SiteScope explizit auf den Tenant-Slug gefiltert.
|
||||
*/
|
||||
private function syncTransferPaymentConfiguration(): void
|
||||
{
|
||||
$slug = PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION;
|
||||
|
||||
$method = AvailablePaymentMethod::withoutGlobalScope(SiteScope::class)
|
||||
->where('tenant', $this->request->tenant->slug)
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if ($method === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$method->configuration = PaymentMethod::sanitizeConfiguration($slug, array_merge(
|
||||
$method->configuration ?? [],
|
||||
[
|
||||
'account_owner' => $this->request->accountName,
|
||||
'iban' => $this->request->accountIban,
|
||||
'bic' => $this->request->accountBic,
|
||||
],
|
||||
));
|
||||
$method->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantPayment;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantPaymentRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public string $accountIban,
|
||||
public string $accountBic,
|
||||
public string $accountName,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantPayment;
|
||||
|
||||
class UpdateTenantPaymentResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantTax;
|
||||
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Models\Tenant;
|
||||
use App\Support\Text;
|
||||
|
||||
class UpdateTenantTaxAction
|
||||
{
|
||||
public function __construct(private UpdateTenantTaxRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateTenantTaxResponse
|
||||
{
|
||||
$response = new UpdateTenantTaxResponse();
|
||||
|
||||
// Präfixe sind großgeschrieben; null heißt "nicht mitgeschickt" und damit "unverändert".
|
||||
$prefix = Text::nullIfBlank(strtoupper((string) $this->request->invoicePrefix));
|
||||
|
||||
if ($prefix !== null && $this->prefixTakenByAnotherTenant($prefix)) {
|
||||
$response->message = sprintf('Das Rechnungs-Präfix "%s" wird bereits von einem anderen Mandanten genutzt.', $prefix);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ($this->request->taxLiable) {
|
||||
$this->request->tenant->update($this->withInvoiceDetails([
|
||||
'tax_liable' => true,
|
||||
'vat_rate' => $this->clampVatRate($this->request->vatRate),
|
||||
'vat_pricing_mode' => $this->request->vatPricingMode->value,
|
||||
'tax_exemption_reason' => null,
|
||||
'tax_exemption_note' => null,
|
||||
], $prefix));
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Steuerinformationen wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$reason = $this->request->exemptionReason;
|
||||
|
||||
if ($reason === null) {
|
||||
$response->message = 'Bitte einen gültigen Befreiungsgrund auswählen.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$note = trim((string)$this->request->exemptionNote);
|
||||
|
||||
if ($reason->requires_note && $note === '') {
|
||||
$response->message = 'Bitte einen Text für den Befreiungsgrund angeben.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$this->request->tenant->update($this->withInvoiceDetails([
|
||||
'tax_liable' => false,
|
||||
'vat_rate' => 0,
|
||||
'vat_pricing_mode' => VatPricingMode::Inclusive->value,
|
||||
'tax_exemption_reason' => $reason->slug,
|
||||
'tax_exemption_note' => $reason->requires_note ? $note : null,
|
||||
], $prefix));
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Steuerinformationen wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function clampVatRate(int $vatRate): int
|
||||
{
|
||||
return max(0, min(100, $vatRate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ergänzt die Rechnungsstellerangaben. Sie gelten unabhängig davon, ob Steuerpflicht besteht -- eine
|
||||
* Steuernummer gehört auch auf eine steuerfreie Rechnung.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function withInvoiceDetails(array $attributes, ?string $prefix): array
|
||||
{
|
||||
$attributes['tax_number'] = Text::nullIfBlank($this->request->taxNumber);
|
||||
$attributes['vat_id'] = Text::nullIfBlank($this->request->vatId);
|
||||
|
||||
// Nicht mitgeschickt heißt "unverändert", nicht "leeren".
|
||||
if ($prefix !== null) {
|
||||
$attributes['invoice_prefix'] = $prefix;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
private function prefixTakenByAnotherTenant(string $prefix): bool
|
||||
{
|
||||
return Tenant::where('invoice_prefix', $prefix)
|
||||
->where('id', '!=', $this->request->tenant->id)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantTax;
|
||||
|
||||
use App\Enumerations\TaxExemptionReason;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantTaxRequest
|
||||
{
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
public bool $taxLiable,
|
||||
public int $vatRate,
|
||||
public ?TaxExemptionReason $exemptionReason,
|
||||
public ?string $exemptionNote,
|
||||
public VatPricingMode $vatPricingMode,
|
||||
/** Steuernummer bzw. USt-IdNr. -- Pflichtangabe auf Rechnungen (§ 14 Abs. 4 Nr. 2 UStG). */
|
||||
public ?string $taxNumber = null,
|
||||
public ?string $vatId = null,
|
||||
/**
|
||||
* Erster Block der Rechnungsnummer. `null` heißt "unverändert lassen" -- im Self-Service wird das
|
||||
* Feld gar nicht erst mitgeschickt, damit ein bestehender Nummernkreis nicht bricht.
|
||||
*/
|
||||
public ?string $invoicePrefix = null,
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateTenantTax;
|
||||
|
||||
class UpdateTenantTaxResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateUser;
|
||||
|
||||
class UpdateUserAction
|
||||
{
|
||||
public function __construct(private UpdateUserRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): UpdateUserResponse
|
||||
{
|
||||
$response = new UpdateUserResponse();
|
||||
|
||||
$allowedFields = [
|
||||
'firstname', 'lastname', 'nickname', 'email', 'phone', 'birthday',
|
||||
'membership_id', 'address_1', 'address_2', 'postcode', 'city',
|
||||
'eating_habits', 'swimming_permission', 'first_aid_permission',
|
||||
'bank_account_owner', 'bank_account_iban',
|
||||
'medications', 'allergies', 'intolerances',
|
||||
'user_role_local_group',
|
||||
];
|
||||
|
||||
if ($this->request->isLvTenant) {
|
||||
$allowedFields[] = 'local_group';
|
||||
if (!$this->request->isOwnUser) {
|
||||
$allowedFields[] = 'user_role_main';
|
||||
}
|
||||
}
|
||||
|
||||
$data = array_intersect_key($this->request->data, array_flip($allowedFields));
|
||||
$this->request->user->update($data);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Benutzerdaten wurden gespeichert.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateUser;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UpdateUserRequest
|
||||
{
|
||||
public function __construct(
|
||||
public User $user,
|
||||
public array $data,
|
||||
public bool $isOwnUser,
|
||||
public bool $isLvTenant,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Actions\UpdateUser;
|
||||
|
||||
class UpdateUserResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class AdminDashboardController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$inertiaProvider = new InertiaProvider('Admin/Dashboard', []);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\DocumentAsset;
|
||||
use App\Models\DocumentTemplate;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class DocumentAssetDeleteController extends CommonController
|
||||
{
|
||||
public function __invoke(string $name): JsonResponse
|
||||
{
|
||||
$asset = DocumentAsset::where('name', $name)->first();
|
||||
|
||||
// Durchweg 200 mit Status im Body -- wie die übrigen Admin-Endpunkte, damit der Grund im Frontend
|
||||
// ankommt (der Ajax-Helfer verwirft den Body bei Fehler-Statuscodes).
|
||||
if ($asset === null) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Das Bild existiert nicht.']);
|
||||
}
|
||||
|
||||
// Ein noch referenziertes Bild zu löschen würde stillschweigend eine Lücke in jede künftige
|
||||
// Rechnung reißen -- der Platzhalter löst dann zu einem Leerstring auf.
|
||||
if ($this->isReferenced($asset->name)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => sprintf('Das Bild wird noch als {asset:%s} in der Vorlage verwendet.', $asset->name),
|
||||
]);
|
||||
}
|
||||
|
||||
$asset->delete();
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => 'Das Bild wurde gelöscht.']);
|
||||
}
|
||||
|
||||
private function isReferenced(string $name): bool
|
||||
{
|
||||
return DocumentTemplate::query()
|
||||
->where('content', 'like', '%{asset:' . $name . '}%')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateDocumentAsset\UpdateDocumentAssetAction;
|
||||
use App\Domains\Admin\Actions\UpdateDocumentAsset\UpdateDocumentAssetRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DocumentAssetUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateDocumentAssetAction(new UpdateDocumentAssetRequest(
|
||||
name: (string) $request->input('name'),
|
||||
label: $request->input('label'),
|
||||
file: $request->file('file'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
'token' => $response->asset !== null ? '{asset:' . $response->asset->name . '}' : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\DocumentAsset;
|
||||
use App\Models\DocumentTemplate;
|
||||
use App\Models\DocumentTypeCatalog;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DocumentTemplatesGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||
|
||||
if (!DocumentTypeCatalog::has($documentType)) {
|
||||
abort(422, 'Unbekannte Dokumentart.');
|
||||
}
|
||||
|
||||
$blocks = DocumentTemplate::forType($documentType)
|
||||
->values()
|
||||
->map(fn(DocumentTemplate $block): array => [
|
||||
'block' => $block->block,
|
||||
'label' => DocumentTypeCatalog::blockLabel($documentType, $block->block),
|
||||
'content' => (string) $block->content,
|
||||
'editable' => $block->editable,
|
||||
'source' => in_array($block->block, DocumentTypeCatalog::SOURCE_BLOCKS, true),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'documentType' => $documentType,
|
||||
'documentTypes' => DocumentTypeCatalog::options(),
|
||||
'blocks' => $blocks,
|
||||
// Die Bilder gelten für alle Dokumentarten -- sie hängen nicht am Typ.
|
||||
'assets' => DocumentAsset::orderBy('name')->get()->map(fn(DocumentAsset $asset): array => [
|
||||
'name' => $asset->name,
|
||||
'label' => $asset->label,
|
||||
'mime' => $asset->mime,
|
||||
'token' => '{asset:' . $asset->name . '}',
|
||||
'preview' => $asset->toDataUri(),
|
||||
]),
|
||||
'tokenGroups' => DocumentTypeCatalog::tokenGroups($documentType),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Inertia\Response;
|
||||
|
||||
class DocumentTemplatesPageController extends CommonController
|
||||
{
|
||||
public function __invoke(): Response
|
||||
{
|
||||
return new InertiaProvider('Admin/DocumentTemplates', [])->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\DocumentTypeCatalog;
|
||||
use App\Providers\DocumentTemplateRenderProvider;
|
||||
use App\Providers\PdfGenerateAndDownloadProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
/**
|
||||
* Rendert die Vorlage mit Beispieldaten, ohne sie zu speichern -- damit niemand blind HTML editiert.
|
||||
*/
|
||||
class DocumentTemplatesPreviewController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||
|
||||
if (!DocumentTypeCatalog::has($documentType)) {
|
||||
abort(422, 'Unbekannte Dokumentart.');
|
||||
}
|
||||
|
||||
$html = new DocumentTemplateRenderProvider(
|
||||
$documentType,
|
||||
(array) $request->input('blocks', []),
|
||||
)->render(DocumentTypeCatalog::sampleTokens($documentType));
|
||||
|
||||
return response(PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait'), 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="vorschau.pdf"',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateDocumentTemplate\UpdateDocumentTemplateAction;
|
||||
use App\Domains\Admin\Actions\UpdateDocumentTemplate\UpdateDocumentTemplateRequest;
|
||||
use App\Models\DocumentTypeCatalog;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DocumentTemplatesUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||
|
||||
// Die Dokumentart bestimmt, welche Zeilen geschrieben werden -- ungeprüft weitergereicht wäre
|
||||
// sie ein Weg, in beliebige Vorlagen zu schreiben.
|
||||
if (!DocumentTypeCatalog::has($documentType)) {
|
||||
abort(422, 'Unbekannte Dokumentart.');
|
||||
}
|
||||
|
||||
$action = new UpdateDocumentTemplateAction(new UpdateDocumentTemplateRequest(
|
||||
documentType: $documentType,
|
||||
blocks: (array) $request->input('blocks', []),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantContactGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'email' => $tenant->email,
|
||||
'email_finance' => $tenant->email_finance,
|
||||
'invoice_sender_name' => $tenant->invoice_sender_name,
|
||||
// Als Platzhalter im Formular: so heisst der Absender, solange nichts eingetragen ist.
|
||||
'name' => $tenant->name,
|
||||
'phone' => $tenant->phone,
|
||||
'address_1' => $tenant->address_1,
|
||||
'address_2' => $tenant->address_2,
|
||||
'address_3' => $tenant->address_3,
|
||||
'postcode' => $tenant->postcode,
|
||||
'city' => $tenant->city,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/contact',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantContact\UpdateTenantContactAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantContact\UpdateTenantContactRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantContactUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantContactAction(new UpdateTenantContactRequest(
|
||||
tenant: $tenant,
|
||||
email: $request->input('email'),
|
||||
emailFinance: $request->input('email_finance'),
|
||||
postcode: $request->input('postcode'),
|
||||
city: $request->input('city'),
|
||||
invoiceSenderName: $request->input('invoice_sender_name'),
|
||||
address1: $request->input('address_1'),
|
||||
address2: $request->input('address_2'),
|
||||
address3: $request->input('address_3'),
|
||||
phone: $request->input('phone'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantGdprGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'gdpr_text' => $tenant->gdpr_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/gdpr',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantGdprUpdateController extends CommonController
|
||||
{
|
||||
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantGdprAction(new UpdateTenantGdprRequest(
|
||||
tenant: $tenant,
|
||||
gdprText: $request->input('gdpr_text'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantImpressGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'impress_text' => $tenant->impress_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/impress',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantImpressUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantImpressAction(new UpdateTenantImpressRequest(
|
||||
tenant: $tenant,
|
||||
impressText: $request->input('impress_text'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantPaymentGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'account_iban' => $tenant->account_iban,
|
||||
'account_bic' => $tenant->account_bic,
|
||||
'account_name' => $tenant->account_name,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/payment',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantPayment\UpdateTenantPaymentAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantPayment\UpdateTenantPaymentRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantPaymentUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantPaymentAction(new UpdateTenantPaymentRequest(
|
||||
tenant: $tenant,
|
||||
accountIban: $request->input('account_iban'),
|
||||
accountBic: $request->input('account_bic'),
|
||||
accountName: $request->input('account_name'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Enumerations\TaxExemptionReason;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantTaxGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'tax_liable' => $tenant->tax_liable,
|
||||
'vat_rate' => $tenant->vat_rate,
|
||||
'tax_exemption_reason' => $tenant->tax_exemption_reason,
|
||||
'tax_exemption_note' => $tenant->tax_exemption_note,
|
||||
'vat_pricing_mode' => $tenant->vat_pricing_mode,
|
||||
'tax_number' => $tenant->tax_number,
|
||||
'vat_id' => $tenant->vat_id,
|
||||
'invoice_prefix' => $tenant->invoice_prefix,
|
||||
// In der Mandanten-Verwaltung ist der Nummernkreis änderbar.
|
||||
'can_edit_invoice_prefix' => true,
|
||||
'exemption_reasons' => TaxExemptionReason::options(),
|
||||
'pricing_modes' => VatPricingMode::options(),
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/tax',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantTax\UpdateTenantTaxAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantTax\UpdateTenantTaxRequest;
|
||||
use App\Enumerations\TaxExemptionReason;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantTaxUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantTaxAction(new UpdateTenantTaxRequest(
|
||||
tenant: $tenant,
|
||||
taxLiable: $request->boolean('tax_liable'),
|
||||
vatRate: (int)$request->input('vat_rate', 0),
|
||||
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
||||
exemptionNote: $request->input('tax_exemption_note'),
|
||||
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
||||
taxNumber: $request->input('tax_number'),
|
||||
vatId: $request->input('vat_id'),
|
||||
invoicePrefix: $request->input('invoice_prefix'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantContactGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'email' => $this->tenant->email,
|
||||
'email_finance' => $this->tenant->email_finance,
|
||||
'invoice_sender_name' => $this->tenant->invoice_sender_name,
|
||||
// Als Platzhalter im Formular: so heisst der Absender, solange nichts eingetragen ist.
|
||||
'name' => $this->tenant->name,
|
||||
'phone' => $this->tenant->phone,
|
||||
'address_1' => $this->tenant->address_1,
|
||||
'address_2' => $this->tenant->address_2,
|
||||
'address_3' => $this->tenant->address_3,
|
||||
'postcode' => $this->tenant->postcode,
|
||||
'city' => $this->tenant->city,
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/contact',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantContact\UpdateTenantContactAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantContact\UpdateTenantContactRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantContactUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateTenantContactAction(new UpdateTenantContactRequest(
|
||||
tenant: $this->tenant,
|
||||
email: $request->input('email'),
|
||||
emailFinance: $request->input('email_finance'),
|
||||
postcode: $request->input('postcode'),
|
||||
city: $request->input('city'),
|
||||
invoiceSenderName: $request->input('invoice_sender_name'),
|
||||
address1: $request->input('address_1'),
|
||||
address2: $request->input('address_2'),
|
||||
address3: $request->input('address_3'),
|
||||
phone: $request->input('phone'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\CreateTenant\CreateTenantAction;
|
||||
use App\Domains\Admin\Actions\CreateTenant\CreateTenantRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantCreateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new CreateTenantAction(new CreateTenantRequest(
|
||||
name: $request->input('name'),
|
||||
slug: $request->input('slug'),
|
||||
url: $request->input('url'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
'slug' => $response->slug,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class TenantEditPageController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): Response
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$inertiaProvider = new InertiaProvider('Admin/TenantEdit', [
|
||||
'tenant' => [
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
],
|
||||
]);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantGdprGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'gdpr_text' => $this->tenant->gdpr_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/gdpr',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantGdprUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateTenantGdprAction(new UpdateTenantGdprRequest(
|
||||
tenant: $this->tenant,
|
||||
gdprText: $request->input('gdpr_text'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantGeneralGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
return response()->json([
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/general',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantGeneral\UpdateTenantGeneralAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantGeneral\UpdateTenantGeneralRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantGeneralUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = $this->adminTenants->findBySlug($slug);
|
||||
|
||||
$action = new UpdateTenantGeneralAction(new UpdateTenantGeneralRequest(
|
||||
tenant: $tenant,
|
||||
name: $request->input('name'),
|
||||
slug: $request->input('slug'),
|
||||
url: $request->input('url'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantImpressGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'impress_text' => $this->tenant->impress_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/impress',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantImpressUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateTenantImpressAction(new UpdateTenantImpressRequest(
|
||||
tenant: $this->tenant,
|
||||
impressText: $request->input('impress_text'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantListApiController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$tenants = $this->adminTenants->getActiveTenants();
|
||||
|
||||
$mapped = $tenants->map(function ($tenant) {
|
||||
return [
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['tenants' => $mapped]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class TenantListPageController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$inertiaProvider = new InertiaProvider('Admin/TenantList', []);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class TenantPageController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$inertiaProvider = new InertiaProvider('Admin/TenantData', [
|
||||
'tenant' => [
|
||||
'name' => $this->tenant->name,
|
||||
'slug' => $this->tenant->slug,
|
||||
'url' => $this->tenant->url,
|
||||
'is_active_local_group' => $this->tenant->is_active_local_group,
|
||||
],
|
||||
]);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantPaymentGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'account_iban' => $this->tenant->account_iban,
|
||||
'account_bic' => $this->tenant->account_bic,
|
||||
'account_name' => $this->tenant->account_name,
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/payment',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Resources\AvailablePaymentMethodResource;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantPaymentMethodsGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'paymentMethods' => AvailablePaymentMethod::all()
|
||||
->map(fn (AvailablePaymentMethod $method) => new AvailablePaymentMethodResource($method)->toArray($request)),
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/payment-methods',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateAvailablePaymentMethod\UpdateAvailablePaymentMethodAction;
|
||||
use App\Domains\Admin\Actions\UpdateAvailablePaymentMethod\UpdateAvailablePaymentMethodRequest;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantPaymentMethodsUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$availablePaymentMethod = AvailablePaymentMethod::findOrFail($id);
|
||||
|
||||
$action = new UpdateAvailablePaymentMethodAction(new UpdateAvailablePaymentMethodRequest(
|
||||
availablePaymentMethod: $availablePaymentMethod,
|
||||
name: $request->input('name'),
|
||||
description: $request->input('description'),
|
||||
active: (bool) $request->input('active'),
|
||||
configuration: (array) $request->input('configuration', []),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantPayment\UpdateTenantPaymentAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantPayment\UpdateTenantPaymentRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantPaymentUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateTenantPaymentAction(new UpdateTenantPaymentRequest(
|
||||
tenant: $this->tenant,
|
||||
accountIban: $request->input('account_iban'),
|
||||
accountBic: $request->input('account_bic'),
|
||||
accountName: $request->input('account_name'),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Enumerations\TaxExemptionReason;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantTaxGetController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'tax_liable' => $this->tenant->tax_liable,
|
||||
'vat_rate' => $this->tenant->vat_rate,
|
||||
'tax_exemption_reason' => $this->tenant->tax_exemption_reason,
|
||||
'tax_exemption_note' => $this->tenant->tax_exemption_note,
|
||||
'vat_pricing_mode' => $this->tenant->vat_pricing_mode,
|
||||
'tax_number' => $this->tenant->tax_number,
|
||||
'vat_id' => $this->tenant->vat_id,
|
||||
'invoice_prefix' => $this->tenant->invoice_prefix,
|
||||
// Im Self-Service nicht änderbar: das Präfix bestimmt den Nummernkreis.
|
||||
'can_edit_invoice_prefix' => false,
|
||||
'exemption_reasons' => TaxExemptionReason::options(),
|
||||
'pricing_modes' => VatPricingMode::options(),
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/tax',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateTenantTax\UpdateTenantTaxAction;
|
||||
use App\Domains\Admin\Actions\UpdateTenantTax\UpdateTenantTaxRequest;
|
||||
use App\Enumerations\TaxExemptionReason;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantTaxUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$action = new UpdateTenantTaxAction(new UpdateTenantTaxRequest(
|
||||
tenant: $this->tenant,
|
||||
taxLiable: $request->boolean('tax_liable'),
|
||||
vatRate: (int)$request->input('vat_rate', 0),
|
||||
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
||||
exemptionNote: $request->input('tax_exemption_note'),
|
||||
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
||||
taxNumber: $request->input('tax_number'),
|
||||
vatId: $request->input('vat_id'),
|
||||
// invoice_prefix wird hier bewusst nicht durchgereicht -- der Nummernkreis ist nur in der
|
||||
// Mandanten-Verwaltung änderbar.
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Enumerations\UserRole;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserDetailGetController extends CommonController
|
||||
{
|
||||
public function __invoke(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->adminUsers->findById($id);
|
||||
|
||||
$userData = $user->toArray();
|
||||
unset($userData['password'], $userData['remember_token'], $userData['activation_token'], $userData['activation_token_expires_at']);
|
||||
|
||||
$tenantNames = $this->adminTenants->getTenantNames();
|
||||
$userData['nicename'] = $user->getNicename();
|
||||
$userData['fullname'] = $user->getFullName();
|
||||
$userData['local_group_name'] = $tenantNames[$user->local_group] ?? $user->local_group;
|
||||
|
||||
return response()->json([
|
||||
'user' => $userData,
|
||||
'isOwnUser' => auth()->id() === $user->id,
|
||||
'isLvTenant' => $this->tenant->slug === 'lv',
|
||||
'userRoles' => UserRole::all()->map(fn($role) => ['slug' => $role->slug, 'name' => $role->name]),
|
||||
'localGroups' => $this->adminTenants->getActiveLocalGroups()->map(fn($t) => ['slug' => $t->slug, 'name' => $t->name]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserListApiController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$tenantNames = $this->adminTenants->getTenantNames();
|
||||
$users = $this->adminUsers->getListForTenant($this->tenant->slug);
|
||||
|
||||
$mapped = $users->map(function ($user) use ($tenantNames) {
|
||||
return [
|
||||
'id' => $user->id,
|
||||
'firstname' => $user->firstname,
|
||||
'lastname' => $user->lastname,
|
||||
'nickname' => $user->nickname,
|
||||
'local_group' => $user->local_group,
|
||||
'local_group_name' => $tenantNames[$user->local_group] ?? $user->local_group,
|
||||
'active' => $user->active,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['users' => $mapped]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class UserListPageController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$inertiaProvider = new InertiaProvider('Admin/UserList', [
|
||||
'isLvTenant' => $this->tenant->slug === 'lv',
|
||||
]);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\UserManagement\Actions\GenerateActivationToken\GenerateActivationTokenCommand;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserResetPasswordController extends CommonController
|
||||
{
|
||||
public function __invoke(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->adminUsers->findById($id);
|
||||
|
||||
if (!$user->email) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Benutzer*in hat keine E-Mail-Adresse hinterlegt.',
|
||||
]);
|
||||
}
|
||||
|
||||
$command = new GenerateActivationTokenCommand($user);
|
||||
$command->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Passwort-Reset-Mail wurde gesendet.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\ToggleUserActive\ToggleUserActiveAction;
|
||||
use App\Domains\Admin\Actions\ToggleUserActive\ToggleUserActiveRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserToggleActiveController extends CommonController
|
||||
{
|
||||
public function __invoke(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->adminUsers->findById($id);
|
||||
|
||||
$action = new ToggleUserActiveAction(new ToggleUserActiveRequest(
|
||||
user: $user,
|
||||
currentUserId: auth()->id(),
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
'active' => $response->active,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Domains\Admin\Actions\UpdateUser\UpdateUserAction;
|
||||
use App\Domains\Admin\Actions\UpdateUser\UpdateUserRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->adminUsers->findById($id);
|
||||
|
||||
$action = new UpdateUserAction(new UpdateUserRequest(
|
||||
user: $user,
|
||||
data: $request->all(),
|
||||
isOwnUser: auth()->id() === $user->id,
|
||||
isLvTenant: $this->tenant->slug === 'lv',
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Repositories;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Collection as SupportCollection;
|
||||
|
||||
class AdminTenantRepository
|
||||
{
|
||||
public function findBySlug(string $slug): Tenant
|
||||
{
|
||||
return Tenant::where('slug', $slug)->firstOrFail();
|
||||
}
|
||||
|
||||
public function getActiveTenants(): Collection
|
||||
{
|
||||
return Tenant::where('has_active_instance', true)->get();
|
||||
}
|
||||
|
||||
public function getTenantNames(): SupportCollection
|
||||
{
|
||||
return Tenant::pluck('name', 'slug');
|
||||
}
|
||||
|
||||
public function getActiveLocalGroups(): Collection
|
||||
{
|
||||
return Tenant::where('is_active_local_group', true)->get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Repositories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class AdminUserRepository
|
||||
{
|
||||
public function findById(int $id): User
|
||||
{
|
||||
return User::findOrFail($id);
|
||||
}
|
||||
|
||||
public function getListForTenant(string $tenantSlug): Collection
|
||||
{
|
||||
$query = User::query();
|
||||
|
||||
if ($tenantSlug !== 'lv') {
|
||||
$query->where('local_group', $tenantSlug);
|
||||
}
|
||||
|
||||
return $query->orderBy('lastname')->orderBy('firstname')->get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use App\Domains\Admin\Controllers\DocumentAssetDeleteController;
|
||||
use App\Domains\Admin\Controllers\DocumentAssetUpdateController;
|
||||
use App\Domains\Admin\Controllers\DocumentTemplatesGetController;
|
||||
use App\Domains\Admin\Controllers\DocumentTemplatesPreviewController;
|
||||
use App\Domains\Admin\Controllers\DocumentTemplatesUpdateController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantContactGetController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantContactUpdateController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantGdprGetController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantGdprUpdateController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantImpressGetController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantImpressUpdateController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantPaymentGetController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantPaymentUpdateController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantTaxGetController;
|
||||
use App\Domains\Admin\Controllers\ManagedTenantTaxUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantContactGetController;
|
||||
use App\Domains\Admin\Controllers\TenantContactUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantCreateController;
|
||||
use App\Domains\Admin\Controllers\TenantGdprGetController;
|
||||
use App\Domains\Admin\Controllers\TenantGdprUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantGeneralGetController;
|
||||
use App\Domains\Admin\Controllers\TenantGeneralUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantImpressGetController;
|
||||
use App\Domains\Admin\Controllers\TenantImpressUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantListApiController;
|
||||
use App\Domains\Admin\Controllers\TenantPaymentGetController;
|
||||
use App\Domains\Admin\Controllers\TenantPaymentMethodsGetController;
|
||||
use App\Domains\Admin\Controllers\TenantPaymentMethodsUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantPaymentUpdateController;
|
||||
use App\Domains\Admin\Controllers\TenantTaxGetController;
|
||||
use App\Domains\Admin\Controllers\TenantTaxUpdateController;
|
||||
use App\Domains\Admin\Controllers\UserDetailGetController;
|
||||
use App\Domains\Admin\Controllers\UserListApiController;
|
||||
use App\Domains\Admin\Controllers\UserResetPasswordController;
|
||||
use App\Domains\Admin\Controllers\UserToggleActiveController;
|
||||
use App\Domains\Admin\Controllers\UserUpdateController;
|
||||
use App\Middleware\AdminRoleMiddleware;
|
||||
use App\Middleware\IdentifyTenant;
|
||||
use App\Middleware\LvOnlyMiddleware;
|
||||
use App\Middleware\MainAdminRoleMiddleware;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
||||
Route::prefix('api/v1/admin/tenant')->group(function () {
|
||||
Route::get('/contact', TenantContactGetController::class);
|
||||
Route::post('/contact', TenantContactUpdateController::class);
|
||||
Route::get('/payment', TenantPaymentGetController::class);
|
||||
Route::post('/payment', TenantPaymentUpdateController::class);
|
||||
Route::get('/payment-methods', TenantPaymentMethodsGetController::class);
|
||||
Route::post('/payment-methods/{id}', TenantPaymentMethodsUpdateController::class);
|
||||
Route::get('/impress', TenantImpressGetController::class);
|
||||
Route::post('/impress', TenantImpressUpdateController::class);
|
||||
Route::get('/gdpr', TenantGdprGetController::class);
|
||||
Route::post('/gdpr', TenantGdprUpdateController::class);
|
||||
Route::get('/tax', TenantTaxGetController::class);
|
||||
Route::post('/tax', TenantTaxUpdateController::class);
|
||||
});
|
||||
|
||||
Route::prefix('api/v1/admin/users')->group(function () {
|
||||
Route::get('/list', UserListApiController::class);
|
||||
Route::get('/{id}', UserDetailGetController::class);
|
||||
Route::post('/{id}', UserUpdateController::class);
|
||||
Route::post('/{id}/toggle-active', UserToggleActiveController::class);
|
||||
Route::post('/{id}/reset-password', UserResetPasswordController::class);
|
||||
});
|
||||
|
||||
// Dokumentvorlagen gelten app-weit für alle Mandanten -- deshalb nur für Hauptadministrator*innen,
|
||||
// AdminRoleMiddleware allein ließe auch Gruppenleitungen durch.
|
||||
Route::middleware(MainAdminRoleMiddleware::class)->group(function () {
|
||||
Route::prefix('api/v1/admin/document-templates')->group(function () {
|
||||
Route::get('/', DocumentTemplatesGetController::class);
|
||||
Route::post('/', DocumentTemplatesUpdateController::class);
|
||||
Route::post('/preview', DocumentTemplatesPreviewController::class);
|
||||
Route::post('/assets', DocumentAssetUpdateController::class);
|
||||
Route::delete('/assets/{name}', DocumentAssetDeleteController::class);
|
||||
});
|
||||
});
|
||||
|
||||
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
||||
Route::prefix('api/v1/admin/tenants')->group(function () {
|
||||
Route::get('/list', TenantListApiController::class);
|
||||
Route::post('/create', TenantCreateController::class);
|
||||
Route::prefix('/{slug}')->group(function () {
|
||||
Route::get('/general', TenantGeneralGetController::class);
|
||||
Route::post('/general', TenantGeneralUpdateController::class);
|
||||
Route::get('/contact', ManagedTenantContactGetController::class);
|
||||
Route::post('/contact', ManagedTenantContactUpdateController::class);
|
||||
Route::get('/payment', ManagedTenantPaymentGetController::class);
|
||||
Route::post('/payment', ManagedTenantPaymentUpdateController::class);
|
||||
Route::get('/impress', ManagedTenantImpressGetController::class);
|
||||
Route::post('/impress', ManagedTenantImpressUpdateController::class);
|
||||
Route::get('/gdpr', ManagedTenantGdprGetController::class);
|
||||
Route::post('/gdpr', ManagedTenantGdprUpdateController::class);
|
||||
Route::get('/tax', ManagedTenantTaxGetController::class);
|
||||
Route::post('/tax', ManagedTenantTaxUpdateController::class);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use App\Domains\Admin\Controllers\AdminDashboardController;
|
||||
use App\Domains\Admin\Controllers\DocumentTemplatesPageController;
|
||||
use App\Domains\Admin\Controllers\TenantEditPageController;
|
||||
use App\Domains\Admin\Controllers\TenantListPageController;
|
||||
use App\Domains\Admin\Controllers\TenantPageController;
|
||||
use App\Domains\Admin\Controllers\UserListPageController;
|
||||
use App\Middleware\AdminRoleMiddleware;
|
||||
use App\Middleware\IdentifyTenant;
|
||||
use App\Middleware\LvOnlyMiddleware;
|
||||
use App\Middleware\MainAdminRoleMiddleware;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
||||
Route::prefix('admin')->group(function () {
|
||||
Route::get('/', AdminDashboardController::class);
|
||||
Route::get('/tenant', TenantPageController::class);
|
||||
Route::get('/users', UserListPageController::class);
|
||||
|
||||
// App-weit gültige Dokumentvorlagen -- nur für Hauptadministrator*innen.
|
||||
Route::middleware(MainAdminRoleMiddleware::class)->group(function () {
|
||||
Route::get('/document-templates', DocumentTemplatesPageController::class);
|
||||
});
|
||||
|
||||
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
||||
Route::get('/tenants', TenantListPageController::class);
|
||||
Route::get('/tenants/{slug}', TenantEditPageController::class);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup>
|
||||
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout title="Administration">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||
<h2>Administration</h2>
|
||||
</shadowed-box>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -0,0 +1,666 @@
|
||||
<script setup>
|
||||
import {computed, onMounted, ref} from 'vue'
|
||||
import {toast} from 'vue3-toastify'
|
||||
import AdminAppLayout from '../../../../resources/js/layouts/AdminAppLayout.vue'
|
||||
import ShadowedBox from '../../../Views/Components/ShadowedBox.vue'
|
||||
import TextEditor from '../../../Views/Components/TextEditor.vue'
|
||||
import {useAjax} from '../../../../resources/js/components/ajaxHandler.js'
|
||||
|
||||
const {request} = useAjax()
|
||||
|
||||
const blocks = ref([])
|
||||
const assets = ref([])
|
||||
const tokenGroups = ref({})
|
||||
|
||||
// Die Vorlagen sind nach Dokumentart getrennt; der Umschalter lädt jeweils deren Blöcke neu.
|
||||
const documentType = ref(null)
|
||||
const documentTypes = ref([])
|
||||
|
||||
const activeBlock = ref(null)
|
||||
const saving = ref(false)
|
||||
|
||||
// Die Vorschau ist ein PDF, das aus den aktuellen -- auch ungespeicherten -- Blockinhalten entsteht.
|
||||
const previewUrl = ref(null)
|
||||
const previewLoading = ref(false)
|
||||
|
||||
const newAsset = ref({name: '', label: '', file: null})
|
||||
const assetInput = ref(null)
|
||||
|
||||
const current = computed(() => blocks.value.find(b => b.block === activeBlock.value) ?? null)
|
||||
|
||||
/** Beim Blockwechsel die gemerkte Einfügemarke verwerfen -- sie gehört zum vorigen Text. */
|
||||
function selectBlock(block) {
|
||||
activeBlock.value = block
|
||||
caret.value = null
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
async function load() {
|
||||
const query = documentType.value ? '?type=' + encodeURIComponent(documentType.value) : ''
|
||||
const data = await request('/api/v1/admin/document-templates' + query, {method: 'GET'})
|
||||
if (!data) {
|
||||
toast.error('Die Vorlage konnte nicht geladen werden.')
|
||||
return
|
||||
}
|
||||
|
||||
documentType.value = data.documentType
|
||||
documentTypes.value = data.documentTypes ?? []
|
||||
blocks.value = data.blocks ?? []
|
||||
assets.value = data.assets ?? []
|
||||
tokenGroups.value = data.tokenGroups ?? {}
|
||||
activeBlock.value = blocks.value.find(b => b.editable)?.block ?? blocks.value[0]?.block ?? null
|
||||
|
||||
await refreshPreview()
|
||||
}
|
||||
|
||||
/** Beim Wechsel der Dokumentart alles neu holen -- Blöcke und Platzhalter sind je Art andere. */
|
||||
async function selectDocumentType(type) {
|
||||
if (type === documentType.value) return
|
||||
|
||||
documentType.value = type
|
||||
caret.value = null
|
||||
await load()
|
||||
}
|
||||
|
||||
/** Nur editierbare Blöcke werden gesendet; der generierte Rechnungsinhalt bleibt unverändert. */
|
||||
function editableBlocks() {
|
||||
return Object.fromEntries(
|
||||
blocks.value.filter(b => b.editable).map(b => [b.block, b.content ?? ''])
|
||||
)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
|
||||
try {
|
||||
const response = await request('/api/v1/admin/document-templates', {
|
||||
method: 'POST',
|
||||
body: {type: documentType.value, blocks: editableBlocks()},
|
||||
})
|
||||
|
||||
if (response?.status === 'success') {
|
||||
toast.success(response.message)
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshPreview() {
|
||||
previewLoading.value = true
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/v1/admin/document-templates/preview', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content ?? '',
|
||||
},
|
||||
body: JSON.stringify({type: documentType.value, blocks: editableBlocks()}),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
toast.error('Die Vorschau konnte nicht erzeugt werden.')
|
||||
return
|
||||
}
|
||||
|
||||
if (previewUrl.value) {
|
||||
URL.revokeObjectURL(previewUrl.value)
|
||||
}
|
||||
|
||||
previewUrl.value = URL.createObjectURL(await response.blob())
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Platzhalter an der Einfügemarke ergänzen. Im WYSIWYG-Editor übernimmt das TinyMCE selbst, im
|
||||
* Quelltext-Editor wird an der zuletzt bekannten Cursorposition eingesetzt.
|
||||
*/
|
||||
function insertToken(token) {
|
||||
const block = current.value
|
||||
if (!block) return
|
||||
|
||||
const placeholder = wrapForBlock('{' + token + '}', token, block)
|
||||
|
||||
if (block.source) {
|
||||
insertIntoTextarea(placeholder)
|
||||
return
|
||||
}
|
||||
|
||||
const editor = window.tinymce?.activeEditor
|
||||
if (editor) {
|
||||
editor.execCommand('mceInsertContent', false, placeholder)
|
||||
} else {
|
||||
block.content = (block.content ?? '') + placeholder
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Bild-Platzhalter allein ist nirgends sinnvoll: er expandiert zum nackten Data-URI, das dann als
|
||||
* Zeichenkette im Dokument steht. Er braucht immer eine Hülle — im CSS url("..."), sonst ein <img>.
|
||||
*
|
||||
* Im CSS ist das zusätzlich eine Frage der Funktionsfähigkeit: ein Data-URI ausserhalb von url()
|
||||
* kann dompdf nicht verarbeiten und läuft ins Zeitlimit.
|
||||
*/
|
||||
function wrapForBlock(placeholder, token, block) {
|
||||
if (!token.startsWith('asset:')) {
|
||||
return placeholder
|
||||
}
|
||||
|
||||
return block.block === 'style'
|
||||
? `url("${placeholder}")`
|
||||
: `<img src="${placeholder}" alt="" />`
|
||||
}
|
||||
|
||||
const sourceArea = ref(null)
|
||||
// Zuletzt bekannte Einfügemarke im Quelltext-Feld. Ohne das würde ein Klick in der weit darunter
|
||||
// liegenden Platzhalter- oder Bilder-Liste an unvorhersehbarer Stelle einfügen.
|
||||
const caret = ref(null)
|
||||
|
||||
function rememberCaret() {
|
||||
const area = sourceArea.value
|
||||
if (!area) return
|
||||
|
||||
caret.value = {start: area.selectionStart, end: area.selectionEnd}
|
||||
}
|
||||
|
||||
function insertIntoTextarea(text) {
|
||||
const block = current.value
|
||||
if (!block) return
|
||||
|
||||
const content = block.content ?? ''
|
||||
const position = caret.value
|
||||
|
||||
if (position === null) {
|
||||
block.content = content + text
|
||||
return
|
||||
}
|
||||
|
||||
block.content = content.slice(0, position.start) + text + content.slice(position.end)
|
||||
caret.value = {start: position.start + text.length, end: position.start + text.length}
|
||||
}
|
||||
|
||||
async function uploadAsset() {
|
||||
const form = new FormData()
|
||||
form.append('name', newAsset.value.name)
|
||||
form.append('label', newAsset.value.label ?? '')
|
||||
if (newAsset.value.file) {
|
||||
form.append('file', newAsset.value.file)
|
||||
}
|
||||
|
||||
const result = await request('/api/v1/admin/document-templates/assets', {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
})
|
||||
|
||||
if (result?.status === 'success') {
|
||||
toast.success(result.message)
|
||||
newAsset.value = {name: '', label: '', file: null}
|
||||
if (assetInput.value) assetInput.value.value = ''
|
||||
await load()
|
||||
} else {
|
||||
toast.error(result?.message ?? 'Fehler beim Hochladen')
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteAsset(name) {
|
||||
if (!confirm(`Das Bild „${name}" wirklich löschen?`)) return
|
||||
|
||||
const result = await request('/api/v1/admin/document-templates/assets/' + name, {method: 'DELETE'})
|
||||
|
||||
if (result?.status === 'success') {
|
||||
toast.success(result.message)
|
||||
await load()
|
||||
} else {
|
||||
// Ein noch in der Vorlage referenziertes Bild lehnt der Server ab.
|
||||
toast.error(result?.message ?? 'Das Bild konnte nicht gelöscht werden.')
|
||||
}
|
||||
}
|
||||
|
||||
function copyToken(token) {
|
||||
navigator.clipboard?.writeText(token)
|
||||
toast.success(`${token} kopiert`)
|
||||
}
|
||||
|
||||
function onFileChosen(event) {
|
||||
newAsset.value.file = event.target.files?.[0] ?? null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout title="Dokumentvorlagen">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px;">
|
||||
<p class="intro">
|
||||
Die Vorlagen gelten für <strong>alle Mandanten</strong>; die eingesetzten Werte kommen je
|
||||
Dokument aus dem jeweiligen Mandanten. Sie liegen in der Datenbank und werden von einem
|
||||
Update nicht überschrieben.
|
||||
</p>
|
||||
|
||||
<div class="type-switch">
|
||||
<label for="document-type">Dokumentart</label>
|
||||
<select
|
||||
id="document-type"
|
||||
class="form-input"
|
||||
:value="documentType"
|
||||
@change="selectDocumentType($event.target.value)"
|
||||
>
|
||||
<option v-for="type in documentTypes" :key="type.value" :value="type.value">
|
||||
{{ type.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="layout">
|
||||
<!-- ── Blöcke und Editor ── -->
|
||||
<div class="editor-column">
|
||||
<div class="block-tabs">
|
||||
<button
|
||||
v-for="block in blocks"
|
||||
:key="block.block"
|
||||
class="block-tab"
|
||||
:class="{active: block.block === activeBlock, readonly: !block.editable}"
|
||||
@click="selectBlock(block.block)"
|
||||
>
|
||||
{{ block.label }}
|
||||
<span v-if="!block.editable" class="badge">generiert</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="current" class="editor-panel">
|
||||
<p v-if="!current.editable" class="notice">
|
||||
Dieser Block wird beim Erzeugen des Dokuments aus den Daten der Anmeldung
|
||||
zusammengesetzt und lässt sich nicht bearbeiten.
|
||||
</p>
|
||||
|
||||
<p v-else-if="current.source" class="notice">
|
||||
Enthält den Seitenaufbau bzw. die Gestaltung und wird deshalb im Quelltext
|
||||
bearbeitet. Für Adresse, Logo oder Fußnote ist das nicht nötig.
|
||||
</p>
|
||||
|
||||
<textarea
|
||||
v-if="current.source || !current.editable"
|
||||
ref="sourceArea"
|
||||
v-model="current.content"
|
||||
class="source-editor"
|
||||
:readonly="!current.editable"
|
||||
spellcheck="false"
|
||||
rows="24"
|
||||
@click="rememberCaret"
|
||||
@keyup="rememberCaret"
|
||||
@blur="rememberCaret"
|
||||
></textarea>
|
||||
|
||||
<!-- convert-urls aus: sonst schreibt TinyMCE {asset:...} in einem src um. -->
|
||||
<TextEditor v-else v-model="current.content" :convert-urls="false" />
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button class="btn-save" :disabled="saving" @click="save">
|
||||
{{ saving ? 'Wird gespeichert…' : 'Speichern' }}
|
||||
</button>
|
||||
<button class="btn-secondary" :disabled="previewLoading" @click="refreshPreview">
|
||||
{{ previewLoading ? 'Wird erzeugt…' : 'Vorschau aktualisieren' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ── Platzhalter ── -->
|
||||
<div class="tokens">
|
||||
<h3>Platzhalter</h3>
|
||||
<p class="tokens-hint">
|
||||
Klicken fügt den Platzhalter an der Einfügemarke ein — in
|
||||
<strong>{{ current?.label ?? '—' }}</strong>. Mit
|
||||
<code>{if:name}…{/if:name}</code> lässt sich ein Abschnitt weglassen, solange
|
||||
der Platzhalter leer ist.
|
||||
</p>
|
||||
|
||||
<div v-for="(group, key) in tokenGroups" :key="key" class="token-group">
|
||||
<h4>{{ group.label }}</h4>
|
||||
<button
|
||||
v-for="(token, name) in group.tokens"
|
||||
:key="name"
|
||||
class="token"
|
||||
:title="token.description"
|
||||
@click="insertToken(name)"
|
||||
>{{ '{' + name + '}' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Bilder ── -->
|
||||
<div class="assets">
|
||||
<h3>Bilder</h3>
|
||||
<p class="tokens-hint">
|
||||
Liegen in der Datenbank, damit ein Update sie nicht überschreibt. „Einfügen"
|
||||
schreibt in <strong>{{ current?.label ?? '—' }}</strong><template
|
||||
v-if="current?.block === 'style'"> — im CSS als
|
||||
<code>url("…")</code>, anders kann dompdf ein Bild dort nicht verarbeiten</template>.
|
||||
</p>
|
||||
|
||||
<table class="asset-table">
|
||||
<tr v-for="asset in assets" :key="asset.name">
|
||||
<td class="asset-preview"><img :src="asset.preview" :alt="asset.name" /></td>
|
||||
<td>
|
||||
<strong>{{ asset.name }}</strong>
|
||||
<span v-if="asset.label" class="asset-label">{{ asset.label }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<code class="token-code" @click="copyToken(asset.token)">{{ asset.token }}</code>
|
||||
</td>
|
||||
<td class="asset-actions">
|
||||
<button class="btn-link" @click="insertToken('asset:' + asset.name)">Einfügen</button>
|
||||
<button class="btn-link danger" @click="deleteAsset(asset.name)">Löschen</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="asset-upload">
|
||||
<input v-model="newAsset.name" type="text" placeholder="Name, z. B. logo" class="form-input" />
|
||||
<input v-model="newAsset.label" type="text" placeholder="Beschreibung (optional)" class="form-input" />
|
||||
<input ref="assetInput" type="file" accept="image/*" @change="onFileChosen" />
|
||||
<button class="btn-secondary" :disabled="!newAsset.name" @click="uploadAsset">
|
||||
Hochladen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Vorschau ── -->
|
||||
<div class="preview-column">
|
||||
<h3>Vorschau</h3>
|
||||
<p class="tokens-hint">Mit Beispieldaten, ohne zu speichern.</p>
|
||||
<iframe v-if="previewUrl" :src="previewUrl" class="preview-frame"></iframe>
|
||||
<p v-else class="notice">Noch keine Vorschau erzeugt.</p>
|
||||
</div>
|
||||
</div>
|
||||
</shadowed-box>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.intro {
|
||||
margin-bottom: 20px;
|
||||
padding: 10px 12px;
|
||||
border-left: 3px solid #f5c400;
|
||||
background-color: #fffef5;
|
||||
font-size: 0.9rem;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.type-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.type-switch label {
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.type-switch select {
|
||||
width: auto;
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.editor-column {
|
||||
flex: 1 1 60%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.preview-column {
|
||||
flex: 1 1 40%;
|
||||
min-width: 320px;
|
||||
position: sticky;
|
||||
top: 20px;
|
||||
}
|
||||
|
||||
.block-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.block-tab {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
background-color: #ffffff;
|
||||
cursor: pointer;
|
||||
font-size: 0.85rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.block-tab.active {
|
||||
background-color: #1d4899;
|
||||
border-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.block-tab.readonly {
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.badge {
|
||||
margin-left: 6px;
|
||||
padding: 1px 5px;
|
||||
border-radius: 3px;
|
||||
background-color: #e5e7eb;
|
||||
color: #4b5563;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.block-tab.active .badge {
|
||||
background-color: rgba(255, 255, 255, 0.25);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.editor-panel {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.notice {
|
||||
margin-bottom: 10px;
|
||||
font-size: 0.85rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.source-editor {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.5;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.source-editor[readonly] {
|
||||
background-color: #f9fafb;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.btn-save, .btn-secondary {
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover:not(:disabled) {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-save:disabled, .btn-secondary:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.tokens, .assets {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.tokens h3, .assets h3, .preview-column h3 {
|
||||
margin-bottom: 6px;
|
||||
font-size: 1rem;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.tokens-hint {
|
||||
margin-bottom: 10px;
|
||||
font-size: 0.8rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.tokens-hint code, .token-code {
|
||||
padding: 1px 4px;
|
||||
background-color: #f3f4f6;
|
||||
border-radius: 3px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.token-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.token-group h4 {
|
||||
margin-bottom: 4px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: normal;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.token {
|
||||
margin: 0 4px 4px 0;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 4px;
|
||||
background-color: #f9fafb;
|
||||
cursor: pointer;
|
||||
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||
font-size: 0.75rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.token:hover {
|
||||
background-color: #eef2ff;
|
||||
border-color: #1d4899;
|
||||
}
|
||||
|
||||
.asset-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.asset-table td {
|
||||
padding: 6px 8px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
vertical-align: middle;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.asset-preview img {
|
||||
max-width: 60px;
|
||||
max-height: 40px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.asset-label {
|
||||
display: block;
|
||||
font-size: 0.75rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.token-code {
|
||||
cursor: pointer;
|
||||
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.asset-actions {
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
padding: 2px 6px;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
color: #1d4899;
|
||||
}
|
||||
|
||||
.btn-link.danger {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.asset-upload {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.preview-frame {
|
||||
width: 100%;
|
||||
height: 780px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.layout {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.preview-column {
|
||||
position: static;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,224 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const editing = ref(false)
|
||||
// Solange kein eigener Absender eingetragen ist, steht auf der Rechnung der Name des Mandanten.
|
||||
const senderFallback = props.data.name ?? ''
|
||||
|
||||
const form = ref({
|
||||
invoice_sender_name: props.data.invoice_sender_name ?? '',
|
||||
email: props.data.email ?? '',
|
||||
email_finance: props.data.email_finance ?? '',
|
||||
phone: props.data.phone ?? '',
|
||||
address_1: props.data.address_1 ?? '',
|
||||
address_2: props.data.address_2 ?? '',
|
||||
address_3: props.data.address_3 ?? '',
|
||||
postcode: props.data.postcode ?? '',
|
||||
city: props.data.city ?? '',
|
||||
})
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenant/contact'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: form.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
editing.value = false
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!editing">
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>Rechnungs-Absender:</th>
|
||||
<td>
|
||||
{{ form.invoice_sender_name || senderFallback }}
|
||||
<span v-if="!form.invoice_sender_name" class="field-hint">
|
||||
Name des Mandanten, da nichts Eigenes hinterlegt ist
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>Email:</th><td>{{ form.email }}</td></tr>
|
||||
<tr><th>Email Schatzmeister*in:</th><td>{{ form.email_finance }}</td></tr>
|
||||
<tr><th>Telefon:</th><td>{{ form.phone || '—' }}</td></tr>
|
||||
<tr><th>Straße & Hausnummer:</th><td>{{ form.address_1 || '—' }}</td></tr>
|
||||
<tr><th>Adresszusatz:</th><td>{{ form.address_2 || '—' }}</td></tr>
|
||||
<tr><th>Weiterer Zusatz:</th><td>{{ form.address_3 || '—' }}</td></tr>
|
||||
<tr><th>Postleitzahl:</th><td>{{ form.postcode }}</td></tr>
|
||||
<tr><th>Ort:</th><td>{{ form.city }}</td></tr>
|
||||
</table>
|
||||
|
||||
<p v-if="!form.address_1" class="hint">
|
||||
Ohne Straße & Hausnummer ist die Anschrift auf Rechnungen unvollständig
|
||||
(§ 14 Abs. 4 UStG).
|
||||
</p>
|
||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>Rechnungs-Absender:</th>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
v-model="form.invoice_sender_name"
|
||||
class="form-input"
|
||||
:placeholder="senderFallback"
|
||||
/>
|
||||
<span class="field-hint">
|
||||
Vollständige Bezeichnung mit Rechtsform, wie sie auf der Rechnung stehen soll.
|
||||
Leer lassen, um den Namen des Mandanten zu verwenden.
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Email:</th>
|
||||
<td><input type="email" v-model="form.email" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Email Schatzmeister*in:</th>
|
||||
<td><input type="email" v-model="form.email_finance" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Telefon:</th>
|
||||
<td><input type="text" v-model="form.phone" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Straße & Hausnummer:</th>
|
||||
<td>
|
||||
<input type="text" v-model="form.address_1" class="form-input" />
|
||||
<span class="field-hint">Pflichtangabe für Rechnungen (§ 14 Abs. 4 UStG)</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Adresszusatz:</th>
|
||||
<td>
|
||||
<input type="text" v-model="form.address_2" class="form-input" placeholder="z. B. c/o Mustermensch" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Weiterer Zusatz:</th>
|
||||
<td><input type="text" v-model="form.address_3" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Postleitzahl:</th>
|
||||
<td><input type="text" v-model="form.postcode" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Ort:</th>
|
||||
<td><input type="text" v-model="form.city" class="form-input" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="editing = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 0.8rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border-left: 3px solid #f5c400;
|
||||
background-color: #fffef5;
|
||||
font-size: 0.85rem;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.btn-edit, .btn-save, .btn-cancel {
|
||||
margin-top: 15px;
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
import gdprTemplate from "../../../../../resources/templates/gdpr-template.html?raw";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const content = ref(props.data.gdpr_text ?? '')
|
||||
|
||||
function autoGenerate() {
|
||||
if (content.value && content.value.trim() !== '') {
|
||||
toast.error('Der Editor ist nicht leer. Bitte leere den Inhalt zuerst, um die Vorlage zu verwenden.')
|
||||
return
|
||||
}
|
||||
|
||||
const today = new Date().toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' })
|
||||
content.value = gdprTemplate.replace('[Datum]', today)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenant/gdpr'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: { gdpr_text: content.value },
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<TextEditor v-model="content" />
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-generate" @click="autoGenerate">Auto-generieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.btn-save, .btn-generate {
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-generate {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-generate:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,157 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const editing = ref(false)
|
||||
const form = ref({
|
||||
name: props.data.name ?? '',
|
||||
slug: props.data.slug ?? '',
|
||||
url: props.data.url ?? '',
|
||||
})
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenants/' + props.data.slug + '/general'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: form.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
editing.value = false
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!editing">
|
||||
<table class="data-table">
|
||||
<tr><th>Name:</th><td>{{ form.name }}</td></tr>
|
||||
<tr><th>Slug:</th><td>{{ form.slug }}</td></tr>
|
||||
<tr><th>URL:</th><td>{{ form.url }}</td></tr>
|
||||
<tr><th>Status:</th><td>
|
||||
<span class="badge-active">Aktiv</span>
|
||||
</td></tr>
|
||||
</table>
|
||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>Name:</th>
|
||||
<td><input type="text" v-model="form.name" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Slug:</th>
|
||||
<td><input type="text" v-model="form.slug" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>URL:</th>
|
||||
<td><input type="text" v-model="form.url" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr><th>Status:</th><td>
|
||||
<span class="badge-active">Aktiv</span>
|
||||
</td></tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="editing = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.btn-edit, .btn-save, .btn-cancel {
|
||||
margin-top: 15px;
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const content = ref(props.data.impress_text ?? '')
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenant/impress'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: { impress_text: content.value },
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<TextEditor v-model="content" />
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.btn-save {
|
||||
margin-top: 15px;
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,140 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const editing = ref(false)
|
||||
const form = ref({
|
||||
account_iban: props.data.account_iban ?? '',
|
||||
account_bic: props.data.account_bic ?? '',
|
||||
account_name: props.data.account_name ?? '',
|
||||
})
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenant/payment'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: form.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
editing.value = false
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!editing">
|
||||
<table class="data-table">
|
||||
<tr><th>IBAN:</th><td>{{ form.account_iban }}</td></tr>
|
||||
<tr><th>BIC:</th><td>{{ form.account_bic }}</td></tr>
|
||||
<tr><th>Name Kontoinhaber:</th><td>{{ form.account_name }}</td></tr>
|
||||
</table>
|
||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>IBAN:</th>
|
||||
<td><input type="text" v-model="form.account_iban" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>BIC:</th>
|
||||
<td><input type="text" v-model="form.account_bic" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name Kontoinhaber:</th>
|
||||
<td><input type="text" v-model="form.account_name" class="form-input" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="editing = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn-edit, .btn-save, .btn-cancel {
|
||||
margin-top: 15px;
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,264 @@
|
||||
<script setup>
|
||||
import {computed, ref} from 'vue';
|
||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
||||
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
||||
import {PAYMENT_METHOD_ICONS} from "../../../../../resources/js/constants/paymentMethodIcons.js";
|
||||
import {useAjax} from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import {toast} from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const paymentMethods = ref(props.data.paymentMethods ?? [])
|
||||
const editing = ref(null)
|
||||
const form = ref({ name: '', description: '', active: true, configuration: {} })
|
||||
|
||||
// Sind alle Pflichtfelder des aktuell bearbeiteten Moduls befüllt? Der Server ist die
|
||||
// eigentliche Autorität (Guard), das hier dient nur der Bedienführung.
|
||||
const requiredComplete = computed(() => {
|
||||
if (!editing.value) return true
|
||||
return (editing.value.optionsSchema ?? [])
|
||||
.filter(option => option.required)
|
||||
.every(option => {
|
||||
const value = form.value.configuration[option.name]
|
||||
return value !== undefined && value !== null && value !== ''
|
||||
})
|
||||
})
|
||||
|
||||
function edit(paymentMethod) {
|
||||
editing.value = paymentMethod
|
||||
const configuration = {}
|
||||
for (const option of paymentMethod.optionsSchema ?? []) {
|
||||
configuration[option.name] = paymentMethod.configuration?.[option.name] ?? ''
|
||||
}
|
||||
form.value = {
|
||||
name: paymentMethod.name,
|
||||
description: paymentMethod.description ?? '',
|
||||
active: paymentMethod.active,
|
||||
configuration,
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
editing.value = null
|
||||
}
|
||||
|
||||
async function save() {
|
||||
const response = await request('/api/v1/admin/tenant/payment-methods/' + editing.value.id, {
|
||||
method: 'POST',
|
||||
body: form.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
Object.assign(editing.value, form.value)
|
||||
close()
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table class="payment-method-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th class="empty"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="paymentMethod in paymentMethods" :key="paymentMethod.id">
|
||||
<td>{{ paymentMethod.name }}</td>
|
||||
<td>
|
||||
<span :class="paymentMethod.active ? 'badge-active' : 'badge-inactive'">
|
||||
{{ paymentMethod.active ? 'Aktiv' : 'Inaktiv' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-edit" @click="edit(paymentMethod)">Bearbeiten</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<FullScreenModal :show="editing !== null" @close="close">
|
||||
<template v-if="editing">
|
||||
<h2>Zahlungsmodul bearbeiten</h2>
|
||||
<table class="data-table">
|
||||
<tr><th>Name</th><td><input type="text" v-model="form.name" class="form-input" /></td></tr>
|
||||
<tr><th>Beschreibung</th><td><textarea v-model="form.description" class="form-input"></textarea></td></tr>
|
||||
<tr v-for="option in editing.optionsSchema ?? []" :key="option.name">
|
||||
<th>{{ option.label }}<span v-if="option.required" class="required-marker">*</span></th>
|
||||
<td>
|
||||
<RichSelectBox v-if="option.type === 'icon'" v-model="form.configuration[option.name]"
|
||||
:options="PAYMENT_METHOD_ICONS" placeholder="Symbol wählen…"/>
|
||||
<TextEditor v-else-if="option.type === 'richtext'" v-model="form.configuration[option.name]"/>
|
||||
<input v-else type="text" v-model="form.configuration[option.name]" class="form-input"/>
|
||||
<span v-if="option.hint" class="option-hint">{{ option.hint }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Aktiv</th>
|
||||
<td>
|
||||
<input type="checkbox" v-model="form.active" :disabled="!requiredComplete && !form.active" />
|
||||
<span v-if="!requiredComplete" class="hint">Bitte zuerst alle Pflichtfelder (*) ausfüllen, um zu aktivieren.</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="close">Abbrechen</button>
|
||||
</div>
|
||||
</template>
|
||||
</FullScreenModal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.payment-method-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.payment-method-table thead th {
|
||||
text-align: left;
|
||||
padding: 10px 16px;
|
||||
background-color: #f9fafb;
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
border-bottom: 2px solid #d1d5db;
|
||||
}
|
||||
|
||||
.payment-method-table tbody td {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.badge-inactive {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #991b1b;
|
||||
background-color: #fee2e2;
|
||||
border: 1px solid #ef4444;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
padding: 6px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.required-marker {
|
||||
color: #ef4444;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 0.8rem;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.option-hint {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 0.8rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.btn-save, .btn-cancel {
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,317 @@
|
||||
<script setup>
|
||||
import {computed, ref} from 'vue';
|
||||
import {useAjax} from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
||||
import {toast} from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
})
|
||||
|
||||
const {request} = useAjax()
|
||||
|
||||
const editing = ref(false)
|
||||
|
||||
const reasons = computed(() => props.data.exemption_reasons ?? [])
|
||||
const pricingModes = computed(() => props.data.pricing_modes ?? [])
|
||||
|
||||
const liableOptions = [
|
||||
{value: '1', label: 'Ja – Umsatzsteuer wird erhoben'},
|
||||
{value: '0', label: 'Nein – umsatzsteuerbefreit'},
|
||||
]
|
||||
|
||||
const form = ref({
|
||||
tax_liable: props.data.tax_liable ? '1' : '0',
|
||||
vat_rate: props.data.vat_rate ?? 0,
|
||||
tax_exemption_reason: props.data.tax_exemption_reason ?? '',
|
||||
tax_exemption_note: props.data.tax_exemption_note ?? '',
|
||||
vat_pricing_mode: props.data.vat_pricing_mode ?? 'inclusive',
|
||||
tax_number: props.data.tax_number ?? '',
|
||||
vat_id: props.data.vat_id ?? '',
|
||||
invoice_prefix: props.data.invoice_prefix ?? '',
|
||||
})
|
||||
|
||||
// Das Präfix bestimmt den Nummernkreis und darf sich nachträglich nicht ändern -- sonst gehörten bereits
|
||||
// herausgegebene Rechnungen plötzlich zu einer anderen Nummer. Nur in der verwalteten Ansicht editierbar.
|
||||
const canEditPrefix = computed(() => props.data.can_edit_invoice_prefix === true)
|
||||
|
||||
const isLiable = computed(() => form.value.tax_liable === '1')
|
||||
const isCustomReason = computed(() => form.value.tax_exemption_reason === 'custom')
|
||||
|
||||
const selectedReason = computed(
|
||||
() => reasons.value.find(r => r.value === form.value.tax_exemption_reason) ?? null
|
||||
)
|
||||
|
||||
const pricingModeLabel = computed(
|
||||
() => pricingModes.value.find(m => m.value === form.value.vat_pricing_mode)?.label ?? '—'
|
||||
)
|
||||
|
||||
// Vorschau des Pflichthinweises nach § 14 Abs. 4 Nr. 8 UStG, der später auf der Rechnung erscheint.
|
||||
const invoiceHint = computed(() => {
|
||||
if (isLiable.value) {
|
||||
return `Umsatzsteuerpflichtig – USt-Satz: ${form.value.vat_rate || 0} %`
|
||||
}
|
||||
if (isCustomReason.value) {
|
||||
return form.value.tax_exemption_note?.trim() || '—'
|
||||
}
|
||||
return selectedReason.value?.text || '—'
|
||||
})
|
||||
|
||||
const reasonLabel = computed(() => selectedReason.value?.label ?? '—')
|
||||
|
||||
async function save() {
|
||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenant/tax'
|
||||
const response = await request(saveUrl, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
tax_liable: isLiable.value,
|
||||
vat_rate: Number(form.value.vat_rate) || 0,
|
||||
tax_exemption_reason: isLiable.value ? null : form.value.tax_exemption_reason,
|
||||
tax_exemption_note: form.value.tax_exemption_note,
|
||||
vat_pricing_mode: form.value.vat_pricing_mode,
|
||||
tax_number: form.value.tax_number,
|
||||
vat_id: form.value.vat_id,
|
||||
invoice_prefix: canEditPrefix.value ? form.value.invoice_prefix : undefined,
|
||||
},
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
editing.value = false
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!editing">
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>Steuerpflicht</th>
|
||||
<td>{{ isLiable ? 'Ja – Umsatzsteuer wird erhoben' : 'Nein – umsatzsteuerbefreit' }}</td>
|
||||
</tr>
|
||||
<tr v-if="isLiable">
|
||||
<th>USt-Satz</th>
|
||||
<td>{{ form.vat_rate || 0 }} %</td>
|
||||
</tr>
|
||||
<tr v-if="isLiable">
|
||||
<th>Preismodus</th>
|
||||
<td>{{ pricingModeLabel }}</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<th>Befreiungsgrund</th>
|
||||
<td>{{ reasonLabel }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Rechnungshinweis</th>
|
||||
<td>{{ invoiceHint }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Steuernummer</th>
|
||||
<td>{{ form.tax_number || '—' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>USt-IdNr.</th>
|
||||
<td>{{ form.vat_id || '—' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Rechnungs-Präfix</th>
|
||||
<td>{{ form.invoice_prefix || '—' }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<th>Steuerpflicht</th>
|
||||
<td>
|
||||
<RichSelectBox v-model="form.tax_liable" :options="liableOptions"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="isLiable">
|
||||
<th>USt-Satz (%)</th>
|
||||
<td><input type="number" min="0" max="100" v-model.number="form.vat_rate" class="form-input"/></td>
|
||||
</tr>
|
||||
<tr v-if="isLiable">
|
||||
<th>Preismodus</th>
|
||||
<td>
|
||||
<RichSelectBox v-model="form.vat_pricing_mode" :options="pricingModes"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<template v-else>
|
||||
<tr>
|
||||
<th>Befreiungsgrund</th>
|
||||
<td>
|
||||
<RichSelectBox
|
||||
v-model="form.tax_exemption_reason"
|
||||
:options="reasons"
|
||||
placeholder="Grund auswählen…"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isCustomReason">
|
||||
<th>Freitext</th>
|
||||
<td>
|
||||
<textarea
|
||||
v-model="form.tax_exemption_note"
|
||||
class="form-input"
|
||||
rows="3"
|
||||
placeholder="Hinweistext für die Rechnung…"
|
||||
></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<tr>
|
||||
<th>Rechnungshinweis</th>
|
||||
<td class="hint-preview">{{ invoiceHint }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Steuernummer</th>
|
||||
<td>
|
||||
<input type="text" v-model="form.tax_number" class="form-input" />
|
||||
<span class="field-hint">
|
||||
Pflichtangabe auf Rechnungen — alternativ die USt-IdNr. (§ 14 Abs. 4 Nr. 2 UStG)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>USt-IdNr.</th>
|
||||
<td><input type="text" v-model="form.vat_id" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Rechnungs-Präfix</th>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
v-model="form.invoice_prefix"
|
||||
class="form-input"
|
||||
:disabled="!canEditPrefix"
|
||||
/>
|
||||
<span class="field-hint">
|
||||
Erster Block der Rechnungsnummer, z. B. <code>WM</code> in
|
||||
<code>WM-V-20260701-0005</code>.
|
||||
<template v-if="canEditPrefix">
|
||||
Eine Änderung wirkt nur auf künftige Veranstaltungen; bereits angelegte behalten
|
||||
ihre Nummer.
|
||||
</template>
|
||||
<template v-else>
|
||||
Änderbar nur in der Mandanten-Verwaltung.
|
||||
</template>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="editing = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.hint-preview {
|
||||
color: #6b7280;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 0.8rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.field-hint code {
|
||||
padding: 1px 4px;
|
||||
background-color: #f3f4f6;
|
||||
border-radius: 3px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.form-input:disabled {
|
||||
background-color: #f3f4f6;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.btn-edit, .btn-save, .btn-cancel {
|
||||
margin-top: 15px;
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,331 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const props = defineProps({
|
||||
data: Object,
|
||||
})
|
||||
|
||||
const emit = defineEmits(['updated', 'closed'])
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const editing = ref(false)
|
||||
const user = props.data.user
|
||||
const isOwnUser = props.data.isOwnUser
|
||||
const isLvTenant = props.data.isLvTenant
|
||||
const userRoles = props.data.userRoles
|
||||
const localGroups = props.data.localGroups
|
||||
|
||||
const form = ref({
|
||||
firstname: user.firstname ?? '',
|
||||
lastname: user.lastname ?? '',
|
||||
nickname: user.nickname ?? '',
|
||||
email: user.email ?? '',
|
||||
phone: user.phone ?? '',
|
||||
birthday: user.birthday ?? '',
|
||||
membership_id: user.membership_id ?? '',
|
||||
address_1: user.address_1 ?? '',
|
||||
address_2: user.address_2 ?? '',
|
||||
postcode: user.postcode ?? '',
|
||||
city: user.city ?? '',
|
||||
medications: user.medications ?? '',
|
||||
allergies: user.allergies ?? '',
|
||||
intolerances: user.intolerances ?? '',
|
||||
bank_account_owner: user.bank_account_owner ?? '',
|
||||
bank_account_iban: user.bank_account_iban ?? '',
|
||||
user_role_local_group: user.user_role_local_group ?? '',
|
||||
user_role_main: user.user_role_main ?? '',
|
||||
local_group: user.local_group ?? '',
|
||||
})
|
||||
|
||||
async function save() {
|
||||
const response = await request('/api/v1/admin/users/' + user.id, {
|
||||
method: 'POST',
|
||||
body: form.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
editing.value = false
|
||||
emit('updated')
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleActive() {
|
||||
const response = await request('/api/v1/admin/users/' + user.id + '/toggle-active', {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
emit('updated')
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler')
|
||||
}
|
||||
}
|
||||
|
||||
async function resetPassword() {
|
||||
const response = await request('/api/v1/admin/users/' + user.id + '/reset-password', {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler')
|
||||
}
|
||||
}
|
||||
|
||||
function getRoleName(slug) {
|
||||
const role = userRoles.find(r => r.slug === slug)
|
||||
return role ? role.name : slug
|
||||
}
|
||||
|
||||
function getGroupName(slug) {
|
||||
const group = localGroups.find(g => g.slug === slug)
|
||||
return group ? group.name : slug
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="detail-header">
|
||||
<h3>{{ user.firstname }} {{ user.lastname }}</h3>
|
||||
<div class="detail-actions">
|
||||
<button v-if="!editing" class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||
<button class="btn-reset" @click="resetPassword">Passwort zurücksetzen</button>
|
||||
<button v-if="!isOwnUser" :class="user.active ? 'btn-deactivate' : 'btn-activate'" @click="toggleActive">
|
||||
{{ user.active ? 'Deaktivieren' : 'Aktivieren' }}
|
||||
</button>
|
||||
<button class="btn-close" @click="emit('closed')">Schließen</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!editing">
|
||||
<table class="data-table">
|
||||
<tr><th>Anmeldename:</th><td>{{ user.username }}</td></tr>
|
||||
<tr><th>Vorname:</th><td>{{ form.firstname }}</td></tr>
|
||||
<tr><th>Nachname:</th><td>{{ form.lastname }}</td></tr>
|
||||
<tr><th>Nickname:</th><td>{{ form.nickname }}</td></tr>
|
||||
<tr><th>E-Mail:</th><td>{{ form.email }}</td></tr>
|
||||
<tr><th>Telefon:</th><td>{{ form.phone }}</td></tr>
|
||||
<tr><th>Geburtstag:</th><td>{{ form.birthday }}</td></tr>
|
||||
<tr><th>Mitgliedsnummer:</th><td>{{ form.membership_id }}</td></tr>
|
||||
<tr><th>Adresse 1:</th><td>{{ form.address_1 }}</td></tr>
|
||||
<tr><th>Adresse 2:</th><td>{{ form.address_2 }}</td></tr>
|
||||
<tr><th>PLZ:</th><td>{{ form.postcode }}</td></tr>
|
||||
<tr><th>Ort:</th><td>{{ form.city }}</td></tr>
|
||||
<tr><th>Medikamente:</th><td>{{ form.medications }}</td></tr>
|
||||
<tr><th>Allergien:</th><td>{{ form.allergies }}</td></tr>
|
||||
<tr><th>Unverträglichkeiten:</th><td>{{ form.intolerances }}</td></tr>
|
||||
<tr><th>Kontoinhaber:</th><td>{{ form.bank_account_owner }}</td></tr>
|
||||
<tr><th>IBAN:</th><td>{{ form.bank_account_iban }}</td></tr>
|
||||
<tr><th>Stamm:</th><td>{{ getGroupName(form.local_group) }}</td></tr>
|
||||
<tr><th>Rolle (Stamm):</th><td>{{ getRoleName(form.user_role_local_group) }}</td></tr>
|
||||
<tr><th>Rolle (LV):</th><td>{{ getRoleName(form.user_role_main) }}</td></tr>
|
||||
<tr><th>Status:</th><td>
|
||||
<span :class="user.active ? 'badge-active' : 'badge-inactive'">
|
||||
{{ user.active ? 'Aktiv' : 'Inaktiv' }}
|
||||
</span>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<table class="data-table">
|
||||
<tr><th>Anmeldename:</th><td>{{ user.username }}</td></tr>
|
||||
<tr><th>Vorname:</th><td><input type="text" v-model="form.firstname" class="form-input" /></td></tr>
|
||||
<tr><th>Nachname:</th><td><input type="text" v-model="form.lastname" class="form-input" /></td></tr>
|
||||
<tr><th>Nickname:</th><td><input type="text" v-model="form.nickname" class="form-input" /></td></tr>
|
||||
<tr><th>E-Mail:</th><td><input type="email" v-model="form.email" class="form-input" /></td></tr>
|
||||
<tr><th>Telefon:</th><td><input type="text" v-model="form.phone" class="form-input" /></td></tr>
|
||||
<tr><th>Geburtstag:</th><td><input type="date" v-model="form.birthday" class="form-input" /></td></tr>
|
||||
<tr><th>Mitgliedsnummer:</th><td><input type="text" v-model="form.membership_id" class="form-input" /></td></tr>
|
||||
<tr><th>Adresse 1:</th><td><input type="text" v-model="form.address_1" class="form-input" /></td></tr>
|
||||
<tr><th>Adresse 2:</th><td><input type="text" v-model="form.address_2" class="form-input" /></td></tr>
|
||||
<tr><th>PLZ:</th><td><input type="text" v-model="form.postcode" class="form-input" /></td></tr>
|
||||
<tr><th>Ort:</th><td><input type="text" v-model="form.city" class="form-input" /></td></tr>
|
||||
<tr><th>Medikamente:</th><td><input type="text" v-model="form.medications" class="form-input" /></td></tr>
|
||||
<tr><th>Allergien:</th><td><input type="text" v-model="form.allergies" class="form-input" /></td></tr>
|
||||
<tr><th>Unverträglichkeiten:</th><td><input type="text" v-model="form.intolerances" class="form-input" /></td></tr>
|
||||
<tr><th>Kontoinhaber:</th><td><input type="text" v-model="form.bank_account_owner" class="form-input" /></td></tr>
|
||||
<tr><th>IBAN:</th><td><input type="text" v-model="form.bank_account_iban" class="form-input" /></td></tr>
|
||||
<tr><th>Stamm:</th><td>
|
||||
<select v-if="isLvTenant" v-model="form.local_group" class="form-input">
|
||||
<option v-for="group in localGroups" :key="group.slug" :value="group.slug">{{ group.name }}</option>
|
||||
</select>
|
||||
<span v-else>{{ getGroupName(form.local_group) }}</span>
|
||||
</td></tr>
|
||||
<tr><th>Rolle (Stamm):</th><td>
|
||||
<select v-model="form.user_role_local_group" class="form-input">
|
||||
<option v-for="role in userRoles" :key="role.slug" :value="role.slug">{{ role.name }}</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><th>Rolle (LV):</th><td>
|
||||
<select v-if="isLvTenant && !isOwnUser" v-model="form.user_role_main" class="form-input">
|
||||
<option v-for="role in userRoles" :key="role.slug" :value="role.slug">{{ role.name }}</option>
|
||||
</select>
|
||||
<span v-else>{{ getRoleName(form.user_role_main) }}</span>
|
||||
</td></tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="save">Speichern</button>
|
||||
<button class="btn-cancel" @click="editing = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.detail-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.detail-header h3 {
|
||||
margin: 0;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.detail-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 6px 12px;
|
||||
width: 180px;
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.9rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.badge-inactive {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #991b1b;
|
||||
background-color: #fee2e2;
|
||||
border: 1px solid #ef4444;
|
||||
}
|
||||
|
||||
.btn-edit, .btn-save, .btn-cancel, .btn-reset, .btn-deactivate, .btn-activate, .btn-close {
|
||||
padding: 6px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-edit:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.btn-reset {
|
||||
background-color: #f59e0b;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-reset:hover {
|
||||
background-color: #d97706;
|
||||
}
|
||||
|
||||
.btn-deactivate {
|
||||
background-color: #ef4444;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-deactivate:hover {
|
||||
background-color: #dc2626;
|
||||
}
|
||||
|
||||
.btn-activate {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-activate:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
background-color: #6b7280;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-close:hover {
|
||||
background-color: #4b5563;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,121 @@
|
||||
<script setup>
|
||||
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
import TabbedPage from "../../../Views/Components/TabbedPage.vue";
|
||||
import TenantContact from "./Partials/TenantContact.vue";
|
||||
import TenantPayment from "./Partials/TenantPayment.vue";
|
||||
import TenantImpress from "./Partials/TenantImpress.vue";
|
||||
import TenantGdpr from "./Partials/TenantGdpr.vue";
|
||||
import TenantPaymentMethods from "./Partials/TenantPaymentMethods.vue";
|
||||
import TenantTaxInfo from "./Partials/TenantTaxInfo.vue";
|
||||
|
||||
const props = defineProps({
|
||||
tenant: Object,
|
||||
})
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
title: 'Kontaktdaten',
|
||||
component: TenantContact,
|
||||
endpoint: '/api/v1/admin/tenant/contact',
|
||||
},
|
||||
{
|
||||
title: 'IBAN-Informationen',
|
||||
component: TenantPayment,
|
||||
endpoint: '/api/v1/admin/tenant/payment',
|
||||
},
|
||||
{
|
||||
title: 'Zahlungsmodule',
|
||||
component: TenantPaymentMethods,
|
||||
endpoint: '/api/v1/admin/tenant/payment-methods',
|
||||
},
|
||||
{
|
||||
title: 'Steuerinformationen',
|
||||
component: TenantTaxInfo,
|
||||
endpoint: '/api/v1/admin/tenant/tax',
|
||||
},
|
||||
{
|
||||
title: 'Impressum',
|
||||
component: TenantImpress,
|
||||
endpoint: '/api/v1/admin/tenant/impress',
|
||||
},
|
||||
{
|
||||
title: 'Datenschutzerklärung',
|
||||
component: TenantGdpr,
|
||||
endpoint: '/api/v1/admin/tenant/gdpr',
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout :title="props.tenant.slug === 'lv' ? 'LV-Daten' : 'Stammesdaten'">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||
<table class="tenant-header">
|
||||
<tr><th>Name</th><td>{{ props.tenant.name }}</td></tr>
|
||||
<tr><th>Slug</th><td>{{ props.tenant.slug }}</td></tr>
|
||||
<tr><th>mareike-URL:</th><td>{{ props.tenant.url }}</td></tr>
|
||||
<tr><th>Status</th><td>
|
||||
<span :class="props.tenant.is_active_local_group ? 'badge-active' : 'badge-inactive'">
|
||||
{{ props.tenant.is_active_local_group ? 'Aktiv' : 'Inaktiv' }}
|
||||
</span>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<div style="margin-top: 30px;">
|
||||
<tabbed-page :tabs="tabs" />
|
||||
</div>
|
||||
</shadowed-box>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tenant-header {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tenant-header th {
|
||||
text-align: left;
|
||||
padding: 10px 16px;
|
||||
width: 200px;
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
background-color: #f9fafb;
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
}
|
||||
|
||||
.tenant-header td {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
}
|
||||
|
||||
.tenant-header tr:last-child th,
|
||||
.tenant-header tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.badge-inactive {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #991b1b;
|
||||
background-color: #fee2e2;
|
||||
border: 1px solid #ef4444;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup>
|
||||
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
import TabbedPage from "../../../Views/Components/TabbedPage.vue";
|
||||
import TenantGeneral from "./Partials/TenantGeneral.vue";
|
||||
import TenantContact from "./Partials/TenantContact.vue";
|
||||
import TenantPayment from "./Partials/TenantPayment.vue";
|
||||
import TenantImpress from "./Partials/TenantImpress.vue";
|
||||
import TenantGdpr from "./Partials/TenantGdpr.vue";
|
||||
import TenantTaxInfo from "./Partials/TenantTaxInfo.vue";
|
||||
|
||||
const props = defineProps({
|
||||
tenant: Object,
|
||||
})
|
||||
|
||||
const slug = props.tenant.slug
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
title: 'Allgemeines',
|
||||
component: TenantGeneral,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/general',
|
||||
},
|
||||
{
|
||||
title: 'Kontaktdaten',
|
||||
component: TenantContact,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/contact',
|
||||
},
|
||||
{
|
||||
title: 'IBAN-Informationen',
|
||||
component: TenantPayment,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/payment',
|
||||
},
|
||||
{
|
||||
title: 'Steuerinformationen',
|
||||
component: TenantTaxInfo,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/tax',
|
||||
},
|
||||
{
|
||||
title: 'Impressum',
|
||||
component: TenantImpress,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/impress',
|
||||
},
|
||||
{
|
||||
title: 'Datenschutzerklärung',
|
||||
component: TenantGdpr,
|
||||
endpoint: '/api/v1/admin/tenants/' + slug + '/gdpr',
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout :title="props.tenant.name">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||
<tabbed-page :tabs="tabs" />
|
||||
</shadowed-box>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
@@ -0,0 +1,248 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
||||
import { toast } from "vue3-toastify";
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
function openTenant(slug) {
|
||||
window.location.href = '/admin/tenants/' + slug
|
||||
}
|
||||
|
||||
const tenants = ref([])
|
||||
const showCreate = ref(false)
|
||||
const createForm = ref({
|
||||
name: '',
|
||||
slug: '',
|
||||
url: '',
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await loadTenants()
|
||||
})
|
||||
|
||||
async function loadTenants() {
|
||||
const response = await fetch('/api/v1/admin/tenants/list', {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
const data = await response.json()
|
||||
tenants.value = data.tenants
|
||||
}
|
||||
|
||||
async function createTenant() {
|
||||
const response = await request('/api/v1/admin/tenants/create', {
|
||||
method: 'POST',
|
||||
body: createForm.value,
|
||||
})
|
||||
|
||||
if (response && response.status === 'success') {
|
||||
toast.success(response.message)
|
||||
showCreate.value = false
|
||||
createForm.value = { name: '', slug: '', url: '' }
|
||||
await loadTenants()
|
||||
} else {
|
||||
toast.error(response?.message ?? 'Fehler beim Anlegen')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout title="Stämme">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||
<table class="tenant-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Slug</th>
|
||||
<th>URL</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="tenant in tenants" :key="tenant.slug" class="tenant-row" @click="openTenant(tenant.slug)">
|
||||
<td>{{ tenant.name }}</td>
|
||||
<td>{{ tenant.slug }}</td>
|
||||
<td>{{ tenant.url }}</td>
|
||||
<td>
|
||||
<span :class="tenant.is_active_local_group ? 'badge-active' : 'badge-inactive'">
|
||||
{{ tenant.is_active_local_group ? 'Aktiv' : 'Inaktiv' }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<button v-if="!showCreate" class="btn-create" @click="showCreate = true">Neuen Stamm anlegen</button>
|
||||
|
||||
<div v-if="showCreate" class="create-form">
|
||||
<h3>Neuen Stamm anlegen</h3>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td><input type="text" v-model="createForm.name" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Slug</th>
|
||||
<td><input type="text" v-model="createForm.slug" class="form-input" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>URL</th>
|
||||
<td><input type="text" v-model="createForm.url" class="form-input" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="btn-group">
|
||||
<button class="btn-save" @click="createTenant">Anlegen</button>
|
||||
<button class="btn-cancel" @click="showCreate = false">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</shadowed-box>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tenant-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tenant-table thead th {
|
||||
text-align: left;
|
||||
padding: 10px 16px;
|
||||
background-color: #f9fafb;
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
border-bottom: 2px solid #d1d5db;
|
||||
}
|
||||
|
||||
.tenant-table tbody td {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.tenant-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tenant-row:hover {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.badge-inactive {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #991b1b;
|
||||
background-color: #fee2e2;
|
||||
border: 1px solid #ef4444;
|
||||
}
|
||||
|
||||
.create-form {
|
||||
margin-top: 15px;
|
||||
padding: 20px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
|
||||
.create-form h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.form-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.form-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
width: 100px;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.form-table td {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn-create {
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
background-color: #1d4899;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-create:hover {
|
||||
background-color: #163a7a;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.btn-save, .btn-cancel {
|
||||
padding: 8px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background-color: #16a34a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background-color: #15803d;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background-color: #e5e7eb;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,167 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
import FullScreenModal from "../../../Views/Components/FullScreenModal.vue";
|
||||
import UserDetail from "./Partials/UserDetail.vue";
|
||||
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
||||
|
||||
const { request } = useAjax()
|
||||
|
||||
const props = defineProps({
|
||||
isLvTenant: Boolean,
|
||||
})
|
||||
|
||||
const users = ref([])
|
||||
const selectedUserId = ref(null)
|
||||
const userDetail = ref(null)
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUsers()
|
||||
})
|
||||
|
||||
async function loadUsers() {
|
||||
const response = await fetch('/api/v1/admin/users/list', {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
const data = await response.json()
|
||||
users.value = data.users
|
||||
}
|
||||
|
||||
async function selectUser(userId) {
|
||||
if (selectedUserId.value === userId) {
|
||||
selectedUserId.value = null
|
||||
userDetail.value = null
|
||||
return
|
||||
}
|
||||
|
||||
selectedUserId.value = userId
|
||||
const response = await fetch('/api/v1/admin/users/' + userId, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
userDetail.value = await response.json()
|
||||
}
|
||||
|
||||
function onUserUpdated() {
|
||||
loadUsers()
|
||||
if (selectedUserId.value) {
|
||||
selectUser(selectedUserId.value)
|
||||
}
|
||||
}
|
||||
|
||||
function onDetailClosed() {
|
||||
selectedUserId.value = null
|
||||
userDetail.value = null
|
||||
loadUsers()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminAppLayout title="Benutzer*innen">
|
||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||
<table class="user-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nachname</th>
|
||||
<th>Vorname</th>
|
||||
<th>Pfadiname</th>
|
||||
<th v-if="props.isLvTenant">Stamm</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in users"
|
||||
:key="user.id"
|
||||
:class="['user-row', { 'user-row-selected': selectedUserId === user.id }]"
|
||||
@click="selectUser(user.id)">
|
||||
<td>{{ user.lastname }}</td>
|
||||
<td>{{ user.firstname }}</td>
|
||||
<td>{{ user.nickname }}</td>
|
||||
<td v-if="props.isLvTenant">{{ user.local_group_name }}</td>
|
||||
<td>
|
||||
<span :class="user.active ? 'badge-active' : 'badge-inactive'">
|
||||
{{ user.active ? 'Aktiv' : 'Inaktiv' }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</shadowed-box>
|
||||
|
||||
<FullScreenModal :show="userDetail !== null" @close="onDetailClosed">
|
||||
<UserDetail
|
||||
v-if="userDetail"
|
||||
:data="userDetail"
|
||||
@updated="onUserUpdated"
|
||||
@closed="onDetailClosed"
|
||||
/>
|
||||
</FullScreenModal>
|
||||
</AdminAppLayout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.user-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-table thead th {
|
||||
text-align: left;
|
||||
padding: 10px 16px;
|
||||
background-color: #f9fafb;
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
border-bottom: 2px solid #d1d5db;
|
||||
}
|
||||
|
||||
.user-table tbody td {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.user-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.user-row:hover {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
|
||||
.user-row-selected {
|
||||
background-color: #eff6ff;
|
||||
}
|
||||
|
||||
.badge-active {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #166534;
|
||||
background-color: #dcfce7;
|
||||
border: 1px solid #22c55e;
|
||||
}
|
||||
|
||||
.badge-inactive {
|
||||
display: inline-block;
|
||||
padding: 3px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: #991b1b;
|
||||
background-color: #fee2e2;
|
||||
border: 1px solid #ef4444;
|
||||
}
|
||||
</style>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user