<!DOCTYPE html>
<html lang="en">

<head>
    <?= $this->include('layout/head') ?>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
</head>

<body>
<?= $this->include('layout/sidebar') ?>

<main id="main" class="main">
    <div class="pagetitle">
        <div class="container mt-4">
            <div class="card shadow">
                <div class="card-header text-white" style="background-color: #5c8978;">
                    <h5 class="mb-0">Form Tambah Data Guru</h5>
                </div>
                <div class="card-body">
                    <form action="<?= base_url('users/store') ?>" method="post">
                        <div class="row">
                <h2>Tambah Akun</h2>
                    <form action="/users/store" method="post">
                        <label>Nama</label>
                        <input type="text" name="nama" required><br>

                        <label>Username</label>
                        <input type="text" name="username" required><br>

                        <label>Password</label>
                        <input type="password" name="password" required><br>

                        <label>Role</label>
                        <select name="role" required onchange="document.getElementById('guruSelect').style.display = this.value === 'guru' ? 'block' : 'none'">
                            <option value="">-- Pilih --</option>
                            <option value="admin">Admin</option>
                            <option value="guru">Guru</option>
                            <option value="kepsek">Kepsek</option>
                        </select><br>

                        <div id="guruSelect" style="display:none;">
                            <label>Hubungkan ke Guru:</label>
                            <select name="id_guru">
                                <option value="">-- Pilih Guru --</option>
                                <?php foreach ($guru as $g): ?>
                                    <option value="<?= $g['id'] ?>"><?= $g['nama_guru'] ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        <br>
                    <div class="text-end mt-3">
                            <button type="submit" class="btn btn-success btn-sm me-2">
                                <i class="fas fa-upload"></i> Submit
                            </button>
                            <a href="<?= base_url('users') ?>" class="btn btn-secondary btn-sm">
                                <i class="fas fa-arrow-left"></i> Batal
                            </a>
                        </div>
                    </form>
