Files

91 lines
5.4 KiB
HTML

{% extends "base.html" %}
{% block title %}Utility Providers{% endblock %}
{% block page_title %}Utility Providers{% endblock %}
{% block topbar_actions %}
<a href="{{ url_for('utilities.index') }}" class="btn btn-sm btn-outline-secondary" style="font-size:12px;">← Utilities</a>
<a href="{{ url_for('utilities.provider_new') }}" class="btn btn-sm btn-primary" style="font-size:12px;"><i class="bi bi-plus-lg me-1"></i><span class="btn-label">Add Provider</span></a>
{% endblock %}
{% block content %}
{% if providers %}
<div class="pcard p-0">
<div class="table-wrap">
<table class="pfm-table wide">
<thead>
<tr>
<th>Provider</th>
<th>Type</th>
<th class="d-mob-none">Account No.</th>
<th class="d-mob-none">Unit</th>
<th class="d-mob-none">Pays From</th>
<th class="text-end">Bills</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for p in providers %}
<tr {% if not p.is_active %}style="opacity:.55;"{% endif %}>
<td>
<div class="d-flex align-items-center gap-2">
<div style="width:30px;height:30px;border-radius:8px;background:{{ p.color }}22;color:{{ p.color }};display:flex;align-items:center;justify-content:center;font-size:15px;flex-shrink:0;">
<i class="bi {{ p.icon }}"></i>
</div>
<div>
<a href="{{ url_for('utilities.provider_detail', id=p.id) }}" style="font-size:13px;font-weight:600;text-decoration:none;color:inherit;">{{ p.name }}</a>
{% if not p.is_active %}<span class="badge bg-secondary" style="font-size:9px;">Archived</span>{% endif %}
{% if p.billing_day %}<div style="font-size:11px;color:var(--muted);">Bills on day {{ p.billing_day }}</div>{% endif %}
</div>
</div>
</td>
<td style="font-size:12px;">{{ p.type_label }}</td>
<td class="d-mob-none mono" style="font-size:12px;color:var(--muted);">{{ p.account_number or '—' }}</td>
<td class="d-mob-none" style="font-size:12px;">{{ p.usage_unit or '—' }}</td>
<td class="d-mob-none" style="font-size:12px;">{{ p.default_account.name if p.default_account else '—' }}</td>
<td class="text-end mono" style="font-size:12px;">{{ counts[p.id] }}</td>
<td class="text-end">
<div class="dropdown">
<button class="btn btn-sm" style="background:none;border:none;color:var(--muted);padding:2px 6px;" data-bs-toggle="dropdown"><i class="bi bi-three-dots"></i></button>
<ul class="dropdown-menu dropdown-menu-end" style="font-size:13px;">
<li><a class="dropdown-item" href="{{ url_for('utilities.provider_detail', id=p.id) }}"><i class="bi bi-graph-up me-2"></i>History &amp; Usage</a></li>
<li><a class="dropdown-item" href="{{ url_for('utilities.bill_new', provider_id=p.id) }}"><i class="bi bi-plus-circle me-2"></i>Add Bill</a></li>
<li><a class="dropdown-item" href="{{ url_for('utilities.provider_edit', id=p.id) }}"><i class="bi bi-pencil me-2"></i>Edit</a></li>
<li><hr class="dropdown-divider"></li>
<li>
<form method="POST" action="{{ url_for('utilities.provider_toggle', id=p.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="dropdown-item">
<i class="bi bi-{{ 'arrow-counterclockwise' if not p.is_active else 'archive' }} me-2"></i>{{ 'Reactivate' if not p.is_active else 'Archive' }}
</button>
</form>
</li>
<li>
<form method="POST" action="{{ url_for('utilities.provider_delete', id=p.id) }}"
onsubmit="return confirm('Delete {{ p.name }}{% if counts[p.id] %} and its {{ counts[p.id] }} bill(s){% endif %}? This cannot be undone.')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="confirm_bills" value="yes">
<button type="submit" class="dropdown-item text-danger"><i class="bi bi-trash me-2"></i>Delete</button>
</form>
</li>
</ul>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<p class="text-muted mt-3" style="font-size:12px;">
Archiving hides a provider from the utilities dashboard but keeps its bill history. Deleting removes the bills too — payment transactions created by PFM are left in place.
</p>
{% else %}
<div class="pcard text-center py-5">
<i class="bi bi-building text-muted" style="font-size:3rem;"></i>
<h5 class="mt-3 mb-1">No providers yet</h5>
<p class="text-muted small mb-3">Add electricity, water, gas, and internet providers to start tracking.</p>
<a href="{{ url_for('utilities.provider_new') }}" class="btn btn-primary btn-sm">Add First Provider</a>
</div>
{% endif %}
{% endblock %}