<style type="text/css">
    .permission_txt:hover {cursor: default;}
</style>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/user.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input.check_all, input.master, input.permission').prop('disabled', true);
    });
</script>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color">User View</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box box-danger">
                    <div class="box-body">
                        <div class="col-xs-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <span class="first-coln">Name</span>
                                    <span class="seperator">:</span>
                                    <span class="second-coln">
                                        <?php echo text($user->name);?>
                                    </span>
                                </div>
                                <div class="role_checkbox" style="display: none;">
                                    <input type="radio" name="role" style="display:none;" value="<?php echo $user->role;?>" checked />
                                </div>
                                <div class="form-group">
                                    <span class="first-coln">Role</span>
                                    <span class="seperator">:</span>
                                    <span class="second-coln">
                                        <?php echo text($user->role_str);?>
                                    </span>
                                </div>
                                
                                <div class="form-group">
                                    <span class="first-coln">User Name</span>
                                    <span class="seperator">:</span>
                                    <span class="second-coln">
                                        <?php echo text($user->user_name);?>
                                    </span>
                                </div>
                                
                                <div class="form-group">
                                    <span class="first-coln">Contact No</span>
                                    <span class="seperator">:</span>
                                    <span class="second-coln">
                                        <?php echo text($user->contact_no);?>
                                    </span>
                                </div>
                                
                                <div class="form-group">
                                    <span class="first-coln">Status</span>
                                    <span class="seperator">:</span>
                                    <span class="second-coln">
                                        <?php echo ($user->status == 1) ? 'Confirmed' : 'Blocked';?>
                                    </span>
                                </div>
                                
                                <?php $permission = unserialize($user->permissions); ?>
                            </div>
                        </div>
                        
                        <?php $permission = unserialize($user->permissions); ?>
                        <!-- Permission div Start-->
                        <div class="permission_container col-xs-12">
                            <div class="permission_row col-xs-12 even">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <label style="width: 25%;">
                                            <input type="checkbox" name="permissions[check_all]" value="1" class="check_all" <?php echo (!empty($permission['check_all'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Full Permissions</span>
                                        </label>
                                        
                                        <label style="width: 25%;">
                                            <input type="checkbox" name="permissions[home][]" class="permission master" value="1" data-master="home" <?php echo (!empty($permission['home'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Dashboard</span>
                                        </label>
                                        
                                        <label style="width: 24%;">
                                            <input type="checkbox" name="permissions[otp][]" class="permission master" value="1" data-master="otp" <?php echo (!empty($permission['otp'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">OTP</span>
                                        </label>
                                        
                                        <label style="width: 24%;">
                                            <input type="checkbox" name="permissions[sms][]" class="permission master" value="1" data-master="sms" <?php echo (!empty($permission['sms'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Send SMS</span>
                                        </label>
                                        
                                        <label style="width: 25%; padding-top: 10px;">
                                            <input type="checkbox" name="permissions[notification][]" class="permission master" value="1" data-master="notification" <?php echo (!empty($permission['notification'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Notification</span>
                                        </label>
                                        
                                        <label style="width: 24%; padding-top: 10px;">
                                            <input type="checkbox" name="permissions[day_end_report][]" class="permission master" value="1" data-master="day_end_report" <?php echo (!empty($permission['day_end_report'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Day End Report</span>
                                        </label>
                                        
                                        <label style="width: 24%; padding-top: 10px;">
                                            <input type="checkbox" name="permissions[daily_report][]" class="permission master" value="1" data-master="daily_report" <?php echo (!empty($permission['daily_report'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Daily Report</span>
                                        </label>
                                        
                                        <label style="width: 24%;">
                                            <input type="checkbox" name="permissions[prasadam_consolidate][]" class="permission master" value="1" data-master="prasadam_consolidate" <?php echo (!empty($permission['prasadam_consolidate'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Prasadam Consolidated Report</span>
                                        </label>
                                        
                                        <label style="width: 25%; padding-top: 10px;">
                                            <input type="checkbox" name="permissions[kattalai_archanai_report][]" class="permission master" value="1" data-master="kattalai_archanai_report" <?php echo (!empty($permission['kattalai_archanai_report'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Kattalai Archanai Report</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="permission_row col-xs-12 even" style="padding-left: 15px !important; padding-right: 15px !important;">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <label style="width: 25%;">
                                            <input type="checkbox" name="permissions[add_all]" value="1" class="add_all" <?php echo (!empty($permission['add_all'])) ? 'checked' : '';?> disabled />
                                            <span class="permission_txt">Add All</span>
                                        </label>

                                        <label style="width: 25%;">
                                            <input type="checkbox" name="permissions[edit_all]" value="1" class="edit_all" <?php echo (!empty($permission['edit_all'])) ? 'checked' : '';?> disabled />
                                            <span class="permission_txt">Edit All</span>
                                        </label>

                                        <label style="width: 24%;">
                                            <input type="checkbox" name="permissions[view_all]" value="1" class="view_all" <?php echo (!empty($permission['view_all'])) ? 'checked' : '';?> disabled />
                                            <span class="permission_txt">View All</span>
                                        </label>

                                        <label style="width: 24%;">
                                            <input type="checkbox" name="permissions[delete_all]" value="1" class="delete_all" <?php echo (!empty($permission['delete_all'])) ? 'checked' : '';?> disabled />
                                            <span class="permission_txt">Delete All</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            
                            <?php $permission = unserialize($user->master_permissions); ?>
                            <div class="administrator permission_row col-xs-12 odd">
                                <div class="panel panel-default master_container">
                                    <div class="panel-heading">
                                        <label>
                                            <input type="checkbox" name="master[masters]" value="1" class="master super_master" data-master="<?php echo $masters_str;?>" <?php echo (!empty($permission['masters'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Masters</span>
                                        </label>
                                        <div class="pull-right compress_btn compress">
                                            <span class="btn btn-success btn-sm">
                                                <i class="fa fa-compress"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                    <?php foreach($masters as $key => $master) {?>
                                        <?php $controller_name = $master->controller_name;?>
                                        <div class="col-md-6 master_container">
                                            <div class="checkbox permission_div">
                                                <label>
                                                    <h5>
                                                        <input type="checkbox" name="master[<?php echo $controller_name;?>][]" class="master" data-master="<?php echo $controller_name;?>" value="ALL" <?php echo ((!empty($permission[$controller_name])) && (in_array('ALL', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt"><?php echo $master->master_name;?></span>
                                                    </h5>
                                                </label>
                                            </div>
                                            
                                            <div class="form-group">
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="master[<?php echo $controller_name;?>][]" class="permission view" value="1" <?php echo ((!empty($permission[$controller_name])) && (in_array('1', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">View</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="master[<?php echo $controller_name;?>][]" class="permission add" value="2" <?php echo ((!empty($permission[$controller_name])) && (in_array('2', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Add</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="master[<?php echo $controller_name;?>][]" class="permission edit" value="3" <?php echo ((!empty($permission[$controller_name])) && (in_array('3', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Edit</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="master[<?php echo $controller_name;?>][]" class="permission delete" value="4" <?php echo ((!empty($permission[$controller_name])) && (in_array('4', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Delete</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    <?php }?>
                                    </div>
                                </div>
                            </div>
                            
                            <?php $permission = unserialize($user->inventory_permissions); ?>
                            <div class="administrator permission_row col-xs-12 even">
                                <div class="panel panel-default master_container">
                                    <div class="panel-heading">
                                        <label>
                                            <input type="checkbox" name="inventory[inventory]" value="1" class="master super_master" data-master="<?php echo $inventory_str;?>" <?php echo (!empty($permission['inventory'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Inventory</span>
                                        </label>
                                        <div class="pull-right compress_btn compress">
                                            <span class="btn btn-success btn-sm">
                                                <i class="fa fa-compress"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                    <?php foreach($inventories as $key => $inventory) {?>
                                        <?php $controller_name = $inventory->controller_name;?>
                                        <div class="col-md-6 master_container">
                                            <div class="checkbox permission_div">
                                                <label>
                                                    <h5>
                                                        <input type="checkbox" name="inventory[<?php echo $controller_name;?>][]" class="master" data-master="<?php echo $controller_name;?>" value="ALL" <?php echo ((!empty($permission[$controller_name])) && (in_array('ALL', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt"><?php echo $inventory->inventory_name;?></span>
                                                    </h5>
                                                </label>
                                            </div>
                                            
                                            <div class="form-group">
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="inventory[<?php echo $controller_name;?>][]" class="permission view" value="1" <?php echo ((!empty($permission[$controller_name])) && (in_array('1', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">View</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="inventory[<?php echo $controller_name;?>][]" class="permission add" value="2" <?php echo ((!empty($permission[$controller_name])) && (in_array('2', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Add</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="inventory[<?php echo $controller_name;?>][]" class="permission edit" value="3" <?php echo ((!empty($permission[$controller_name])) && (in_array('3', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Edit</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="inventory[<?php echo $controller_name;?>][]" class="permission delete" value="4" <?php echo ((!empty($permission[$controller_name])) && (in_array('4', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Delete</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    <?php }?>
                                    </div>
                                </div>
                            </div>
                            
                            <?php $permission = unserialize($user->statue_permissions); ?>
                                <div class="administrator permission_row col-xs-12 even">
                                    <div class="panel panel-default master_container">
                                        <div class="panel-heading">
                                            <label>
                                                <input type="checkbox" name="statue[statue]" value="1" class="master super_master" data-master="<?php echo $statues_str;?>" <?php echo (!empty($permission['statue'])) ? 'checked' : '';?> />
                                                <span class="permission_txt">Statue and Books</span>
                                            </label>
                                            <div class="pull-right compress_btn compress">
                                                <span class="btn btn-success btn-sm">
                                                    <i class="fa fa-compress"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="panel-body">
                                        <?php foreach($statues as $key => $statuebook) {?>
                                            <?php $controller_name = trim($statuebook->controller_name);?>
                                            <div class="col-md-6 master_container">
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <h5>
                                                            <input type="checkbox" name="statue[<?php echo $controller_name;?>][]" class="master" data-master="<?php echo $controller_name;?>" value="ALL" <?php echo ((!empty($permission[$controller_name])) && (in_array('ALL', $permission[$controller_name]))) ? 'checked' : '';?>/>
                                                            <span class="permission_txt"><?php echo $statuebook->menu_name;?></span>
                                                        </h5>
                                                    </label>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <div class="checkbox permission_div">
                                                        <label>
                                                            <input type="checkbox" name="statue[<?php echo $controller_name;?>][]" class="permission view" value="1" <?php echo ((!empty($permission[$controller_name])) && (in_array('1', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                            <span class="permission_txt">View</span>
                                                        </label>
                                                    </div>
                                                    
                                                    <div class="checkbox permission_div">
                                                        <label>
                                                            <input type="checkbox" name="statue[<?php echo $controller_name;?>][]" class="permission add" value="2" <?php echo ((!empty($permission[$controller_name])) && (in_array('2', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                            <span class="permission_txt">Add</span>
                                                        </label>
                                                    </div>
                                                    
                                                    <div class="checkbox permission_div">
                                                        <label>
                                                            <input type="checkbox" name="statue[<?php echo $controller_name;?>][]" class="permission edit" value="3" <?php echo ((!empty($permission[$controller_name])) && (in_array('3', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                            <span class="permission_txt">Edit</span>
                                                        </label>
                                                    </div>
                                                    
                                                    <div class="checkbox permission_div">
                                                        <label>
                                                            <input type="checkbox" name="statue[<?php echo $controller_name;?>][]" class="permission delete" value="4" <?php echo ((!empty($permission[$controller_name])) && (in_array('4', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                            <span class="permission_txt">Delete</span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php }?>
                                        </div>
                                    </div>
                                </div>
                            
                            <?php $permission = unserialize($user->billing_permissions); ?>
                            <div class="administrator user permission_row col-xs-12 odd">
                                <div class="panel panel-default master_container">
                                    <div class="panel-heading">
                                        <label>
                                            <input type="checkbox" name="billing[billing]" value="1" class="master super_master" data-master="<?php echo $service_str;?>" <?php echo (!empty($permission['billing'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Billing</span>
                                        </label>
                                        <div class="pull-right compress_btn compress">
                                            <span class="btn btn-success btn-sm">
                                                <i class="fa fa-compress"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                    <?php foreach($services as $key => $service) {?>
                                        <?php $controller_name = $service->controller_name;?>
                                        <div class="col-md-6 master_container">
                                            <div class="checkbox permission_div">
                                                <label>
                                                    <h5>
                                                        <input type="checkbox" name="billing[<?php echo $controller_name;?>][]" class="master" data-master="<?php echo $controller_name;?>" value="ALL" <?php echo ((!empty($permission[$controller_name])) && (in_array('ALL', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt"><?php echo $service->service_name;?></span>
                                                    </h5>
                                                </label>
                                            </div>
                                            
                                            <div class="form-group">
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="billing[<?php echo $controller_name;?>][]" class="permission view" value="1" <?php echo ((!empty($permission[$controller_name])) && (in_array('1', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">View</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="billing[<?php echo $controller_name;?>][]" class="permission add" value="2" <?php echo ((!empty($permission[$controller_name])) && (in_array('2', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Add</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="billing[<?php echo $controller_name;?>][]" class="permission edit" value="3" <?php echo ((!empty($permission[$controller_name])) && (in_array('3', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Edit</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="billing[<?php echo $controller_name;?>][]" class="permission delete" value="4" <?php echo ((!empty($permission[$controller_name])) && (in_array('4', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Delete</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    <?php }?>
                                    </div>
                                </div>
                            </div>
                            
                            <?php $permission = unserialize($user->report_permissions); ?>
                            <div class="administrator permission_row col-xs-12 even">
                                <div class="panel panel-default master_container">
                                    <div class="panel-heading">
                                        <label>
                                            <input type="checkbox" name="reports[reports]" value="1" class="master super_master" data-master="<?php echo $report_str;?>" <?php echo (!empty($permission['reports'])) ? 'checked' : '';?> />
                                            <span class="permission_txt">Reports</span>
                                        </label>
                                        <div class="pull-right compress_btn compress">
                                            <span class="btn btn-success btn-sm">
                                                <i class="fa fa-compress"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                    <?php foreach($reports as $key => $report) {?>
                                        <?php $controller_name = $report->controller_name;?>
                                        <div class="col-md-6 master_container">
                                            <div class="checkbox permission_div">
                                                <label>
                                                    <h5>
                                                        <input type="checkbox" name="reports[<?php echo $controller_name;?>][]" class="master" data-master="<?php echo $controller_name;?>" value="ALL" <?php echo ((!empty($permission[$controller_name])) && (in_array('ALL', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt"><?php echo $report->report_name;?></span>
                                                    </h5>
                                                </label>
                                            </div>
                                            
                                            <div class="form-group">
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="reports[<?php echo $controller_name;?>][]" class="permission view" value="1" <?php echo ((!empty($permission[$controller_name])) && (in_array('1', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">View</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="reports[<?php echo $controller_name;?>][]" class="permission add" value="2" <?php echo ((!empty($permission[$controller_name])) && (in_array('2', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Add</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="reports[<?php echo $controller_name;?>][]" class="permission edit" value="3" <?php echo ((!empty($permission[$controller_name])) && (in_array('3', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Edit</span>
                                                    </label>
                                                </div>
                                                
                                                <div class="checkbox permission_div">
                                                    <label>
                                                        <input type="checkbox" name="reports[<?php echo $controller_name;?>][]" class="permission delete" value="4" <?php echo ((!empty($permission[$controller_name])) && (in_array('4', $permission[$controller_name]))) ? 'checked' : '';?> />
                                                        <span class="permission_txt">Delete</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    <?php }?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer"></div>
                </div><!-- /.box -->
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
    </section><!-- /.content -->
</aside>