354 lines
15 KiB
PHTML
354 lines
15 KiB
PHTML
<?php
|
|
/**
|
|
* @var array $tenants
|
|
* @var array $roles
|
|
* @var array $departments
|
|
* @var array $values
|
|
* @var array $settings
|
|
*/
|
|
|
|
use MintyPHP\Session;
|
|
use MintyPHP\Service\BrandingLogoService;
|
|
use MintyPHP\Service\BrandingFaviconService;
|
|
|
|
$values = $values ?? [];
|
|
$settings = $settings ?? [];
|
|
$defaultTenantId = (int) ($values['default_tenant_id'] ?? 0);
|
|
$defaultRoleId = (int) ($values['default_role_id'] ?? 0);
|
|
$defaultDepartmentId = (int) ($values['default_department_id'] ?? 0);
|
|
$appTitle = (string) ($values['app_title'] ?? '');
|
|
$appLocale = (string) ($values['app_locale'] ?? '');
|
|
$appTheme = (string) ($values['app_theme'] ?? '');
|
|
$appThemeUser = !empty($values['app_theme_user']);
|
|
$appPrimaryColor = (string) ($values['app_primary_color'] ?? '');
|
|
$smtpHost = (string) ($values['smtp_host'] ?? '');
|
|
$smtpPort = (string) ($values['smtp_port'] ?? '');
|
|
$smtpUser = (string) ($values['smtp_user'] ?? '');
|
|
$smtpSecure = (string) ($values['smtp_secure'] ?? '');
|
|
$smtpFrom = (string) ($values['smtp_from'] ?? '');
|
|
$smtpFromName = (string) ($values['smtp_from_name'] ?? '');
|
|
$defaultTenantDesc = $settings['default_tenant']['description'] ?? 'setting.default_tenant';
|
|
$defaultRoleDesc = $settings['default_role']['description'] ?? 'setting.default_role';
|
|
$defaultDepartmentDesc = $settings['default_department']['description'] ?? 'setting.default_department';
|
|
$appTitleDesc = $settings['app_title']['description'] ?? 'setting.app_title';
|
|
$appLocaleDesc = $settings['app_locale']['description'] ?? 'setting.app_locale';
|
|
$appThemeDesc = $settings['app_theme']['description'] ?? 'setting.app_theme';
|
|
$appThemeUserDesc = $settings['app_theme_user']['description'] ?? 'setting.app_theme_user';
|
|
$appPrimaryColorDesc = $settings['app_primary_color']['description'] ?? 'setting.app_primary_color';
|
|
$smtpHostDesc = $settings['smtp_host']['description'] ?? 'setting.smtp_host';
|
|
$smtpPortDesc = $settings['smtp_port']['description'] ?? 'setting.smtp_port';
|
|
$smtpUserDesc = $settings['smtp_user']['description'] ?? 'setting.smtp_user';
|
|
$smtpPasswordDesc = $settings['smtp_password']['description'] ?? 'setting.smtp_password';
|
|
$smtpSecureDesc = $settings['smtp_secure']['description'] ?? 'setting.smtp_secure';
|
|
$smtpFromDesc = $settings['smtp_from']['description'] ?? 'setting.smtp_from';
|
|
$smtpFromNameDesc = $settings['smtp_from_name']['description'] ?? 'setting.smtp_from_name';
|
|
$locales = defined('APP_LOCALES') ? APP_LOCALES : [];
|
|
$hasLogo = BrandingLogoService::hasLogo();
|
|
$hasFavicon = BrandingFaviconService::hasFavicon();
|
|
$canUpdateSettings = can('settings.update');
|
|
$isReadOnly = !$canUpdateSettings;
|
|
$readonlyAttr = $isReadOnly ? 'readonly' : '';
|
|
$disabledAttr = $isReadOnly ? 'disabled' : '';
|
|
?>
|
|
|
|
<div class="app-details-container">
|
|
<section>
|
|
<div class="app-breadcrumb">
|
|
<a href="/admin">Startseite</a><i class="bi bi-chevron-right"></i><?php e(t('Settings')); ?>
|
|
</div>
|
|
<div class="app-details-titlebar">
|
|
<h1>
|
|
<?php e(t('Settings')); ?>
|
|
</h1>
|
|
<div class="app-details-titlebar-actions">
|
|
<?php if ($canUpdateSettings): ?>
|
|
<button type="submit" form="settings-form" class="primary">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="settings-form" method="post">
|
|
<input type="hidden" name="settings_submit" value="1">
|
|
<details name="general" open>
|
|
<summary><?php e(t('General')); ?></summary>
|
|
<hr>
|
|
<label class="app-field">
|
|
<span><?php e(t('App title')); ?></span>
|
|
<input type="text" name="app_title" value="<?php e($appTitle); ?>" placeholder="<?php e(APP_NAME); ?>" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($appTitleDesc)); ?></small>
|
|
</label>
|
|
</details>
|
|
<hr>
|
|
<details name="appearance">
|
|
<summary><?php e(t('Appearance')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<fieldset>
|
|
<legend><small><?php e(t('Default theme')); ?></small></legend>
|
|
<select name="app_theme" <?php e($disabledAttr); ?>>
|
|
<option value=""><?php e(t('None')); ?></option>
|
|
<option value="light" <?php e($appTheme === 'light' ? 'selected' : ''); ?>>
|
|
<?php e(t('Light')); ?>
|
|
</option>
|
|
<option value="dark" <?php e($appTheme === 'dark' ? 'selected' : ''); ?>>
|
|
<?php e(t('Dark')); ?>
|
|
</option>
|
|
</select>
|
|
<small><?php e(t($appThemeDesc)); ?></small>
|
|
</fieldset>
|
|
<fieldset>
|
|
<legend><small><?php e(t('Primary color')); ?></small></legend>
|
|
<label class="app-field">
|
|
<input type="color" name="app_primary_color"
|
|
value="<?php e($appPrimaryColor !== '' ? $appPrimaryColor : '#2fa4a4'); ?>" <?php e($disabledAttr); ?>>
|
|
<div>
|
|
<div>
|
|
<?php e(t('Choose color')); ?>
|
|
</div>
|
|
</div>
|
|
</label>
|
|
<small class="muted"><?php e(t($appPrimaryColorDesc)); ?></small>
|
|
</fieldset>
|
|
</div>
|
|
<blockquote data-variant="info">
|
|
<?php e(t('Tenants can override this color in their appearance settings.')); ?>
|
|
</blockquote>
|
|
<fieldset>
|
|
<legend>
|
|
<small>
|
|
<?php e(t($appThemeUserDesc)); ?>
|
|
</small>
|
|
</legend>
|
|
<label class="app-field">
|
|
<input type="checkbox" name="app_theme_user" value="1" <?php e($appThemeUser ? 'checked' : ''); ?> <?php e($disabledAttr); ?>>
|
|
<span><?php e(t('Allow user theme')); ?></span>
|
|
</label>
|
|
</fieldset>
|
|
</details>
|
|
<hr>
|
|
<details name="smtp">
|
|
<summary><?php e(t('Email settings')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP host')); ?></span>
|
|
<input type="text" name="smtp_host" value="<?php e($smtpHost); ?>" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpHostDesc)); ?></small>
|
|
</label>
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP port')); ?></span>
|
|
<input type="number" name="smtp_port" value="<?php e($smtpPort); ?>" min="1" max="65535" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpPortDesc)); ?></small>
|
|
</label>
|
|
</div>
|
|
<div class="grid">
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP user')); ?></span>
|
|
<input type="text" name="smtp_user" value="<?php e($smtpUser); ?>" autocomplete="username" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpUserDesc)); ?></small>
|
|
</label>
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP password')); ?></span>
|
|
<input type="password" name="smtp_password" value="" autocomplete="new-password" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpPasswordDesc)); ?></small>
|
|
</label>
|
|
</div>
|
|
<div class="grid">
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP security')); ?></span>
|
|
<select name="smtp_secure" <?php e($disabledAttr); ?>>
|
|
<option value=""><?php e(t('None')); ?></option>
|
|
<option value="tls" <?php e($smtpSecure === 'tls' ? 'selected' : ''); ?>>TLS</option>
|
|
<option value="ssl" <?php e($smtpSecure === 'ssl' ? 'selected' : ''); ?>>SSL</option>
|
|
</select>
|
|
<small><?php e(t($smtpSecureDesc)); ?></small>
|
|
</label>
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP from address')); ?></span>
|
|
<input type="email" name="smtp_from" value="<?php e($smtpFrom); ?>" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpFromDesc)); ?></small>
|
|
</label>
|
|
</div>
|
|
<label class="app-field">
|
|
<span><?php e(t('SMTP from name')); ?></span>
|
|
<input type="text" name="smtp_from_name" value="<?php e($smtpFromName); ?>" <?php e($readonlyAttr); ?>>
|
|
<small><?php e(t($smtpFromNameDesc)); ?></small>
|
|
</label>
|
|
</details>
|
|
<hr>
|
|
<details name="internationalization">
|
|
<summary><?php e(t('Internationalization')); ?></summary>
|
|
<hr>
|
|
<label class="app-field">
|
|
<span><?php e(t('Default language')); ?></span>
|
|
<select name="app_locale" <?php e($disabledAttr); ?>>
|
|
<option value=""><?php e(t('None')); ?></option>
|
|
<?php foreach ($locales as $locale): ?>
|
|
<?php
|
|
$label = strtoupper($locale);
|
|
if ($locale === 'de') {
|
|
$label = t('German');
|
|
} elseif ($locale === 'en') {
|
|
$label = t('English');
|
|
}
|
|
?>
|
|
<option value="<?php e($locale); ?>" <?php e($appLocale === $locale ? 'selected' : ''); ?>>
|
|
<?php e($label); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small><?php e(t($appLocaleDesc)); ?></small>
|
|
</label>
|
|
</details>
|
|
<hr>
|
|
<details name="user-creation">
|
|
<summary><?php e(t('User creation rules')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<label class="app-field">
|
|
<span>
|
|
<?php e(t('Default tenant')); ?>
|
|
</span>
|
|
<select name="default_tenant_id" <?php e($disabledAttr); ?>>
|
|
<option value="">
|
|
<?php e(t('None')); ?>
|
|
</option>
|
|
<?php foreach ($tenants ?? [] as $tenant): ?>
|
|
<?php $tenantId = (int) ($tenant['id'] ?? 0); ?>
|
|
<?php if ($tenantId > 0): ?>
|
|
<option value="<?php e((string) $tenantId); ?>" <?php e($tenantId === $defaultTenantId ? 'selected' : ''); ?>>
|
|
<?php e($tenant['description'] ?? ''); ?>
|
|
</option>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small>
|
|
<?php e(t($defaultTenantDesc)); ?>
|
|
</small>
|
|
</label>
|
|
<label class="app-field">
|
|
<span>
|
|
<?php e(t('Default department')); ?>
|
|
</span>
|
|
<select name="default_department_id" <?php e($disabledAttr); ?>>
|
|
<option value="">
|
|
<?php e(t('None')); ?>
|
|
</option>
|
|
<?php foreach ($departments ?? [] as $department): ?>
|
|
<?php $departmentId = (int) ($department['id'] ?? 0); ?>
|
|
<?php if ($departmentId > 0): ?>
|
|
<option value="<?php e((string) $departmentId); ?>" <?php e($departmentId === $defaultDepartmentId ? 'selected' : ''); ?>>
|
|
<?php e($department['description'] ?? ''); ?>
|
|
</option>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small>
|
|
<?php e(t($defaultDepartmentDesc)); ?>
|
|
</small>
|
|
</label>
|
|
</div>
|
|
|
|
<label class="app-field">
|
|
<span><?php e(t('Default role')); ?></span>
|
|
<select name="default_role_id" <?php e($disabledAttr); ?>>
|
|
<option value=""><?php e(t('None')); ?></option>
|
|
<?php foreach ($roles ?? [] as $role): ?>
|
|
<?php $roleId = (int) ($role['id'] ?? 0); ?>
|
|
<?php if ($roleId > 0): ?>
|
|
<option value="<?php e((string) $roleId); ?>" <?php e($roleId === $defaultRoleId ? 'selected' : ''); ?>>
|
|
<?php e($role['description'] ?? ''); ?>
|
|
</option>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small><?php e(t($defaultRoleDesc)); ?></small>
|
|
</label>
|
|
|
|
</details>
|
|
<hr>
|
|
<?php Session::getCsrfInput(); ?>
|
|
</form>
|
|
</section>
|
|
<aside id="app-details-aside-section">
|
|
<div class="app-details-aside-section">
|
|
<div class="entity-avatar-block avatar-square avatar-ratio-16-9 avatar-borderless">
|
|
<a data-fslightbox="app-logo" href="<?php e(appLogoUrl(256)); ?>">
|
|
<img class="entity-avatar-image" src="<?php e(appLogoUrl(256)); ?>" alt="<?php e(t('App logo')); ?>">
|
|
</a>
|
|
</div>
|
|
<hgroup>
|
|
<h2><?php e(appTitle()); ?></h2>
|
|
<p><?php e(t('Settings')); ?></p>
|
|
</hgroup>
|
|
<hr>
|
|
<?php if ($canUpdateSettings): ?>
|
|
<details name="app-logo">
|
|
<summary>
|
|
<?php e(t('Upload logo')); ?>
|
|
</summary>
|
|
<hr>
|
|
<small>
|
|
<?php e(t('Allowed file types: SVG, PNG, JPG, WEBP')); ?>
|
|
</small>
|
|
<hr>
|
|
<form class="user-avatar-form" method="post" action="admin/settings/logo" enctype="multipart/form-data">
|
|
<label class="user-avatar-upload">
|
|
<input type="file" name="logo" accept="image/svg+xml,image/png,image/jpeg,image/webp">
|
|
</label>
|
|
<div class="grid">
|
|
<button type="submit" class="primary">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
<?php if ($hasLogo): ?>
|
|
<button type="submit" class="danger" formaction="admin/settings/logo-delete" formmethod="post">
|
|
<?php e(t('Remove logo')); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php Session::getCsrfInput(); ?>
|
|
</form>
|
|
</details>
|
|
<?php endif; ?>
|
|
<hr>
|
|
<?php if ($canUpdateSettings): ?>
|
|
<details name="app-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/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/settings/favicon" 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/settings/favicon-delete" formmethod="post">
|
|
<?php e(t('Remove favicon')); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php Session::getCsrfInput(); ?>
|
|
</form>
|
|
</details>
|
|
<?php endif; ?>
|
|
</div>
|
|
</aside>
|
|
</div>
|