<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />

<div class="" id="addUserProfile">
    <div class="modal-dialog" style="width:75%">
        <div class="modal-content">
            <!-- Modal heading -->
            <div class="modal-header">
                <h3 class="modal-title" align="center">Manage Access Roles</h3>
            </div>
            <!-- Modal body -->
            <div class="modal-body">
                <div class="innerAll">
                    <div class="innerLR">
                        <form class="form-horizontal" role="form" action="" method="post">
                            <!-- <div class="form-group mmar">
                                <label  class="col-sm-4 control-label text-center">Access Role Name: </label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" value="" name = "access_role_name"/>
                                </div>

                            </div> -->
                            <!-- <div class="form-group" align="left">
        <div class="col-sm-offset-4 col-sm-8">
            <a href="<?php echo base_url();?>index.php/manage/scanmodules" ><button type="button" class="btn btn-primary">Scan Modules</button></a>
        </div>
    </div> -->
                            <div class="panel panel-default">
                                <!-- Default panel contents -->

                                <div class="panel-heading">Access Roles</div>
                                <div class="col-xs-2 col-md-6 bot-mar">
                                    <label  class="col-sm-7 control-label text-center">Select User Level:</label><br >
                                    <select class="cust_select col-xs-6" name="role_id" id="role_id" onchange="this.form.submit()">
                                        <option value="">--Select--</option>
                                        <?php foreach($users as $role) {

                                            if ($role['id'] >= $session_level_id) {
                                            ?>
                                            <option value="<?php echo $role['id'];?>"
                                                    <?php if ($selected_id == $role['id']){ ?>selected = "selected" <?php }?>><?php echo ucwords($role['name']);?></option>
                                        <?php }} ?>
                                    </select>
                                </div>
                                <div style="clear: both"></div>
                                <div style="margin-left: 20px"><p> <input type="checkbox" name="select-all" id="select-all" /> Select All </p></div>
                                <div style="margin-left: 20px"><p> <input type="checkbox" name="select-all" id="reset-all" /> Reset </p></div>
                                <div style="clear: both"></div>
                                <!-- Table -->
                                <table class="table table-white table-vertical-center margin-none table-striped footable">

                                    <tbody>
                                    <?php foreach($all_methods as $method_name => $method_info) {?>
                                        <tr>
                                            <td class="text-left strong" style="width:80px"><?php echo $method_name; ?></td>

                                            <?php
                                            $method_details = array();
                                            foreach($method_info as $method_action => $method_details){ ?>
                                                <td  class="text-center" style="width: 65px">
                                                    <div class="checkbox">
                                                        <label>
                                                            <input type="checkbox" value="<?php echo $method_details['id'];?>" name="access_methods[]"
                                                                <?php if(in_array($method_details['id'], $previous_access)) {?>
                                                                    checked
                                                                <?php } ?>
                                                                >
                                                            <?php echo trim($method_details['comment']);?>
                                                        </label>
                                                    </div>
                                                </td>

                                            <?php } ?>
                                        </tr>
                                    <?php } ?>

                                    </tbody>
                                </table>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-offset-4 col-sm-8">
                                    <button type="submit" class="btn btn-primary" name="permission">Submit</button>
                                    <button type="submit" class="btn btn-primary">Cancel</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- // Modal body END -->
<script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>
<script>
    $(document).ready(function() {
        $('#select-all').click(function(event) {
            if(this.checked) {
                // Iterate each checkbox
                $(':checkbox').each(function() {
                    this.checked = true;
                });
            }
        });

        $("#reset-all").click(function(){
            window.location.reload(true);
        })

    });
</script>