{% extends 'core/base.html' %}
{% block title %}Staff Performance - SwiftPOS{% endblock %}
{% block topbar_title %}Staff Performance{% endblock %}

{% block content %}
<div class="container-fluid px-0">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <div>
            <h5 class="mb-0">Staff Performance Overview</h5>
            <div class="small text-muted">Based on completed POS orders.</div>
        </div>
    </div>

    <div class="card">
        <div class="card-body p-0">
        <div class="sp-table-container">
            <table class="table table-sm mb-0">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Staff</th>
                        <th>Role</th>
                        <th>Total Orders</th>
                        <th>Total Sales ({{ currency_symbol }})</th>
                        <!-- <th>Estimated Profit ({{ currency_symbol }})</th> -->
                        <th>Unusual Txns</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in staff_stats %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ row.user.get_full_name|default:row.user.username }}</td>
                            <td>{{ row.user.get_role_display }}</td>
                            <td>{{ row.total_orders }}</td>
                            <td>{{ currency_symbol }}{{ row.total_sales|floatformat:2 }}</td>
                            <!-- <td class="{% if row.total_profit < 0 %}text-danger{% else %}text-success{% endif %}">
                                {{ currency_symbol }}{{ row.total_profit|floatformat:2 }}
                            </td> -->
                            <td>
                                {% if row.unusual_transactions %}
                                    <span class="badge bg-danger">{{ row.unusual_transactions }}</span>
                                {% else %}
                                    <span class="badge bg-success">0</span>
                                {% endif %}
                            </td>
                        </tr>
                    {% empty %}
                        <tr>
                            <td colspan="7" class="text-center text-muted py-3">
                                No staff performance data yet.
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    </div>
</div>
{% endblock %}
