@extends('layouts.app')

@section('content')

<div class="container">

<h1>Laporan Data Pengunjung</h1>

<div style="margin: 20px 0;">
    <form method="GET" action="{{ route('laporan.export.excel') }}" style="display:inline-block;">
        <select name="month" style="padding: 10px; border-radius: 5px; border: 1px solid #ccc;">
            <option value="">Semua Bulan</option>
            @for ($i = 1; $i <= 12; $i++)
                <option value="{{ $i }}">{{ DateTime::createFromFormat('!m', $i)->format('F') }}</option>
            @endfor
        </select>
        <button type="submit" style="padding: 10px 15px; background: #198754; color: white; border: none; border-radius: 5px; cursor: pointer;">Download Excel</button>
    </form>
</div>

<div style="margin: 20px 0;">
    <strong>Unduhan per bulan:</strong>
</div>

<div style="display:flex; flex-wrap:wrap; gap:10px; margin-bottom:20px;">
    @for ($i = 1; $i <= 12; $i++)
        <a href="{{ route('laporan.export.excel', ['month' => $i]) }}" style="padding: 8px 12px; background: #198754; color: white; text-decoration:none; border-radius:5px;">Excel {{ DateTime::createFromFormat('!m', $i)->format('F') }}</a>
    @endfor
</div>


<div class="card">
    <h3>Total Pengunjung</h3>
    <h1>{{ $totalPengunjung }}</h1>
</div>


<br>


<h2>Riwayat Pengunjung</h2>


<table border="1" width="100%" cellpadding="10">

<tr>
    <th>No</th>
    <th>Nama</th>
    <th>Instansi</th>
    <th>Keperluan</th>
    <th>Tanggal</th>
</tr>


@foreach($dataPengunjung as $data)

<tr>
    <td>{{ $loop->iteration }}</td>
    <td>{{ $data->nama }}</td>
    <td>{{ $data->instansi }}</td>
    <td>{{ $data->keperluan }}</td>
    <td>{{ $data->created_at }}</td>
</tr>

@endforeach


</table>


<br>


<h2>Laporan Bulanan</h2>

<table border="1" width="50%" cellpadding="10">

<tr>
    <th>Bulan</th>
    <th>Jumlah Pengunjung</th>
</tr>


@foreach($laporanBulanan as $laporan)

<tr>
    <td>{{ $laporan->bulan }}</td>
    <td>{{ $laporan->jumlah }}</td>
</tr>

@endforeach


</table>


</div>


@endsection