<?php
if ($all_selected_person) {
    if ($first_column_selected_person) {
        echo '<div class="col-sm-12">';
        foreach ($first_column_selected_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>" checked >
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
    if ($second_column_selected_person) {
        echo '<div class="col-sm-12">';
        foreach ($second_column_selected_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>" checked >
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
    if ($third_column_selected_person) {
        echo '<div class="col-sm-12">';
        foreach ($third_column_selected_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>" checked >
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
}
if ($all_user) {
    if ($first_column_person) {
        echo '<div class="col-sm-12">';
        foreach ($first_column_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>">
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
    if ($second_column_person) {
        echo '<div class="col-sm-12">';
        foreach ($second_column_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>">
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
    if ($third_column_person) {
        echo '<div class="col-sm-12">';
        foreach ($third_column_person as $user_value) {
            ?>
            <div class="col-sm-3">
                <div class="checkbox checkbox-success">
                    <input type="checkbox"
                           onchange="checkPersonID(this.value)"
                           id="person_id<?php echo $user_value->person_id; ?>" 
                           class="styled"
                           name="special_user_id[]"
                           value="<?php echo $user_value->person_id; ?>">
                    <label for="<?php echo $user_value->person_first_name . ' ' . $user_value->person_last_name; ?>"  >
                        <?php
                        echo $user_value->person_first_name . ' ' . $user_value->person_last_name;
                        ?>
                    </label>
                </div>
                <div class="col-sm-12" style="color: red" id="special_checkbox_error<?php echo $user_value->person_id; ?>"></div>
            </div>
            <?php
        }
        echo ' </div>';
    }
} else {
    echo $message;
}