Many fixes
This commit is contained in:
@@ -1,220 +1,245 @@
|
||||
{% extends 'superadmin/layout.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="sa-header">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Организация: {{ organization.name }}</h1>
|
||||
<a href="{{ base_url('/superadmin/organizations') }}" class="btn btn-primary">← Назад</a>
|
||||
<a href="{{ base_url('/superadmin/organizations') }}" class="btn btn-outline-secondary">
|
||||
<i class="fa-solid fa-arrow-left"></i> Назад к списку
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% for alert in get_alerts() %}
|
||||
<div class="alert alert-{{ alert.type }}">{{ alert.message }}</div>
|
||||
<div class="alert alert-{{ alert.type }}">{{ alert.message }}</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="grid-2">
|
||||
<div class="sa-card">
|
||||
<div class="sa-card-header">
|
||||
<h2>Информация об организации</h2>
|
||||
</div>
|
||||
<div class="sa-card-body">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th style="width: 150px;">ID</th>
|
||||
<td>{{ organization.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<td>{{ organization.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Тип</th>
|
||||
<td>
|
||||
{% if organization.type == 'business' %}
|
||||
<span class="badge badge-info">Бизнес</span>
|
||||
{% else %}
|
||||
<span class="badge badge-warning">Личное пространство</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Тариф</th>
|
||||
<td>
|
||||
{% if currentSubscription %}
|
||||
{% set plan = plans|filter(p => p.id == currentSubscription.plan_id)|first %}
|
||||
{% if plan %}
|
||||
<span class="badge badge-primary">{{ plan.name }}</span>
|
||||
{% else %}
|
||||
<span class="badge badge-secondary">ID: {{ currentSubscription.plan_id }}</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="badge badge-secondary">Не назначен</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Статус подписки</th>
|
||||
<td>
|
||||
{% if currentSubscription %}
|
||||
{% if currentSubscription.status == 'active' %}
|
||||
<span class="badge badge-success">Активна</span>
|
||||
{% elseif currentSubscription.status == 'expired' %}
|
||||
<span class="badge badge-danger">Истёкшая</span>
|
||||
{% elseif currentSubscription.status == 'trial' %}
|
||||
<span class="badge badge-info">Пробный период</span>
|
||||
{% else %}
|
||||
<span class="badge badge-warning">{{ currentSubscription.status }}</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="badge badge-secondary">Нет подписки</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Срок действия</th>
|
||||
<td>
|
||||
{% if currentSubscription and currentSubscription.expires_at %}
|
||||
до {{ currentSubscription.expires_at|date('d.m.Y H:i') }}
|
||||
{% else %}
|
||||
Не ограничен
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Статус организации</th>
|
||||
<td>
|
||||
{% if organization.status == 'active' %}
|
||||
<span class="badge badge-success">Активна</span>
|
||||
{% elseif organization.status == 'blocked' %}
|
||||
<span class="badge badge-danger">Заблокирована</span>
|
||||
{% else %}
|
||||
<span class="badge badge-warning">{{ organization.status|default('Не определён') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Создана</th>
|
||||
<td>{{ organization.created_at|date('d.m.Y H:i') }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap;">
|
||||
{% if organization.status == 'active' %}
|
||||
<a href="{{ base_url('/superadmin/organizations/block/' ~ organization.id) }}" class="btn btn-warning" onclick="return confirm('Заблокировать организацию?')">🚫 Заблокировать</a>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Подписки на модули</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if subscriptions is empty %}
|
||||
<p class="text-muted text-center py-4">У организации нет активных подписок</p>
|
||||
{% else %}
|
||||
<a href="{{ base_url('/superadmin/organizations/unblock/' ~ organization.id) }}" class="btn btn-success" onclick="return confirm('Разблокировать организацию?')">✅ Разблокировать</a>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Модуль</th>
|
||||
<th>Статус</th>
|
||||
<th>Истекает</th>
|
||||
<th>Создана</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for sub in subscriptions %}
|
||||
{% set module = allModules[sub.module_code] %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ module.name|default(sub.module_code) }}</strong>
|
||||
<div class="text-muted small">{{ module.description|default('') }}</div>
|
||||
</td>
|
||||
<td>
|
||||
{% if sub.status == 'active' %}
|
||||
<span class="badge bg-success">Активна</span>
|
||||
{% elseif sub.status == 'trial' %}
|
||||
<span class="badge bg-info">Триал</span>
|
||||
{% elseif sub.status == 'expired' %}
|
||||
<span class="badge bg-danger">Истекла</span>
|
||||
{% else %}
|
||||
<span class="badge bg-warning">{{ sub.status }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if sub.expires_at %}
|
||||
{{ sub.expires_at|date('d.m.Y H:i') }}
|
||||
{% else %}
|
||||
<span class="text-muted">Бессрочно</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ sub.created_at|date('d.m.Y H:i') }}</td>
|
||||
<td>
|
||||
<a href="{{ base_url('/superadmin/organizations/' ~ organization.id ~ '/removeSubscription/' ~ sub.id) }}"
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
onclick="return confirm('Удалить подписку на модуль {{ module.name|default(sub.module_code) }}?')"
|
||||
title="Удалить подписку">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Участники организации</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if users is empty %}
|
||||
<p class="text-muted text-center py-4">Участников пока нет</p>
|
||||
{% else %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Пользователь</th>
|
||||
<th>Email</th>
|
||||
<th>Роль</th>
|
||||
<th>Статус</th>
|
||||
<th>Дата добавления</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.name|default('—') }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<span class="badge {{ user.role == 'owner' ? 'bg-danger' : (user.role == 'admin' ? 'bg-warning' : 'bg-info') }}">
|
||||
{{ user.role }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.status == 'active' %}
|
||||
<span class="badge bg-success">Активен</span>
|
||||
{% elseif user.status == 'blocked' %}
|
||||
<span class="badge bg-danger">Заблокирован</span>
|
||||
{% else %}
|
||||
<span class="badge bg-warning">{{ user.status }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.created_at|date('d.m.Y') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{{ base_url('/superadmin/organizations/delete/' ~ organization.id) }}" class="btn btn-danger" onclick="return confirm('Удалить организацию? Это действие нельзя отменить!')">🗑️ Удалить</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sa-card">
|
||||
<div class="sa-card-header">
|
||||
<h2>Управление тарифом</h2>
|
||||
</div>
|
||||
<div class="sa-card-body">
|
||||
<form action="{{ base_url('/superadmin/organizations/set-plan/' ~ organization.id) }}" method="post">
|
||||
{{ csrf_field()|raw }}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="plan_id">Выберите тариф</label>
|
||||
<select name="plan_id" id="plan_id" class="form-control" required>
|
||||
<option value="">-- Выберите тариф --</option>
|
||||
{% for plan in plans %}
|
||||
<option value="{{ plan.id }}" {{ currentSubscription and currentSubscription.plan_id == plan.id ? 'selected' : '' }}>
|
||||
{{ plan.name }} - {{ plan.price }} {{ plan.currency }}/{{ plan.billing_period }}
|
||||
<div class="col-md-4">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Добавить подписку</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ base_url('/superadmin/organizations/' ~ organization.id ~ '/add-subscription') }}" method="post">
|
||||
{{ csrf_field()|raw }}
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Модуль</label>
|
||||
<select name="module_code" class="form-select" required>
|
||||
<option value="">Выберите модуль...</option>
|
||||
{% for code, module in allModules %}
|
||||
{% set hasSub = false %}
|
||||
{% for sub in subscriptions %}
|
||||
{% if sub.module_code == code %}
|
||||
{% set hasSub = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<option value="{{ code }}" {{ hasSub ? 'disabled style="background-color: #f8f9fa;"' : '' }}>
|
||||
{{ module.name }} - {{ module.price_monthly }} руб/мес {{ hasSub ? '(уже есть)' : '' }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="duration_days">Срок действия (дней)</label>
|
||||
<input type="number" name="duration_days" id="duration_days" class="form-control"
|
||||
value="30" min="0" max="365000" placeholder="30">
|
||||
<small class="text-muted">Оставьте пустым или 0 для неограниченного срока</small>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Назначить тариф</button>
|
||||
</form>
|
||||
|
||||
<hr style="margin: 20px 0; border: none; border-top: 1px solid #eee;">
|
||||
|
||||
<h4>Статистика</h4>
|
||||
<div style="text-align: center; padding: 20px;">
|
||||
<div style="font-size: 48px; font-weight: bold; color: #3498db;">{{ users|length }}</div>
|
||||
<div style="color: #7f8c8d;">Участников</div>
|
||||
</div>
|
||||
<hr style="margin: 20px 0; border: none; border-top: 1px solid #eee;">
|
||||
<div style="display: flex; justify-content: space-around; text-align: center;">
|
||||
<div>
|
||||
<div style="font-size: 24px; font-weight: bold; color: #27ae60;">
|
||||
{% set owner_count = users|filter(u => u.role == 'owner')|length %}
|
||||
{{ owner_count }}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div style="color: #7f8c8d; font-size: 12px;">Владельцы</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 24px; font-weight: bold; color: #f39c12;">
|
||||
{% set admin_count = users|filter(u => u.role == 'admin')|length %}
|
||||
{{ admin_count }}
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Срок действия (дней)</label>
|
||||
<input type="number" name="duration_days" class="form-control" value="30" min="0">
|
||||
<div class="form-text">0 - бессрочно</div>
|
||||
</div>
|
||||
<div style="color: #7f8c8d; font-size: 12px;">Админы</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 24px; font-weight: bold; color: #9b59b6;">
|
||||
{% set manager_count = users|filter(u => u.role == 'manager')|length %}
|
||||
{{ manager_count }}
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Статус</label>
|
||||
<select name="status" class="form-select">
|
||||
<option value="active">Активна</option>
|
||||
<option value="trial">Триал</option>
|
||||
<option value="expired">Истекла</option>
|
||||
<option value="cancelled">Отменена</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="color: #7f8c8d; font-size: 12px;">Менеджеры</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<i class="fa-solid fa-plus"></i> Добавить подписку
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sa-card" style="margin-top: 20px;">
|
||||
<div class="sa-card-header">
|
||||
<h2>Участники организации</h2>
|
||||
</div>
|
||||
<div class="sa-card-body">
|
||||
{% if users is empty %}
|
||||
<p style="color: #7f8c8d; text-align: center; padding: 40px;">Участников пока нет</p>
|
||||
{% else %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Информация</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th>Пользователь</th>
|
||||
<th>Email</th>
|
||||
<th>Роль</th>
|
||||
<th>Статус</th>
|
||||
<th>Дата добавления</th>
|
||||
<td>ID</td>
|
||||
<td class="text-end">{{ organization.id }}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.name|default('—') }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<span class="badge {{ user.role == 'owner' ? 'badge-danger' : (user.role == 'admin' ? 'badge-warning' : 'badge-info') }}">
|
||||
{{ user.role }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.status == 'active' %}
|
||||
<span class="badge badge-success">Активен</span>
|
||||
{% elseif user.status == 'blocked' %}
|
||||
<span class="badge badge-danger">Заблокирован</span>
|
||||
<td>Тип</td>
|
||||
<td class="text-end">
|
||||
{% if organization.type == 'business' %}
|
||||
<span class="badge bg-info">Бизнес</span>
|
||||
{% else %}
|
||||
<span class="badge badge-warning">{{ user.status }}</span>
|
||||
<span class="badge bg-warning">Личное</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.created_at|date('d.m.Y') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>Статус</td>
|
||||
<td class="text-end">
|
||||
{% if organization.status == 'active' %}
|
||||
<span class="badge bg-success">Активна</span>
|
||||
{% elseif organization.status == 'blocked' %}
|
||||
<span class="badge bg-danger">Заблокирована</span>
|
||||
{% else %}
|
||||
<span class="badge bg-warning">{{ organization.status }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Создана</td>
|
||||
<td class="text-end">{{ organization.created_at|date('d.m.Y H:i') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Участников</td>
|
||||
<td class="text-end">{{ users|length }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column gap-2">
|
||||
{% if organization.status == 'active' %}
|
||||
<a href="{{ base_url('/superadmin/organizations/block/' ~ organization.id) }}"
|
||||
class="btn btn-warning"
|
||||
onclick="return confirm('Заблокировать организацию?')">
|
||||
<i class="fa-solid fa-ban"></i> Заблокировать
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ base_url('/superadmin/organizations/unblock/' ~ organization.id) }}"
|
||||
class="btn btn-success"
|
||||
onclick="return confirm('Разблокировать организацию?')">
|
||||
<i class="fa-solid fa-check"></i> Разблокировать
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ base_url('/superadmin/organizations/delete/' ~ organization.id) }}"
|
||||
class="btn btn-danger"
|
||||
onclick="return confirm('Удалить организацию? Это действие нельзя отменить!')">
|
||||
<i class="fa-solid fa-trash"></i> Удалить организацию
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user