{% extends 'base.html' %}
{% load i18n static %}

{% block content %}
<div class="container-fluid mt-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2><i class="fas fa-list-alt me-2"></i> {% trans "Cashier Sessions" %}</h2>
    </div>

    <div class="card shadow-sm">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead class="table-light">
                        <tr>
                            <th>{% trans "ID" %}</th>
                            <th>{% trans "Cashier" %}</th>
                            <th>{% trans "Counter" %}</th>
                            <th>{% trans "Start Time" %}</th>
                            <th>{% trans "End Time" %}</th>
                            <th>{% trans "Status" %}</th>
                            <th>{% trans "Actions" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for session in sessions %}
                        <tr>
                            <td>#{{ session.id }}</td>
                            <td>{{ session.user.username }}</td>
                            <td>{{ session.counter.name|default:"-" }}</td>
                            <td>{{ session.start_time|date:"Y-m-d H:i" }}</td>
                            <td>{{ session.end_time|date:"Y-m-d H:i"|default:"-" }}</td>
                            <td>
                                <span class="badge bg-{% if session.status == 'active' %}success{% else %}secondary{% endif %}">
                                    {{ session.get_status_display }}
                                </span>
                            </td>
                            <td>
                                <a href="{% url 'session_detail' pk=session.pk %}" class="btn btn-sm btn-info text-white">
                                    <i class="fas fa-eye"></i>
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="7" class="text-center text-muted">{% trans "No sessions found." %}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}
