124 lines
4.8 KiB
HTML
124 lines
4.8 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Customer Management{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="row mb-4 align-items-center">
|
|
<div class="col">
|
|
<h2><i class="bi bi-person-badge"></i> Customer Management</h2>
|
|
<p class="text-muted mb-0">Manage portal access for all customer accounts.</p>
|
|
</div>
|
|
<div class="col-auto d-flex gap-2">
|
|
<a href="{{ url_for('customers.bulk_import') }}" class="btn btn-outline-success">
|
|
<i class="bi bi-upload"></i> Import CSV
|
|
</a>
|
|
<a href="{{ url_for('customers.create') }}" class="btn btn-primary">
|
|
<i class="bi bi-person-plus"></i> New Customer
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{% if customers %}
|
|
<div class="card shadow-sm">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Username</th>
|
|
<th>Full Name</th>
|
|
<th>Email</th>
|
|
<th>Status</th>
|
|
<th>Assigned Projects</th>
|
|
<th>Accessible Facilities</th>
|
|
<th>Created</th>
|
|
<th width="160"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for customer in customers %}
|
|
{% set assignments = assignment_map[customer.id] %}
|
|
{% set facility_ids = scope_map[customer.id] %}
|
|
<tr class="{{ 'table-secondary text-muted' if not customer.active else '' }}">
|
|
<td>
|
|
<strong>
|
|
<a href="{{ url_for('customers.manage', customer_id=customer.id) }}"
|
|
class="text-decoration-none">
|
|
{{ customer.username }}
|
|
</a>
|
|
</strong>
|
|
</td>
|
|
<td>{{ customer.full_name or '—' }}</td>
|
|
<td class="small text-muted">{{ customer.email }}</td>
|
|
<td>
|
|
{% if customer.active %}
|
|
<span class="badge bg-success">Active</span>
|
|
{% else %}
|
|
<span class="badge bg-secondary">Disabled</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if assignments %}
|
|
{% set project_names = assignments | map(attribute='project') | map(attribute='name') | unique | list %}
|
|
{% for pname in project_names %}
|
|
<span class="badge bg-primary me-1">{{ pname }}</span>
|
|
{% endfor %}
|
|
{% else %}
|
|
<span class="text-muted small">— None —</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if facility_ids %}
|
|
<span class="badge bg-info text-dark">{{ facility_ids|length }} facilit{{ 'y' if facility_ids|length == 1 else 'ies' }}</span>
|
|
{% else %}
|
|
<span class="text-muted small">— None —</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="small text-muted">{{ customer.created_at.strftime('%Y-%m-%d') }}</td>
|
|
<td class="text-end">
|
|
<a href="{{ url_for('customers.manage', customer_id=customer.id) }}"
|
|
class="btn btn-sm btn-outline-primary" title="Manage">
|
|
<i class="bi bi-gear"></i>
|
|
</a>
|
|
<a href="{{ url_for('customers.edit', customer_id=customer.id) }}"
|
|
class="btn btn-sm btn-outline-secondary" title="Edit">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
<form method="POST"
|
|
action="{{ url_for('customers.toggle_active', customer_id=customer.id) }}"
|
|
class="d-inline">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button type="submit"
|
|
class="btn btn-sm {{ 'btn-outline-warning' if customer.active else 'btn-outline-success' }}"
|
|
title="{{ 'Disable' if customer.active else 'Enable' }}"
|
|
onclick="return confirm('{{ 'Disable' if customer.active else 'Enable' }} {{ customer.username }}?')">
|
|
<i class="bi bi-{{ 'person-slash' if customer.active else 'person-check' }}"></i>
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# ── Summary footer ── #}
|
|
<div class="mt-3 text-muted small">
|
|
{{ customers|length }} customer account{{ 's' if customers|length != 1 else '' }} total
|
|
· {{ customers|selectattr('active')|list|length }} active
|
|
</div>
|
|
|
|
{% else %}
|
|
<div class="card shadow-sm">
|
|
<div class="card-body text-center py-5 text-muted">
|
|
<i class="bi bi-person-badge fs-1 d-block mb-3 opacity-25"></i>
|
|
<p class="mb-3">No customer accounts have been created yet.</p>
|
|
<a href="{{ url_for('customers.create') }}" class="btn btn-primary">
|
|
<i class="bi bi-person-plus"></i> Create First Customer
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|