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

{% block content %}
<div class="container mt-4">
    <div class="card shadow-sm" style="max-width: 600px; margin: 0 auto;">
        <div class="card-header bg-danger text-white">
            <h4 class="mb-0"><i class="fas fa-door-closed me-2"></i> {% trans "Close Session" %}</h4>
        </div>
        <div class="card-body">
            <div class="row mb-4">
                <div class="col-md-6">
                    <strong>{% trans "Started At:" %}</strong><br>
                    {{ session.start_time }}
                </div>
                <div class="col-md-6">
                    <strong>{% trans "Opening Balance:" %}</strong><br>
                    {{ session.opening_balance }}
                </div>
            </div>
            
            <div class="card bg-light mb-3">
                <div class="card-body">
                    <h5>{% trans "Session Summary (System)" %}</h5>
                    <table class="table table-sm">
                        <tr>
                            <td>{% trans "Total Sales:" %}</td>
                            <td class="text-end fw-bold">{{ total_sales|floatformat:3 }}</td>
                        </tr>
                        {% for pm in payments %}
                        <tr>
                            <td>{{ pm.payment_method_name }}</td>
                            <td class="text-end">{{ pm.total|floatformat:3 }}</td>
                        </tr>
                        {% endfor %}
                    </table>
                </div>
            </div>

            <form method="post">
                {% csrf_token %}
                <div class="mb-3">
                    <label class="form-label">{% trans "Closing Cash Balance (Counted)" %}</label>
                    {{ form.closing_balance }}
                    <div class="form-text">{% trans "Enter the actual cash amount found in the drawer." %}</div>
                </div>
                <div class="mb-3">
                    <label class="form-label">{% trans "Notes" %}</label>
                    {{ form.notes }}
                </div>
                <div class="d-grid">
                    <button type="submit" class="btn btn-danger">{% trans "Close Session" %}</button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}
