<script>
    var list = '';
</script>

<div class="col-sm-12 col-sm-offset-3 col-md-12 col-md-offset-2 main" id="container">
    <!--START Relative Path-->
    <div class="">
        <a href="<?php echo base_url(); ?>super_admin">Dashboard <?php // echo $person_role;?></a>->>
        <a href="<?php echo base_url(); ?>super_admin/user_list/Organization/<?php echo $this->session->userdata('role_id'); ?>"><?php echo $person_role; ?> List</a>->>
        <a href="<?php echo base_url(); ?>super_admin/view_detail/Organization/<?php echo $org_info->person_id; ?>"><?php echo $person_role; ?> Detail</a>->>
        <a href="<?php echo base_url(); ?>super_admin_organization/classroom_list/<?php echo $org_info->person_id; ?>"><?php echo $person_role; ?> Classroom</a>->>
        <span> <?php echo $person_role; ?> Detail</span>
        <div>
            <?php
            $message = $this->session->userdata('message');
            if ($message) {
                echo $message;
            }
            ?>
        </div>
    </div>
    <!--END Relative Path-->
    
    <?php
    $status = $this->session->userdata('status');
    if (!$status) {
        $status = 'all';
    }
    $role_id = $this->session->userdata('role_id');
    $person_id = $this->session->userdata('person_id');
    ?>
    <div class="col-sm-9">
        <hr>
        <div class="col-lg-6 col-md-6 col-sm-6" >
            <h4>Organization Classroom Information</h4> 
        </div>

        <div class="col-sm-8">
            <?php
            $message = $this->session->userdata('message');
            $this->session->unset_userdata('message');
            if ($message) {
                echo $message;
            }
            ?>
        </div>
        <div class="container col-sm-12" id="change">
            <!--Teacher LIST-->
            <div class="col-lg-6">Running Classes: <?php echo count($current_classroom_list); ?></div>
            <div class="col-lg-6">Total Available Classroom: <?php echo $feature_info->virtual_classroom_number; ?></div>
            <div class="table-responsive col-lg-12 col-md-12 col-sm-12" id="user_list">
                <form name="myform" action=""  method="post">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th><input type="checkbox" name="all_list" id="all_list" onchange="toggleAllUserSelection(document.myform.person_id)"/></th>
                                <th></th>
                                <th>Student Name</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                        <script>

                            function toggleAllUserSelection(field) {
                                allList = document.getElementById("all_list").checked;
                                if (allList) {
                                    for (i = 0; i < field.length; i++) {
                                        field[i].checked = true;
                                        list += field[i].value + '.';
                                    }
                                } else {
                                    for (i = 0; i < field.length; i++)
                                        field[i].checked = false;
                                    list = '';
                                }
                            }

                            function setUserIdList(userID)
                            {
                                if ($("#person_id" + userID).is(":checked")) {
                                    list += userID + '.';
                                } else {
                                    list = list.replace(userID + ".", "");
                                }
                            }

                            function setInstantUserIdList(userID) {
                                list += userID + '.';
                            }
                        </script>
                        <?php
                        foreach ($classroom_student_list as $v_current_classroom_student) {
                            ?>
                            <tr>
                                <td>
                                    <input name="person_id" id="person_id<?php echo $v_current_classroom_student->person_id; ?>" type="checkbox"  value="<?php echo $v_current_classroom_student->person_id; ?>" onchange="setUserIdList(this.value);"/>
                                </td>
                                <td><img src="<?php echo base_url() . $v_current_classroom_student->person_image_thumb; ?>" width="50" height="50"> </td>
                                <td><?php echo $v_current_classroom_student->person_first_name; ?></td>
                                <td>
                                    <?php if ($v_current_classroom_student->classroom_student_join_status == '3') { ?>
                                        <span style="color: #990000"> 
                                            Unexpectedly Leaved the classroom
                                        </span> 
                                    <?php } else if ($v_current_classroom_student->classroom_student_join_status == '2') { ?>
                                        <span style="color: #990000"> 
                                            Leaved the classroom
                                        </span>
                                    <?php } else if ($v_current_classroom_student->classroom_student_join_status == '1') { ?>
                                        <span style="color: green">
                                            In Class
                                        </span>
                                    <?php } ?>
                                </td>

                                <td style="width: 200px;">
                                    <a href="<?php echo base_url() . 'classroom-detail/' . $v_current_classroom_student->student_id; ?>">
                                        <div class="span1"><i class="fa fa-line-chart">Student Course Statistics</i></div>
                                    </a>
                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <br>
                </form>

            </div>

        </div>
    </div> 

    <!-- Modal Start For Change Role and Status-->
    <!--
    

    <?php include 'admin_modal_view/modal_change_role.php'; ?>
    <?php include 'admin_modal_view/modal_change_status.php'; ?>
    <?php include 'admin_modal_view/modal_for_print.php'; ?>
    
    <!--

        Modal:: 
        IMPORT FILE FORM

    -->



    <div class="modal fade" id="importFile" tabindex="-1" role="dialog" aria-labelledby="importFile" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Add User</h4>
                </div>
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <p>
                        <?php
                        $message = $this->session->userdata('message');
                        $this->session->unset_userdata('message');
                        if ($message) {
                            echo $message;
                        } else {
                            echo 'no message';
                        }
                        ?>
                    </p>
                    <div class="table-responsive col-sm-12">
                        <?php // echo validation_errors();         ?>
                        <form action="<?php echo base_url(); ?>super_admin/import_user_csv_file" method="post" name="import_csv" enctype="multipart/form-data" >
                            <div class="form-group col-sm-8" >
                                <label for="user_info_file" style="float:left;">Select CSV File</label><span class="required"> * <?php // echo form_error('user_image');                                               ?></span><br><br>
                                <input style="float:left;" type='file' onchange="readURL(this, 'file_0');" name="user_info_file" value="<?php // echo set_value('user_image');                                               ?>"/>
                                <div id="file" style="float:left;width: 50px; height: 50px;" ></div>
                            </div>
                            <div class="checkbox col-sm-8" >
                                <button type="submit" class="btn btn-default">Submit</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <!--<button type="button" class="btn btn-primary">Save changes</button>-->
                </div>
            </div>
        </div>
    </div>
</div>


<SCRIPT LANGUAGE="JavaScript">

    document.forms['control_form'].elements['user_role_id2'].value = '<?php echo $role_id; ?>';
    document.forms['control_form'].elements['user_status'].value = '<?php echo $status; ?>';

    function checkAction(action) {
        message = 'do you want to ' + action + '!!';
        chk = confirm(message);
        if (chk) {
            return true;
        } else {
            return false;
        }
    }



    function changeUsersStatus()
    {
        userStatus = document.getElementById("person_status").value;
        serverPage = '<?php echo base_url(); ?>super_admin/change_users_status/' + list + '/' + userStatus;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                document.getElementById('res').innerHTML = xmlhttp.responseText;
            }
            location.reload();
        };
        xmlhttp.send(null);
    }

    function setPerPage(perPage) {
        //        alert(perPage);
        serverPage = '<?php echo base_url(); ?>super_admin/set_per_page/' + perPage;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            //            alert(xmlhttp.responseText);
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                location.reload();
            }
        };
        xmlhttp.send(null);
    }

    function sendMailToUser() {
        //        alert();
        if (list == '') {
            list = '';
            window.location = '<?php echo base_url(); ?>super_admin/send_mail_to_user/' + list;
        } else {
            window.location = '<?php echo base_url(); ?>super_admin/send_mail_to_user/' + list;
        }
    }


    function printPreview(divName) {
        serverPage = '<?php echo base_url(); ?>super_admin/make_print_data/' + list;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            //            alert('make_print_data');
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                window = document.getElementById('container').innerHTML = xmlhttp.responseText;
                window.print();
            }
        };
        xmlhttp.send(null);
    }


    function exportESV() {
        //        alert(list);
        if (list == '') {
            list = '';
            window.location = '<?php echo base_url(); ?>super_admin/export_user_list_csv/' + list;
            //            location.reload();
        } else {
            window.location = '<?php echo base_url(); ?>super_admin/export_user_list_csv/' + list;
//            location.reload();
        }
    }

    function printDiv(divName) {
        window.print();
    }
</script>