<?php
$status = $this->session->userdata('status');
$type_id = $this->session->userdata('type_id');
?>

<!--Add / Change / Assign / Short-->
<div id="change">
    <div class="col-sm-10 col-sm-offset-3 main col-md-10 col-md-offset-2 main">

        <!-- Student List with Some Action  -->    
        <div class="container col-sm-8 col-sm-offset-2 col-md-offset-0 col-md-12" id="res">
            <div class="">
                <a href="<?php echo base_url(); ?>super_admin">Dashboard</a>->>
                <a href="<?php echo base_url(); ?>super_admin_group/manage_group"><span> Group List</span></a>->>
                <span> Group Details</span>
                <div>
                    <?php
                    $message = $this->session->userdata('message');
                    if ($message) {
                        echo $message;
                    }
                    ?>
                </div>
            </div>

            <div class="span11 right">
                <div class="col-lg-6 col-md-4" ><h3> Group Information</h3> </div>
            </div>
            <!--    
            Only List with Pagination 
            Change Status / Edit / Delete
            -->
            <div class="col-lg-12 col-md-8 col-sm-7" id="student_list">
                <div class="row">
                    <div class="col-lg-5 col-md-5 col-sm-5">
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Group Name</div>
                            <div class="col-sm-3 col-md-6"><?php echo $group_details->group_name; ?></div>
                        </div>

                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Resource Person </div>
                            <div class="col-sm-3 col-md-6"><?php echo $group_details->person_first_name; ?></div>
                        </div>
                    </div>

                    <div class="col-lg-5 col-md-5 col-sm-5">
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Total Member</div>
                            <div class="col-sm-3 col-md-6"><?php echo $total_member->total; ?></div>
                        </div>
                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Group Pending Requested</div>
                            <div class="col-sm-3 col-md-6"><?php echo $total_member_pending->total_pending; ?></div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="table-responsive col-lg-11 col-md-10 col-sm-7" id="student_list">
                <br>
                <br>
                <h4>Group Member List</h4>
            </div>
            <div class="table-responsive col-lg-11 col-md-8 col-sm-7" id="user_list">
                <form name="myform" action=""  method="post">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th><input type="checkbox" name="all_user" id="all_user" onchange="toggleAllUserSelection(document.myform.user_id)"/></th>

                                <th>Quiz Name</th>
                                <th>Quiz Topics</th>
                                <th>Number of Question</th>
                                <th>Created By</th>
                                <th>Status</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $i = 1;
                            foreach ($quiz_list as $v_quiz) {
                                ?>
                                <tr>
                                    <td><input name="group_id" id="quiz_id<?php echo $v_quiz->quiz_id; ?>" type="checkbox"  value="<?php echo $v_quiz->quiz_id; ?>" onchange="setGroupMemberIdList(this.value);"/></td>

                                    <td>
                                        <a href="<?php echo base_url() ?>super_admin_quiz/view_quiz_detail/<?php echo $v_quiz->quiz_id ?>">
                                            <?php echo $v_quiz->quiz_name; ?>
                                        </a>
                                    </td>
                                    <td><?php echo $v_quiz->topic_name; ?></td>
                                    <td><?php echo $total_question[$v_quiz->quiz_id]; ?></td>
                                    <td><?php echo $v_quiz->person_last_name; ?></td>



                                    <!--Action: Active, Inactive, Archive, Edit-->

                                    <td><?php
                                        if ($v_quiz->quiz_status == '1') {
                                            echo '<p style="color:limegreen;">Active</p>';
                                            ?>
                                            <a href="<?php echo base_url(); ?>super_admin_quiz/inactive_quiz/<?php echo $v_quiz->quiz_id; ?>"><i class="fa fa-user-times" title="Inactive"></i></a>
                                            <?php
                                        } else if ($v_quiz->quiz_status == '0') {
                                            echo '<p style="color:red;">Inactive</p>';
                                            ?>

                                            <a href="<?php echo base_url(); ?>super_admin_quiz/active_quiz/<?php echo $v_quiz->quiz_id; ?>">
                                                <i class="fa fa-user-plus" title="Active"></i></a>
                                            <?php
                                        } else {
                                            echo '<p style="color:blue;">Archived';
                                            ?>
                                            <a href="<?php echo base_url(); ?>super_admin_quiz/active_quiz/<?php echo $v_quiz->quiz_id; ?>"><i class="fa fa-user-plus" title="Active"></i> </a>
                                        <?php } ?>
                                    </td>
                            <script>

                                function changeUsersRole()
                                {
                                    userRoleId = document.getElementById("user_role_id").value;
                                    serverPage = '<?php echo base_url(); ?>super_admin/change_users_role/' + userList + '/' + userRoleId;
                                    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);
                                }

                            </script>

                            <td>
                                <a href="<?php echo base_url(); ?>super_admin_quiz/update_quiz/<?php echo $v_quiz->quiz_id; ?>"><div class="span1">Edit <i class="fa fa-edit"></i></div></a>
                                <a href="<?php echo base_url(); ?>super_admin_quiz/quiz_detail/<?php echo $v_quiz->quiz_id; ?>"><div class="span1">View </div></a>
                                <?php if ($v_quiz->quiz_status != 2) { ?>
                                    <a href="<?php echo base_url(); ?>super_admin_quiz/archive_quiz/<?php echo $v_quiz->quiz_id; ?>" onclick="return checkAction('Archive');">Archive <i class="fa fa-remove"></i></a>
                                <?php } ?>
                            </td>

                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <br>
                </form>

            </div>
        </div>  
    </div> 


    <script type="text/javascript">
        document.forms['pagination'].elements['per_page'].value = '<?php echo $limit ?>';
        document.forms['control_form'].elements['student_status'].value = '<?php echo $status; ?>';
        document.forms['control_form'].elements['student_role_id2'].value = '<?php echo $type_id; ?>';
    </script>



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

    <!--
    
    Modal:
    Change Role
    
    -->

    <div class="modal fade" id="setRole" tabindex="-1" role="dialog" aria-labelledby="setRole" 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">Change Role</h4>
                </div>
                <form name="setRole">
                    <div class="modal-body">

                        <label for="user_role_id">Set To Role:</label><span>*</span>
                        <select class="form-control" name="user_role_id" id="user_role_id">
                            <option value="">--Select User Type--</option>
                            <option value="1">Admin</option>
                            <option value="2">Account</option>
                            <option value="3">Resource</option>
                            <option value="4">Register</option>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary" onclick="setStudentRole();">Save changes</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


    <!--
    
    Modal:: 
    Change Status
    
    -->

    <div class="modal fade" id="changeStatus" tabindex="-1" role="dialog" aria-labelledby="changeStatus" 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">Change Student Status</h4>
                </div>
                <form>
                    <div class="modal-body">
                        <h3>Select Status</h3>
                        <select class="form-control" name="change_status" id="change_status" required>
                            <option value="">--Select Student Status--</option>
                            <option value="1">Active</option>
                            <option value="2">Inactive</option>
                            <option value="3">Archive</option>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" onclick="changeStudentsStatus();">Save changes</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- Modal END For Change Role and Status-->


    <!-- Assign Course To Student List -->

    <div class="modal fade" id="assignCourse" tabindex="-1" role="dialog" aria-labelledby="assignCourse" 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">Assign Course </h4>
                </div>
                <form>
                    <div class="modal-body">
                        <div id="category" class="col-sm-9 col-md-10 col-md-offset-1">
                            <label>Select Category</label>
                            <select class="form-control span5" name="category_id" id="category_id" required onchange="selectCategoryCourse(this.value, 'course_list');">
                                <option value="">--Select Course Category--</option>
                                <?php foreach ($course_categories as $v_category) { ?>                                                    
                                    <option value="<?php echo $v_category->category_id; ?>"> <?php echo $v_category->category_name; ?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <div id="course_list" class="col-sm-9 col-md-10 col-md-offset-1"></div>

                    </div>
                    <br>
                    <hr>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" onclick="assignCourse();">Assign</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!--
    Print Preview and then Print option
    -->

    <div class="modal fade" id="print" tabindex="-1" role="dialog" aria-labelledby="print" 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">Change Role</h4>
                </div>
                <form name="print">
                    <div class="modal-body">

                        <label for="student_role_id">Student role:</label><span>*</span>
                        <select class="form-control" name="student_role_id" id="student_role_id" required>
                            <option value="">--Select Student Role--</option>
                            <?php foreach ($student_types as $v_student_role) { ?>
                                <option value="<?php echo $v_student_role->student_role_id; ?>" <?php
                                if ($v_student_role->role_name == $student_type) {
                                    echo 'selected';
                                }
                                ?>> <?php echo $v_student_role->role_name ?></option>
                                    <?php } ?>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" onclick="printDiv('student_list');">print</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </form>
            </div>
        </div>
    </div>



    <!--
    
    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 Student</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;
                        }
                        ?>
                    </p>
                    <div class="table-responsive col-sm-12">
                        <?php // echo validation_errors();              ?>
                        <form action="<?php echo base_url(); ?>super_admin/import_student_csv_file" method="post" name="import_csv" enctype="multipart/form-data" >
                            <div class="form-group col-sm-8" >
                                <label for="student_info_file" style="float:left;">Select CSV File</label><span class="required"> * <?php // echo form_error('student_image');                                           ?></span><br><br>
                                <input style="float:left;" type='file' onchange="readURL(this, 'file_0');" name="student_info_file" value="<?php // echo set_value('student_image');                                           ?>"/>
                                <div id="file" style="float:left;width: 50px; height: 50px;" ></div>
                            </div>
                            <div class="form-group col-sm-8" >
                                <label for="student_person_info_file" style="float:left;">Select CSV File</label><span class="required"> * <?php // echo form_error('student_image');                                           ?></span><br><br>
                                <input style="float:left;" type='file' onchange="readURL(this, 'file_0');" name="student_person_info_file" value="<?php // echo set_value('student_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>

</script>
</div>
