Files
breadcrumb-the-shire/pages/admin/tenants/edit(default).phtml
2026-02-04 23:31:53 +01:00

372 lines
14 KiB
PHTML

<?php
/**
* @var array<int, string> $errors
* @var array $form
* @var array $tenant
*/
use MintyPHP\Session;
use MintyPHP\Service\TenantAvatarService;
use MintyPHP\Service\TenantFaviconService;
$values = $form ?? $tenant ?? [];
$isReadOnly = !can('tenants.update');
$avatarUuid = (string) ($values['uuid'] ?? '');
$hasAvatar = $avatarUuid !== '' && TenantAvatarService::hasAvatar($avatarUuid);
$hasFavicon = $avatarUuid !== '' && TenantFaviconService::hasFavicon($avatarUuid);
?>
<div class="app-details-container">
<section>
<div class="app-breadcrumb">
<a href="/admin">Startseite</a><i class="bi bi-chevron-right"></i><a
href="/admin/tenants"><?php e(t('Tenants')); ?></a><i
class="bi bi-chevron-right"></i><?php e(t('Edit tenant')); ?>
</div>
<div class="app-details-titlebar">
<h1>
<a href="admin/tenants" title="<?php e(t('Cancel')); ?>"><i class="bi bi-arrow-left"></i></a>
<?php e(t('Edit tenant')); ?>
</h1>
<div class="app-details-titlebar-actions">
<?php if (can('tenants.delete')): ?>
<details class="dropdown">
<summary role="button" class="outline secondary"><i class="bi bi-three-dots"></i></summary>
<ul dir="rtl">
<li>
<form method="post" action="admin/tenants/delete/<?php e($values['uuid'] ?? ''); ?>"
onsubmit="return confirm('<?php e(t('Delete this tenant?')); ?>');">
<?php Session::getCsrfInput(); ?>
<button type="submit" class="transparent">
<?php e(t('Delete')); ?>
</button>
</form>
</li>
</ul>
</details>
<?php endif; ?>
<?php if (can('tenants.update')): ?>
<button type="submit" form="tenant-form" name="action" value="save" class="secondary outline">
<?php e(t('Save')); ?>
</button>
<button type="submit" form="tenant-form" name="action" value="save_close" class="primary">
<?php e(t('Save & close')); ?>
</button>
<?php endif; ?>
</div>
</div>
<?php if (!empty($errors)): ?>
<div class="app-details-errors">
<div class="notice" data-variant="error">
<ul>
<?php foreach ($errors as $error): ?>
<li><?php e($error); ?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
<?php
$detailsOpenAll = false;
$isReadOnly = $isReadOnly ?? false;
require __DIR__ . '/_form.phtml';
?>
</section>
<aside id="app-details-aside-section">
<div class="app-details-aside-section">
<div class="entity-avatar-block avatar-size-auto avatar-borderless">
<?php if ($hasAvatar): ?>
<a data-fslightbox="tenant-avatar" href="admin/tenants/avatar-file?uuid=<?php e($avatarUuid); ?>&size=256">
<img class="entity-avatar-image" src="admin/tenants/avatar-file?uuid=<?php e($avatarUuid); ?>&size=128"
alt="<?php e(t('Tenant image')); ?>">
</a>
<?php endif; ?>
</div>
<hgroup>
<h2><?php e($values['description'] ?? ''); ?></h2>
<p><?php e(t('Tenant')); ?></p>
</hgroup>
<hr>
<?php if (can('tenants.update')): ?>
<details name="tenant-avatar">
<summary>
<?php e(t('Upload image')); ?>
</summary>
<hr>
<form class="user-avatar-form" method="post" action="admin/tenants/avatar/<?php e($avatarUuid); ?>"
enctype="multipart/form-data">
<label class="user-avatar-upload">
<input type="file" name="avatar" accept="image/*">
</label>
<div class="grid">
<button type="submit" class="primary">
<?php e(t('Save')); ?>
</button>
<?php if ($hasAvatar): ?>
<button data-tooltip-pos="top" data-tooltip="<?php e(t('Remove image')); ?>" type="submit" class="danger" formaction="admin/tenants/avatar-delete/<?php e($avatarUuid); ?>"
formmethod="post">
<i class="bi bi-trash3-fill"></i>
</button>
<?php endif; ?>
</div>
<?php Session::getCsrfInput(); ?>
</form>
</details>
<?php endif; ?>
<hr>
<?php if (can('tenants.update')): ?>
<details name="tenant-favicon">
<summary>
<?php e(t('Upload favicon')); ?>
</summary>
<hr>
<?php if ($hasFavicon): ?>
<div class="entity-avatar-block avatar-square avatar-borderless" style="--avatar-size: 48px;">
<img class="entity-avatar-image"
src="<?php e(asset('favicon/tenants/' . $avatarUuid . '/favicon-32x32.png')); ?>"
alt="<?php e(t('Favicon')); ?>">
</div>
<small><?php e(t('Favicon preview')); ?></small>
<hr>
<?php endif; ?>
<small><?php e(t('Allowed file types: PNG')); ?></small>
<small><?php e(t('Square images are recommended (icons are center-cropped).')); ?></small>
<hr>
<form class="user-avatar-form" method="post" action="admin/tenants/favicon/<?php e($avatarUuid); ?>"
enctype="multipart/form-data">
<label class="user-avatar-upload">
<input type="file" name="favicon" accept="image/png">
</label>
<div class="grid">
<button type="submit" class="primary">
<?php e(t('Save')); ?>
</button>
<?php if ($hasFavicon): ?>
<button type="submit" class="danger" formaction="admin/tenants/favicon-delete/<?php e($avatarUuid); ?>" formmethod="post">
<?php e(t('Remove favicon')); ?>
</button>
<?php endif; ?>
</div>
<?php Session::getCsrfInput(); ?>
</form>
</details>
<?php endif; ?>
<hr>
<?php
$phone = trim((string) ($values['phone'] ?? ''));
$fax = trim((string) ($values['fax'] ?? ''));
$email = trim((string) ($values['email'] ?? ''));
$supportEmail = trim((string) ($values['support_email'] ?? ''));
$supportPhone = trim((string) ($values['support_phone'] ?? ''));
$billingEmail = trim((string) ($values['billing_email'] ?? ''));
$website = trim((string) ($values['website'] ?? ''));
$privacyUrl = trim((string) ($values['privacy_url'] ?? ''));
$imprintUrl = trim((string) ($values['imprint_url'] ?? ''));
$statusValue = (string) ($values['status'] ?? 'active');
?>
<details name="tenant-contact">
<summary><?php e(t('Contact')); ?></summary>
<hr>
<?php if ($supportEmail !== '' || $supportPhone !== '' || $billingEmail !== '' || $email !== '' || $phone !== '' || $fax !== '' || $website !== ''): ?>
<?php if ($supportEmail !== ''): ?>
<div>
<small><?php e(t('Support email')); ?></small>
<p><a href="mailto:<?php e($supportEmail); ?>"><?php e($supportEmail); ?></a></p>
</div>
<?php endif; ?>
<?php if ($supportPhone !== ''): ?>
<div>
<small><?php e(t('Support phone')); ?></small>
<p><a href="tel:<?php e($supportPhone); ?>"><?php e($supportPhone); ?></a></p>
</div>
<?php endif; ?>
<?php if ($billingEmail !== ''): ?>
<div>
<small><?php e(t('Billing email')); ?></small>
<p><a href="mailto:<?php e($billingEmail); ?>"><?php e($billingEmail); ?></a></p>
</div>
<?php endif; ?>
<?php if ($email !== ''): ?>
<div>
<small><?php e(t('Email')); ?></small>
<p><a href="mailto:<?php e($email); ?>"><?php e($email); ?></a></p>
</div>
<?php endif; ?>
<?php if ($phone !== ''): ?>
<div>
<small><?php e(t('Phone')); ?></small>
<p><a href="tel:<?php e($phone); ?>"><?php e($phone); ?></a></p>
</div>
<?php endif; ?>
<?php if ($fax !== ''): ?>
<div>
<small><?php e(t('Fax')); ?></small>
<div><?php e($fax); ?></div>
</div>
<?php endif; ?>
<?php if ($website !== ''): ?>
<div>
<small><?php e(t('Website')); ?></small>
<div>
<a href="<?php e($website); ?>" target="_blank" rel="noopener noreferrer">
<?php e($website); ?>
</a>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<p>-</p>
<?php endif; ?>
</details>
<hr>
<details name="tenant-legal">
<summary><?php e(t('Legal')); ?></summary>
<hr>
<?php if ($privacyUrl !== '' || $imprintUrl !== ''): ?>
<?php if ($privacyUrl !== ''): ?>
<div>
<small><?php e(t('Privacy URL')); ?></small>
<p>
<a href="<?php e($privacyUrl); ?>" target="_blank" rel="noopener noreferrer">
<?php e($privacyUrl); ?>
</a>
</p>
</div>
<?php endif; ?>
<?php if ($imprintUrl !== ''): ?>
<div>
<small><?php e(t('Imprint URL')); ?></small>
<p>
<a href="<?php e($imprintUrl); ?>" target="_blank" rel="noopener noreferrer">
<?php e($imprintUrl); ?>
</a>
</p>
</div>
<?php endif; ?>
<?php else: ?>
<p>-</p>
<?php endif; ?>
</details>
<hr>
<?php
$createdByLabel = $values['created_by_label'] ?? '';
$createdById = $values['created_by'] ?? null;
$createdByUuid = $values['created_by_uuid'] ?? null;
$modifiedByLabel = $values['modified_by_label'] ?? '';
$modifiedById = $values['modified_by'] ?? null;
$modifiedByUuid = $values['modified_by_uuid'] ?? null;
$statusChangedByLabel = $values['status_changed_by_label'] ?? '';
$statusChangedById = $values['status_changed_by'] ?? null;
$statusChangedByUuid = $values['status_changed_by_uuid'] ?? null;
?>
<details name="tenant-status">
<summary><?php e(t('Status')); ?></summary>
<hr>
<div>
<small><?php e(t('Status')); ?></small>
<p><?php e($statusValue !== '' ? t(ucfirst($statusValue)) : '-'); ?></p>
</div>
<div>
<small><?php e(t('Status changed')); ?></small>
<p><?php e(dt($values['status_changed_at'] ?? '') ?: '-'); ?></p>
</div>
<div>
<small><?php e(t('Status changed by')); ?></small>
<p>
<?php if ($statusChangedByLabel !== ''): ?>
<?php if ($statusChangedByUuid): ?>
<a href="admin/users/edit/<?php e($statusChangedByUuid); ?>"><?php e($statusChangedByLabel); ?></a>
<?php else: ?>
<?php e($statusChangedByLabel); ?>
<?php endif; ?>
<?php elseif ($statusChangedById): ?>
<?php e('#' . $statusChangedById); ?>
<?php else: ?>
-
<?php endif; ?>
</p>
</div>
</details>
<hr>
<details name="tenant-audit">
<summary><?php e(t('Audit')); ?></summary>
<hr>
<div>
<small><?php e(t('Created')); ?></small>
<p><?php e(dt($values['created'] ?? '') ?: '-'); ?></p>
</div>
<div>
<small><?php e(t('Created by')); ?></small>
<p>
<?php if ($createdByLabel !== ''): ?>
<?php if ($createdByUuid): ?>
<a href="admin/users/edit/<?php e($createdByUuid); ?>"><?php e($createdByLabel); ?></a>
<?php else: ?>
<?php e($createdByLabel); ?>
<?php endif; ?>
<?php elseif ($createdById): ?>
<?php e('#' . $createdById); ?>
<?php else: ?>
-
<?php endif; ?>
</p>
</div>
<div>
<small><?php e(t('Modified')); ?></small>
<p><?php e(dt($values['modified'] ?? '') ?: '-'); ?></p>
</div>
<div>
<small><?php e(t('Modified by')); ?></small>
<p>
<?php if ($modifiedByLabel !== ''): ?>
<?php if ($modifiedByUuid): ?>
<a href="admin/users/edit/<?php e($modifiedByUuid); ?>"><?php e($modifiedByLabel); ?></a>
<?php else: ?>
<?php e($modifiedByLabel); ?>
<?php endif; ?>
<?php elseif ($modifiedById): ?>
<?php e('#' . $modifiedById); ?>
<?php else: ?>
-
<?php endif; ?>
</p>
</div>
</details>
<hr>
<div class="grid">
<div>
<small>
<?php e(t('UUID')); ?>
</small>
<p>
<span class="badge" data-variant="neutral" data-copy="true"
data-copy-value="<?php e($values['uuid'] ?? ''); ?>">
<?php
$uuidValue = (string) ($values['uuid'] ?? '');
$uuidDisplay = $uuidValue !== '' ? substr($uuidValue, 0, 10) : '-';
e($uuidDisplay);
?>
</span>
</p>
</div>
<div>
<small>
<?php e(t('ID')); ?>
</small>
<p>
<span class="badge" data-variant="neutral" data-copy="true"
data-copy-value="<?php e($values['id'] ?? ''); ?>">
<?php e($values['id'] ?? '-'); ?>
</span>
</p>
</div>
</div>
</div>
</aside>
</div>