{% extends "admin/change_list.html" %}
{% block content %}
<div class="container-fluid">
    
    <div class="row mt-4">
        <div class="col">
            <div class="card shadow-sm mb-2 db-graph">
                <div class="card-header p-2">
                    <h6 class="text-white m-0 font-md">Журнал синхронизации</h6>
                </div>
                <div class="card-body">
                    <form method="post" action="{% url 'antifroud:sync_log_create' %}">
                        {% csrf_token %}
                        <div class="form-row">
                            <div class="col-md-9 col-xl-9">
                                <div class="box-bg">
                                    <div class="form-row">
                                        <div class="col-md-2 col-xl-2 align-self-center font-md text-dark-blue">
                                            <label class="col-form-label p-0" for="hotel-id"><strong>Отель:</strong></label>
                                        </div>
                                        <div class="col-md-4 col-xl-3">
                                            <div class="form-group mb-0">
                                                <select class="custom-select custom-select-sm font-sm" name="hotel" id="hotel-id">
                                                    <option value="">--Выберите Отель --</option>
                                                    {% for hotel in hotels %}
                                                        <option value="{{ hotel.id }}">{{ hotel.name }}</option>
                                                    {% endfor %}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xl-3">
                                <div class="box-bg">
                                    <div class="text-dark form-row">
                                        <div class="col-xl-5 offset-xl-0 align-self-center">
                                            <h6 class="mb-0 font-sm">Полученные записи:</h6>
                                        </div>
                                        <div class="col-xl-7 offset-xl-0 text-right align-self-center">
                                            <div class="form-group mb-1">
                                                <input class="form-control form-control-sm form-control font-sm" type="number" name="received_records" required />
                                            </div>
                                        </div>
                                        <div class="col-xl-5 offset-xl-0 align-self-center">
                                            <h6 class="mb-0 font-sm">Обработанные записи:</h6>
                                        </div>
                                        <div class="col-xl-7 offset-xl-0 text-right align-self-center">
                                            <div class="form-group mb-1">
                                                <input class="form-control form-control-sm form-control font-sm" type="number" name="processed_records" required />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                    
                    <!-- Список существующих журналов синхронизации -->
                    <div class="table-responsive tbl-wfx mt-1 kot-table">
                        <table class="table table-sm">
                            <thead class="text-dark font-md">
                                <tr class="text-dark-blue">
                                    <th>#</th>
                                    <th>Отель</th>
                                    <th>ID бронирования</th>
                                    <th>Обработанные записи</th>
                                    <th>Полученные записи</th>
                                    <th>Создан</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for log in sync_logs %}
                                <tr>
                                    <td>{{ log.id }}</td>
                                    <td>{{ log.hotel.name }}</td>
                                    <td>{{ log.reservation_id }}</td>
                                    <td>{{ log.processed_records }}</td>
                                    <td>{{ log.recieved_records }}</td>
                                    <td>{{ log.created }}</td>
                                </tr>
                                {% empty %}
                                <tr>
                                    <td colspan="6" class="text-center">Нет журналов.</td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}