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

        <div class="col-sm-12 ">
            <span class="col-sm-6 text-left"><h3> Student List</h3></span>
        </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 foreach ($student as $v_student) { ?>
                <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'; ?>"><?php echo $v_student->person_first_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() . 'unassign/' . $v_student->student_id . '/' . $classroom_info->url; ?>', '<?php echo $v_student->student_id; ?>')">  
                                <i class="fa fa-times-circle-o" title="Unassign"></i>
                            </a>
                        </div>
                    </div>
                    <div class="col-sm-12 form-group"></div>
                </div>
            <?php } ?>
        </div>
    </div>
</div>

<script>
    function assignStudent(url, ID) {
        var as_xmlhttp = create_xmlhttp();
        var serverPage = url;
        as_xmlhttp.open("GET", serverPage);
        as_xmlhttp.onreadystatechange = function ()
        {
            if (as_xmlhttp.readyState == 4 && as_xmlhttp.status == 200)
            {
                if (as_xmlhttp.responseText == '2') {
                    window.location.href = '<?php echo base_url() . 'assign-student/' . $classroom_info->url; ?>';
                } else if (as_xmlhttp.responseText == '1') {
                    tt_alert('You tried to some illegal action If You Need Any Help please contact with Talhatraining help desk');
                } else {
                    _("sActions" + ID).innerHTML = as_xmlhttp.responseText;
                }
            }
        };
        as_xmlhttp.send(null);
    }
</script>