<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
	<!-- Brand Logo -->
	<a href="<?php echo base_url().$this->config->item('admin_folder').'dashboard'; ?>" class="brand-link text-center">
		<span class="brand-text font-weight-bold">TFI Lead Generation</span>
	</a>

	<!-- Sidebar -->
	<div class="sidebar">
		<!-- Sidebar user (optional) -->
		<div class="user-panel mt-3 pb-3 mb-3 d-flex">
			<div class="image">
				<img src="<?php echo $this->config->item("admin_assets_folder"); ?>dist/img/user-icon.svg" class="img-circle elevation-2" alt="User Image">
			</div>
			<div class="info">
				<a href="#" class="d-block"><?php echo $_SESSION['name']; ?></a>
			</div>
		</div>

		<!-- Sidebar Menu -->
		<nav class="mt-2">
			<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">

				<li class="nav-item">
					<a href="<?php echo base_url().$this->config->item('admin_folder').'/'.'dashboard'; ?>" class="nav-link <?php echo isset($page_name) && $page_name == "dashboard" ? 'active' : ''; ?>">
				  		<i class="nav-icon fas fa-tachometer-alt"></i>
				  		<p>Dashboard</p>
					</a>
				</li>

				<?php
					if(isset($admin_modules) && !empty($admin_modules)){
		                foreach ($admin_modules as $key => $value) {
		                    if(empty($value->sub_modules)){
		        ?>
		        				<li class="nav-item">
									<a href="<?php echo base_url().$this->config->item('admin_folder').'/'.$value->module_page_name; ?>" class="nav-link <?php echo isset($page_name) && $page_name == $value->module_unique_name ? 'active' : ''; ?>">
								  		<i class="nav-icon <?php echo $value->icon; ?>"></i>
								  		<p><?php echo $value->module_group_name; ?></p>
									</a>
								</li>
		        <?php
		                    }else{
		                    	$submodule_key = array_column($value->sub_modules, 'module_unique_name');
		        ?>
		        				<li class="nav-item has-treeview <?php echo isset($page_name) && in_array($page_name, $submodule_key) ? 'menu-open' : ''; ?>">
									<a href="#" class="nav-link <?php echo isset($page_name) && in_array($page_name, $submodule_key) ? 'active' : ''; ?>">
								  		<i class="nav-icon <?php echo $value->icon; ?>"></i>
								  		<p><?php echo $value->module_group_name; ?><i class="right fas fa-angle-left"></i></p>
									</a>
									<ul class="nav nav-treeview">
										<?php
		                                    foreach ($value->sub_modules as $key1 => $value1) {
		                                        $active_class = isset($page_name) && $page_name == $value1->module_unique_name ? 'active' : '';
                                		?>
											  	<li class="nav-item">
												    <a href="<?php echo base_url().$this->config->item('admin_folder').'/'.$value1->module_page_name; ?>" class="nav-link <?php echo $active_class; ?>">
												      	<i class="far fa-circle nav-icon"></i>
												      	<p><?php echo $value1->module_name; ?></p>
												    </a>
											  	</li>
										<?php
											}
										?>
									</ul>
								</li>
		        <?php
		                    }
		                }
		            }
				?>

								

			</ul>
		</nav>
		<!-- /.sidebar-menu -->
	</div>
	<!-- /.sidebar -->
</aside>