{% extends 'base.html' %}

{% block menuapp %}

{% include 'repostajes/_menu-repostajes.html' %}

{% endblock menuapp %}

{% block content %}
<div class="container-xl">
    <div class="app-card app-card-notification shadow-sm mb-4">
        <div class="app-card-header px-4 py-3">
            <div class="row g-3 align-items-center">
                <div class="col-12 col-lg-auto text-center text-lg-start">
                    {% if vehiculo.foto %}
                    <p><img src="{{ vehiculo.foto.url }}" alt="{{ vehiculo.matricula}}" width="187" height="115"></p>
                    {% else %}
                    <p>No hay imágen disponible</p>
                    {% endif %}
                </div>
                <div class="col-12 col-lg-auto text-center text-lg-start">
                    <h4>{{ vehiculo.matricula }}</h4>

                    <ul class="notification-meta list-inline mb-0">
                        <li class="list-inline-item">{{ vehiculo.matricula }}</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="app-card-body p-4">

            {% if repostajes %}
                <table class="table app-table-hover mb-0 text-left">
                    <thead>
                        <tr>
                            <th class="cell">Fecha</th>
                            <th class="cell">Kilómetros</th>
                            <th class="cell">Litros</th>
                            <th class="cell">Importe</th>
                            <th class="cell">Descuento</th>
                            <th class="cell">Precio por litro</th>
                            <th class="cell">Kms recorridos</th>
                            <th class="cell">Consumo/100 kms</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for repostaje in repostajes %}
                        <tr>
                            <td class="cell"><a href="{% url 'repostajes:detalle_repostaje' repostaje.id %}">{{ repostaje.fecha }}</a></td>
                            <td class="cell">{{ repostaje.kms }}</td>
                            <td class="cell">{{ repostaje.litros }}</td>
                            <td class="cell">{{ repostaje.importe }}</td>
                            <td class="cell">{{ repostaje.descuento }}</td>
                            <td class="cell">{{ repostaje.precioxlitro }}</td>
                            <td class="cell">{{ repostaje.kmsrecorridos }}</td>
                            <td class="cell">{{ repostaje.consumo }}</td>
                        </tr>
                        {% endfor %}	
                    </tbody>
                </table>
            {% else %}
                <p>No se han encontrado repostajes para este vehiculo</p>
            {% endif %}
        </div>
    </div>

    <div class="row g-3 mb-4 align-items-center justify-content-between">
        <div class="col-auto">
            <a class="btn app-btn-secondary" href="{% url 'repostajes:lista_repostajes' %}">Volver al inicio</a>
        </div>

        <div class="col-auto">
            <a class="btn app-btn-primary" href="{% url 'repostajes:nuevo_repostaje' %}">Añadir repostaje</a> <!-- Faltaría poner el id del vehiculo-->
        </div>
    </div>
</div>
{% endblock %}

