<?php $profile_id = $this->session->userdata('profile_id'); ?>
<div class="col-sm-10">
    <div class="row ">

        <div class="col-sm-12 ">
            <span class="col-sm-6 text-left"><h3>Batch student</h3></span>
        </div>
        <div class="col-sm-12 ">
            <span class="col-sm-6 text-left">
                <h4>Batch: <?php echo $batch_info->course_batch_name; ?>
                </h4>
            </span>
        </div>
        <div class="col-sm-12 ">
            <span class="col-sm-6 text-left">
                <h4>Course: 
                    <a href="<?php echo base_url() . $course_info->url; ?>" target="_blank">
                        <?php echo $course_info->course_name; ?>
                    </a>
                </h4>
            </span>
            <span class="col-sm-6 text-left">
                <h4>Resource person: 
                    <a href="<?php echo base_url() . $resource_person_info->url . '/profile'; ?>" target="_blank">
                        <?php echo $resource_person_info->person_first_name . ' ' . $resource_person_info->person_last_name; ?>
                    </a>
                </h4>
            </span>
        </div>
        <div class="col-sm-12"><hr></div>
        <div class="col-sm-12"><hr></div>

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

            <div class="col-sm-12  text-left  "style="margin-bottom: 5px;font-weight: bold; border-bottom: 2px solid #80c12c">
                <div class="col-sm-3">Name</div>
                <div class="col-sm-2">Mobile</div>
                <div class="col-sm-3">Email</div>
                <div class="col-sm-2">Status</div>
                <div class="col-sm-2">Action</div>
            </div>
            <?php
            $assigned_student_arr = explode(',', $batch_info->student_id);
            $security_salt = '#' . rand(1, 99999);
            foreach ($course_registered_student as $v_student) {
                if (in_array($v_student->student_id, $assigned_student_arr)) {
                    $e_id = $this->encrypt->encode($v_student->student_id);
                    $s_id = $e_id . $security_salt;
                    $de_id = $this->encrypt->encode($s_id);
                    $student_e_id = str_replace("/", "%F2", $de_id);
                    ?>
                    <div id="sActions<?php echo $v_student->student_id; ?>">
                        <div class="col-sm-12 text-left " style="padding: 10px;background-color:#F2F9EA;border: 1px solid #ededed">
                            <div class="col-sm-3">
                                <a href="<?php echo base_url() . $v_student->url . '/profile'; ?>" target="_blank">
                                    <?php echo $v_student->person_first_name . ' ' . $v_student->person_last_name; ?>
                                </a>
                            </div>
                            <div class="col-sm-2"><?php echo $v_student->person_contact_number; ?></div>
                            <div class="col-sm-3"><?php echo $v_student->person_email; ?></div>
                            <div class="col-sm-2">
                                <?php
                                if ($student_payment_info[$v_student->student_id]) {
                                    $payment_status = array('', 'Paid', 'Partial paid', 'Unpaid', 'Drop', 'Cancel', 'Pending', 'Free');
                                    echo $payment_status[$student_payment_info[$v_student->student_id]->payment_status];
                                }
                                ?>
                            </div>
                            <div class="col-sm-2">

                                <a href="javascript:;" onclick="assignStudent('<?php echo base_url() . 'super-admin/unassign-batch-student/' . $student_e_id . '/' . $batch_info->course_batch_id; ?>', '<?php echo $v_student->student_id; ?>')">  
                                    <i class="fa fa-times-circle-o" title="Unassign"></i>
                                </a>&nbsp;&nbsp;&nbsp; 

                            </div>
                        </div>
                        <div class="col-sm-12 form-group"></div>
                    </div>
                    <?php
                }
            }
            ?>
        </div>
    </div>
</div>

<script>
    function create_xmlhttp() {
        var xmlhttp = false;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
    }

    function assignStudent(url, ID) {
        xmlhttp = create_xmlhttp();
        serverPage = url;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                document.getElementById("sActions" + ID).innerHTML = xmlhttp.responseText;
            }
        };
        xmlhttp.send(null);
    }
</script>