<?php $query = "SELECT id_buku, judul_buku FROM buku";
$result = mysqli_query($koneksi, $query); ?>
<div id="tambahpeminjam" tabindex="-1" aria-hidden="true" class="hidden fixed top-0 right-0 left-0 z-50 flex justify-center items-center w-full md:inset-0 h-screen bg-opacity-50">
    <div class="relative p-4 w-full max-w-md">
        <div class="relative bg-white rounded-lg shadow">
            <div class="flex items-center justify-between p-4 border-b rounded-t">
                <h3 class="text-lg font-semibold text-gray-">Tambah peminjam</h3>
                <button type="button" data-modal-hide="tambahpeminjam" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center" id="close-modal">
                    <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
                    </svg>
                    <span class="sr-only">Close modal</span>
                </button>
            </div>
            <form action="peminjam/tambahaksi.php" method="POST" enctype="multipart/form-data" class="p-4">
                <div class="grid gap-4 mb-4">
                    <div class="col-span-2">
                        <label for="nama_peminjam" class="block mb-2 text-sm font-medium text-gray-900">Nama peminjam</label>
                        <input type="text" name="nama_peminjam" id="nama_peminjam" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-600 focus:border-blue-600 block w-full p-2.5" placeholder="Masukkan nama peminjam" required>
                    </div>
                    <div class="col-span-2">
                        <label for="email" class="block mb-2 text-sm font-medium text-gray-900">Email</label>
                        <input type="text" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-600 focus:border-blue-600 block w-full p-2.5" placeholder="Masukkan email" required>
                    </div>
                    <div class="col-span-2">
                        <label for="no_telp" class="block mb-2 text-sm font-medium text-gray-900">Nomor telefon</label>
                        <input type="text" name="no_telp" id="no_telp" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-600 focus:border-blue-600 block w-full p-2.5" placeholder="Masukkan no. telefon" required>
                    </div>
                    <div class="col-span-2">
                        <label for="id_buku" class="block mb-2 text-sm font-medium text-gray-900">Buku yang ingin dipinjam</label>
                        <select id="id_buku" name="id_buku" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-600 focus:border-blue-600 block w-full p-2.5" required>
                            <option value="">Pilih Buku</option>
                            <?php while ($row = mysqli_fetch_assoc($result)) : ?>
                                <option value="<?= $row['id_buku']; ?>"><?= $row['judul_buku']; ?></option>
                            <?php endwhile; ?>
                        </select>
                    </div>  
                </div>

                <div class="flex justify-end">
                    <button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">
                        Tambah peminjam
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>