">
    <label for="poll"><?php 
echo get_text('Select_a') . ' ' . strtolower(get_text('Poll'));
?>
: </label>
    <select name="poll">
        <option value=""><?php 
echo get_text('Choose_a') . ' ' . strtolower(get_text('Poll'));
?>
</option>
        <?php 
if (isset($_POST['user']) && !empty($_POST['user'])) {
    $id = get_user_id($_POST['user']);
}
if (isset($_POST['poll']) && !empty($_POST['poll'])) {
    $id = get_poll_reviewee($_POST['poll']);
}
if (!empty($id)) {
    $batch = get_published_batch_id();
    $polls = get_polls_by_reviewee($id, $batch);
    foreach ($polls as $poll) {
        $selected = isset($_POST['poll']) && $poll['ID'] == $_POST['poll'];
        $name = get_user_by_id($poll['Reviewer']);
        $reviewer = $name[0] . ' ' . $name[1];
        ?>
                <option
                    value="<?php 
        echo $poll['ID'];
        ?>
" <?php 
        if ($selected) {
        <?php 
foreach ($departments as $department) {
    ?>
            <optgroup label="<?php 
    echo $department['Name'];
    ?>
">
                <?php 
    foreach ($users as $user) {
        $user_department = get_user_department($user['ID']);
        if ($user_department == $department['ID']) {
            $selected = isset($_POST['user']) && !empty($_POST['user']) && $user['Username'] == $_POST['user'];
            if (!$selected) {
                if (isset($_POST['poll']) && !empty($_POST['poll'])) {
                    $poll = $_POST['poll'];
                    $reviewee_id = get_poll_reviewee($poll);
                    $selected = $user['ID'] == $reviewee_id;
                }
            }
            ?>
                        <option
                            value="<?php 
            echo $user['Username'];
            ?>
" <?php 
            if ($selected) {
                echo 'selected';
            }
            ?>
><?php 
            echo $user['Firstname'] . ' ' . $user['Lastname'];