<div class="col-sm-12"><br></div>
<div class="form-group col-sm-12 padding-zero">
    <?php if ($access_level == 1 || $access_level == 2) { ?>
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >
    <?php } if ($access_level == 3) { ?>
        <?php
        $selected_user = array();
        $to_address_value = '';
        if ($video_course_access_user) {
            foreach ($video_course_access_user as $v_video_course_access_user) {
                $selected_user[$v_video_course_access_user->person_id] = 1;
                $to_address_value .= $v_video_course_access_user->person_id . ',';
            }
        }
        ?>

        <input data-errormessage-value-missing="Email address is Required!" 
               class="form-control validate[custom[multipleEmail]] text-input"
               type="hidden" name="previous_access_user" id="previous_access_user" value="" >
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

        <div class="col-sm-12">
            <select name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                    class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                        <?php
                        foreach ($link_person as $v_person) {
                            ?>
                    <option value="<?php echo $link_person_info[$v_person->person_link_id]->person_id; ?>" <?php
                    if ($selected_user[$link_person_info[$v_person->person_link_id]->person_id] == 1) {
                        echo 'selected';
                    }
                    ?>>
                                <?php echo $link_person_info[$v_person->person_link_id]->person_first_name . ' (' . $link_person_info[$v_person->person_link_id]->person_email . ')'; ?>
                    </option>
                <?php } ?>
            </select>
        </div>

    <?php } else if ($access_level == 4) { ?>
        <?php
        $selected_user = array();
        $to_address_value = '';
        if ($video_course_access_user) {
            foreach ($video_course_access_user as $v_video_course_access_user) {
                $selected_user[$v_video_course_access_user->person_id] = 1;
                $to_address_value .= $v_video_course_access_user->person_id . ',';
            }
        }
        ?>
        <input data-errormessage-value-missing="Email address is Required!" 
               class="form-control validate[custom[multipleEmail]] text-input"
               type="hidden" name="previous_access_user" id="previous_access_user" value="" >
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

        <div class="col-sm-12">

            <select name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                    class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                        <?php foreach ($group as $v_group) { ?>
                    <option value="<?php echo $v_group->group_id ?>" <?php
                    if ($selected_user[$v_group->group_id] == 1) {
                        echo 'selected';
                    }
                    ?>>
                                <?php echo $v_group->group_name . ' (' . $v_group->group_public_id . ')'; ?>
                    </option>
                <?php } ?>
            </select>
        </div>

    <?php } else if ($access_level == 5) { ?>
        <?php
        $selected_user = array();
        $to_address_value = '';
        if ($video_course_access_user) {
            foreach ($video_course_access_user as $v_video_course_access_user) {
                $selected_user[$v_video_course_access_user->person_id] = 1;
                $to_address_value .= $v_video_course_access_user->person_id . ',';
            }
        }
        ?>
        <input data-errormessage-value-missing="Email address is Required!" 
               class="form-control validate[custom[multipleEmail]] text-input"
               type="hidden" name="previous_access_user" id="previous_access_user" value="" >
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

        <div class="col-sm-12">
            <select name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                    class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                <?php
                foreach ($link_person as $v_person) {
                    ?>
                    <option value="<?php echo $link_person_info[$v_person->person_link_id]->person_id; ?>" <?php
                    if ($selected_user[$link_person_info[$v_person->person_link_id]->person_id] == 1) {
                        echo 'selected';
                    }
                    ?>>
                                <?php echo $link_person_info[$v_person->person_link_id]->person_first_name . ' (' . $link_person_info[$v_person->person_link_id]->person_email . ')'; ?>
                    </option>
                <?php } ?>
            </select>
        </div>
    <?php } ?>
</div>