<!-- Left side column contains the sidebar -->
<?php $design_setting = get_design_setting();

if($user_data['role'] == 2) {
    $menu_bg = (!empty($design_setting->admin_menu_bg)) ? 'url(' . base_url() . 'uploads/settings/admin_menu_bg/'. $design_setting->admin_menu_bg .') !important' : '#EBEBEB';
    
    $menu_select_color = (!empty($design_setting->admin_menu_select_color)) ? $design_setting->admin_menu_select_color .' !important' : '#0fd8d0';
    $menu_label = (!empty($design_setting->admin_menu_lbl_color)) ? $design_setting->admin_menu_lbl_color .' !important' : '#FFF';
    $menu_bg_color = (!empty($design_setting->admin_menu_bg_color)) ? $design_setting->admin_menu_bg_color .' !important' : '#444';
    
} elseif($user_data['role'] == 1) {
    
    $menu_bg = (!empty($design_setting->user_menu_bg)) ? 'url(' . base_url() . 'uploads/settings/user_menu_bg/'. $design_setting->user_menu_bg .') !important' : '#EBEBEB';
    $menu_select_color = (!empty($design_setting->user_menu_select_color)) ? $design_setting->user_menu_select_color .' !important' : '#0fd8d0';
    $menu_label = (!empty($design_setting->user_menu_lbl_color)) ? $design_setting->user_menu_lbl_color .' !important' : '#FFF';
    $menu_bg_color = (!empty($design_setting->user_menu_bg_color)) ? $design_setting->user_menu_bg_color .' !important' : '#444';
    
} else {
    $admin_menu_bg = '#EBEBEB';
    $menu_select_color = '#0fd8d0';
    $menu_label = '';
    $menu_bg_color = '#444';
}
?>

<style>
    /* .skin-black .sidebar a {
        color: #FFF;
    } */
    .skin-black .sidebar > .sidebar-menu > li > .treeview-menu {
        background:<?php echo $menu_bg_color;?>
    }
    .set_bg {
       background:<?php echo $menu_bg;?>; 
    }
    .skin-black .sidebar > .sidebar-menu > li > a:hover{
        color:<?php echo $menu_select_color;?>;
        background: <?php echo $menu_bg_color;?>;
    }
    .sidebar .sidebar-menu > li:hover > a > .fa, .active a i {
        color:<?php echo $menu_select_color;?>;
    }
    .skin-black .sidebar > .sidebar-menu > li.active > a {
        background:<?php echo $menu_label;?>
        
    }
    .sidebar .sidebar-menu .treeview-menu > li > a, .treeview-menu > li > a > .fa, .treeview-menu > li > a > .icon {
        color:<?php echo $menu_label;?>
    }
    
    .sidebar .sidebar-menu li.active > a, .treeview-menu > li:hover > a > .fa, .treeview-menu > li:hover  > a > .icon{
        color:<?php echo $menu_select_color;?>
    }
    
</style>
<aside class="left-side sidebar-offcanvas set_bg">
    <!-- sidebar: style can be found in sidebar.less -->
    <?php #echo '<pre>'; print_r($permissions);print_r($master_permissions);print_r($inventory_permissions);print_r($billing_permissions);print_r($report_permissions);echo '</pre>'; ?>
    <section class="sidebar">
        <ul class="sidebar-menu">
            <li <?php echo ($menu == 'home') ? 'class="active"' : '';?>>
                <a href="<?php echo base_url();?>home">
                    <i class="fa fa-dashboard"></i> <span>Dashboard</span>
                </a>
            </li>
            
            <?php if( IS_KSK_ADMIN && !empty($permissions['sett']) ) :
                        // Settings for Kiosk Admin User only
            ?>    
                    <li class="<?php echo $menu == 'billing_settings' ? 'active' : '';?>">
                        <a href="<?php echo base_url(); ?>billing_settings/">
                            <i class="fa fa-cog"></i> <span>Settings</span>
                        </a>
                    </li>
            <?php
                elseif ((!empty($user_data['role'])) && ($user_data['role'] == 3) ) :
                    // For Super Admin only
                    ?>
                    <li class="treeview <?php echo (($menu == 'basic_settings') || ($menu == 'general_settings') || ($menu == 'design_settings') || ($menu == 'service_settings') || ($menu == 'master_settings') || ($menu == 'inventory_settings') || ($menu == 'report_settings')) ? 'active' : '';?>">
                        <a href="#">
                            <i class="fa fa-cog"></i> <span>Settings</span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>
                        <ul class="treeview-menu">
                            <li class="<?php echo ($menu == 'basic_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>basic_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Basic Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'general_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>general_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>General Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'design_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>design_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Design Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'service_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>service_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Service Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'master_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>master_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Master Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'inventory_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>inventory_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Inventory Settings</span> 
                                </a>
                            </li>
                            <li class="<?php echo ($menu == 'report_settings') ? 'active' : '';?>">
                                <a href="<?php echo base_url();?>report_settings">
                                    <i class="fa fa-angle-double-right"></i> <span>Report Settings</span> 
                                </a>
                            </li>
                        </ul>
                    </li>
            <?php endif; ?>
            
            
            <?php if ((!empty($user_data['role'])) && ($user_data['role'] > 1)) {?>
                <?php if (count($this->master_menu)) {?>
                <li class="treeview <?php echo (in_array($menu, array_column($this->master_menu, 'controller_name'))) ? 'active' : '';?>">
                    <a href="#">
                        <i class="fa fa-user-secret"></i> <span>Masters</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <?php foreach($this->master_menu as $key => $master) {?>
                            <li class="<?php echo ($menu == $master['controller_name']) ? 'active' : '';?>">
                                <a href="<?php echo base_url() . $master['controller_name']; ?>">
                                    <i class="fa <?php echo (!empty($master['menu_icon'])) ? $master['menu_icon'] : 'fa-angle-double-right'; ?>"></i> <span><?php echo (!empty($master['menu_name'])) ? $master['menu_name'] : $master['master_name'];?></span> 
                                </a>
                            </li>
                        <?php }?>
                    </ul>
                </li>
                <?php }?>
                
                <?php  if (count($this->inventory_menu)) {?>
                    <li class="treeview <?php echo (in_array($menu, array_column($this->inventory_menu, 'controller_name'))) ? 'active' : '';?>">
                        <a href="#">
                            <i class="fa fa-cubes"></i> <span>Inventory</span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>
                        <ul class="treeview-menu">
                            <?php foreach($this->inventory_menu as $key => $master) {?>
                                <li class="<?php echo ($menu == $master['controller_name']) ? 'active' : '';?>">
                                    <a href="<?php echo base_url() . $master['controller_name']; ?>">
                                        <i class="fa <?php echo (!empty($master['menu_icon'])) ? $master['menu_icon'] : 'fa-angle-double-right'; ?>"></i> <span><?php echo (!empty($master['menu_name'])) ? $master['menu_name'] : $master['inventory_name'];?></span> 
                                    </a>
                                </li>
                            <?php }?>
                        </ul>
                    </li>
                <?php }?>
                
                <?php  if (count($this->statue_menu)) {?>
                    <li class="treeview <?php echo (in_array($menu, array_column($this->statue_menu, 'controller_name'))) ? 'active' : '';?>">
                        <a href="#">
                            <i class="fa fa-book"></i> <span>Statue and Books</span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>
                        <ul class="treeview-menu"> 
                            <?php foreach($this->statue_menu as $key => $master) {?>
                                <li class="<?php echo ($menu == $master['controller_name']) ? 'active' : '';?>">
                                    <a href="<?php echo base_url() . $master['controller_name']; ?>">
                                        <i class="fa <?php echo (!empty($master['menu_icon'])) ? $master['menu_icon'] : 'fa-angle-double-right'; ?>"></i> <span><?php echo (!empty($master['menu_name'])) ? $master['menu_name'] : $master['menu_name'];?></span> 
                                    </a>
                                </li>
                            <?php }?>
                        </ul>
                    </li>
                <?php }?>
            <?php }?>
            
            
            
            <?php if (count($this->billing_menu)) {?>
                <li class="treeview <?php echo (in_array($menu, array_column($this->billing_menu, 'controller_name'))) ? 'active' : '';?>">
                    <a href="#">
                        <i class="fa fa-dollar"></i> <span>Billing Information</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <?php foreach($this->billing_menu as $key => $master) {?>
                            <li class="<?php echo ($menu == $master['controller_name']) ? 'active' : '';?>">
                                <a href="<?php echo base_url() . $master['controller_name'] . '/add/' . $master['id']; ?>">
                                    <i class="<?php echo 'icon icon-'. $master['seq_number'];?>"></i> <span><?php echo (!empty($master['menu_name'])) ? $master['menu_name'] : $master['service_name'];?></span> 
                                </a>
                            </li>
                        <?php }?>
                    </ul>
                </li>
            <?php }?>
          
            <?php if ((!empty($user_data['role'])) && ($user_data['role'] > 1)) {?>
                <?php if (count($this->report_menu)) {?>
                    <li class="treeview <?php echo (in_array($menu, array_column($this->report_menu, 'controller_name'))) ? 'active' : '';?>">
                        <a href="#">
                            <i class="fa fa-bar-chart-o"></i> <span>Report</span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>
                        <ul class="treeview-menu">
                            <?php foreach($this->report_menu as $key => $master) {?>
                                <li class="<?php echo ($menu == $master['controller_name']) ? 'active' : '';?>">
                                    <a href="<?php echo base_url() . $master['controller_name']; ?>">
                                        <i class="fa <?php echo (!empty($master['menu_icon'])) ? $master['menu_icon'] : 'fa-angle-double-right'; ?>"></i> <span><?php echo (!empty($master['menu_name'])) ? $master['menu_name'] : $master['report_name'];?></span> 
                                    </a>
                                </li>
                            <?php }?>
                        </ul>
                    </li>
                <?php }?>
            <?php }?>
        </ul>
    </section>
</aside><!-- /.sidebar -->