<div class="col card--ui" id="card--dashboard">

    <a class="btn--ui lightGrey" href="/presence_reports"><i class="fa-solid fa-arrow-left"></i></a>

    <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
        <div class="title--section_name d-flex align-items-center justify-content-between">
            <i class="ico--ui title_section utenti me-2"></i>
            <h2 class="primary">Assenze</h2>
        </div>
    </header>
    
    <div class="row mb-2">
        <div class="col">
            <div class="alert alert-warning text-center" role="alert">Attenzione: se un utente viene aggiunto manualmente a un corso diverso da quello a cui è associato, l'utente continuerà a risultare assente nel corso a cui è regolarmente iscritto.</div>
        </div>
    </div>
    
    <div class="row mb-2">
        <div class="col">
            <div class="alert alert-info text-center" role="alert">I dati sono aggiornati al giorno precedente della data odierna.</div>
        </div>
    </div>

    <div class="row mb-3">
        <div class="col-8"></div>
        <div class="col text-end">
            <div class="input-group">
                <input type="text" class="form-control" placeholder="Cerca utente" aria-label="Cerca utente" wire:model.defer="search">
            </div>
        </div>
        <div class="col-auto text-end">
            <button class="btn--ui" type="button" wire:click="resetSearch()">Reset</button>
            &nbsp;
            <button class="btn--ui" type="button" wire:click="applySearch()">Cerca</button>
        </div>
    </div>

    @foreach ($record_assenze as $record_data)
        <div class="row mb-5">
            <div class="col-12 mb-2">
                <h3 class="primary">{{$record_data['course']['name']}}</h3>
            </div>
            <div class="col-12">
                <table class="report-table">
                    <thead>
                        <tr>
                            <td style="width: 20%">Cognome</td>
                            <td style="width: 20%">Nome</td>
                            <td style="width: 10%">N. assenze</td>
                            <td>Date</td>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($record_data['members'] as $member)
                        <tr @if($loop->index % 2 == 1)style="background-color: rgba(12 97 151 / 0.05);"@endif>
                            <td>{{$member['member']['last_name']}}</td>
                            <td>{{$member['member']['first_name']}}</td>
                            <td>{{$member["count"]}}</td>
                            <td>
                                @foreach ($member["dates"] as $calendar_date)
                                    <a href="/presences?calendarId={{$calendar_date['calendar_id']}}" target="_blank">{{$calendar_date['date']}}</a>@if (!$loop->last) - @endif
                                @endforeach
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    @endforeach
    {{-- <div class="row">
        <div class="col-12 mb-3">
            <h3 class="primary">Assenze {{$year}}/{{$year+1}}</h3>
        </div>
        <div class="col-12">
            <table class="report-table">
                <thead>
                    <tr>
                        <td>Cognome</td>
                        <td>Nome</td>
                        <td>Corso</td>
                        <td>N. assenze</td>
                        <td>Date</td>
                    </tr>
                </thead>
                <tbody>
                    @foreach($records as $record)
                    <tr>
                        <td>{{$record["last_name"]}}</td>
                        <td>{{$record["first_name"]}}</td>
                        <td>{{$record["course"]}}</td>
                        <td>{{$record["total"]}}</td>
                        <td>{{$record["date"]}}</td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div> --}}
</div>

@push('css')
<link href="/css/presence_report.css" rel="stylesheet" />
@endpush

@push('scripts')
<link href="/css/datatables.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
@endpush

@push('scripts')
<script>
    $(document).ready(function() {});
</script>
@endpush