<?php
    include "../backend/connection.php";
    $configure = new DefaultDatabase();
    $conf = $configure->connect();

    $districts = mysqli_query($conf,"SELECT * FROM districts");
    $staff = mysqli_query($conf,"SELECT * FROM adjudicator");
    $category = mysqli_query($conf,"SELECT * FROM categories");

?>
<div class="school-container">
    <h2>ADJUDICATORS MANAGEMENT</h2>
    <div class="add-school">
        <form method="POST">
            <input type="text" placeholder="First Name" name="first_name" required>
            <input type="text" placeholder="Last Name" name="last_name" required>
            <input type="text" placeholder="phone" name="phone" required>
            <select id="districtSelect" name="district" required>
                <option value="" disabled selected>Select District</option>
                <?php
                    while($dist = mysqli_fetch_array($districts))
                    {
                ?>
                <option value="<?php echo $dist["district_name"] ?>"><?php echo $dist["district_name"] ?></option>
                <?php
                    }
                ?>
            </select>
            <select id="schoolSelect" name="category" required>
                <option value="" disabled selected>Select Category</option>
                <?php
                    while($cat = mysqli_fetch_array($category))
                    {
                ?>
                <option value="<?php echo $cat["category_name"] ?>"><?php echo $cat["category_name"] ?></option>
                <?php
                    }
                ?>
            </select>
            <button  type="submit" name="adjudicator_register">Add Adjudicator</button>
        </form>
    </div>
    <table id="schoolsTable">
        <thead>
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Phone</th>
                <th>District</th>
                <th>Category</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
                while($staff_members = mysqli_fetch_array($staff))
                {
            ?>
            <tr>
                <td><?php echo $staff_members["first_name"] ?></td>
                <td><?php echo $staff_members["last_name"] ?></td>
                <td><?php echo $staff_members["phone"] ?></td>
                <td><?php echo $staff_members["district"] ?></td>
                <td><?php echo $staff_members["category"] ?></td>
                <td>
                    <button class="delete"><a  href="./deletions/delete_adjudicator.php?staff_del=<?php echo $staff_members["id"] ?>" onclick="return confirm('Are you sure you want delete this Adjudicator?');" style="color:white; text-decoration:none;">Delete</a></button>
                </td>
            </tr>
            <?php
                }
            ?>
        </tbody>
    </table>
</div>
