<?php
function request_role_change_form()
{
    $conn = get_connection();
    $result = $conn->query('SELECT * FROM roles WHERE role_id <> 1');

    $roles = '<div class="checkboxes">';
    while ($row = $result->fetch_assoc()) {
        $roles .= '
            <label class="form_checkbox_container">' . $row['role'] . '
                <input name="requested_role" value="' . $row['role_id'] . '" type="radio"' . ($row['role_id'] == $_SESSION['role_id'] ? ' checked' : '') . '>
                <span class="checkmark"></span>
            </label>
        ';
    }

    $roles .= '</div>';

    $form = '
        <div class="form_card">
            <h5 class="underline">Request Role</h5>
            <span class="modal_close">&times;</span>
            <form method="post">
                <input type="hidden" name="form_id" value="request_role_change_form">
                ' . $roles . '
            
                <input type="submit" class="button" value="Request Role">
            </form>
        </div>
    ';

    return $form;
}
