Files
3d-pricing/templates/stats.html
T

85 lines
3.0 KiB
HTML

{% extends 'base.html' %}
{% block title %}Statistiques{% endblock %}
{% block content %}
<div class="page-header d-flex justify-content-between align-items-center">
<h1><i class="bi bi-bar-chart-line me-2 text-success"></i>Statistiques</h1>
<a href="{{ url_for('export_csv') }}" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-download me-1"></i>Export CSV
</a>
</div>
<div class="row g-4">
<!-- Par client -->
<div class="col-md-7">
<div class="card">
<div class="card-header py-3">CA par client</div>
<div class="card-body p-0">
{% if by_client %}
<table class="table table-hover mb-0">
<thead class="table-light">
<tr><th>Client</th><th>Commandes</th><th>Marge moy.</th><th class="text-end">CA total</th></tr>
</thead>
<tbody>
{% set total_rev = by_client | sum(attribute='revenue') %}
{% for c in by_client %}
<tr>
<td class="fw-semibold">{{ c.name }}</td>
<td>{{ c.jobs }}</td>
<td><span class="badge bg-light text-dark">{{ c.avg_margin }}%</span></td>
<td class="text-end">
<span class="fw-bold" style="color:#ff6b35">{{ c.revenue }} €</span>
{% if total_rev > 0 %}
<div class="progress mt-1" style="height:4px">
<div class="progress-bar" style="width:{{ (c.revenue / total_rev * 100)|round(0) }}%;background:#ff6b35"></div>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="text-center text-muted py-4">Aucune donnée disponible.</div>
{% endif %}
</div>
</div>
</div>
<!-- Par mois -->
<div class="col-md-5">
<div class="card">
<div class="card-header py-3">CA par mois (12 derniers)</div>
<div class="card-body p-0">
{% if by_month %}
<table class="table table-hover mb-0">
<thead class="table-light">
<tr><th>Mois</th><th>Cmds</th><th class="text-end">CA</th></tr>
</thead>
<tbody>
{% set max_rev = by_month | map(attribute='revenue') | max %}
{% for m in by_month %}
<tr>
<td class="fw-semibold">{{ m.month }}</td>
<td>{{ m.jobs }}</td>
<td class="text-end">
<span class="fw-bold">{{ m.revenue }} €</span>
{% if max_rev > 0 %}
<div class="progress mt-1" style="height:4px">
<div class="progress-bar bg-success" style="width:{{ (m.revenue / max_rev * 100)|round(0) }}%"></div>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="text-center text-muted py-4">Aucune donnée disponible.</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}