<?php
	include_once __DIR__ . '/../config/dbconn.php';
	$username = 'Admin@Admin.com';
	//$username = $_SESSION["usrname"];
	//$laccess = $_SESSION["laccess"];

	$getParentmenus = "SELECT * FROM tbl_users 
						INNER JOIN access_level ON access_level_cde=access_level_id 
						INNER JOIN access_level_menu_navbar ON access_level_id=userid  
						INNER JOIN tbl_menu_list ON nav_menu_id=id 
						WHERE userstatus=1 AND uname='$username' AND parentid=0 
						ORDER BY id";
	$query = mysqli_query($con, $getParentmenus);

?>

<!-- Start the content for this page -->
<?= startSection('navbar') ?> 
<nav class="navbar navbar-expand-lg navbar-light flex-row border-bottom shadow" style="background: blue">
    <div class="container-fluid">
        <a class="navbar-brand mx-lg-1 mr-0" href="<?=$baseURL?>/" style="display: flex; align-items: center;">
            <!-- Logo Image -->
            <img src="<?=$baseURL?>/assets/images/pwdlogo.png" alt="Logo" style="width: 70px; height: 70px; margin-right: 10px;">
            <!-- Text Section -->
            <div>
                <h1 style="color: white; font-size: 24px; font-weight: bold; margin: 0;"><?=$ENV['APP_NAME']?></h1>
                <p style="color: white; font-size: 16px; margin: 0;">"Embrace, Empower, Achieve"</p>
            </div>
        </a>
        <button class="navbar-toggler mt-2 mr-auto toggle-sidebar text-muted">
			<svg version="1.1" id="logo" class="navbar-brand-img brand-sm" src="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 120 120" xml:space="preserve"><g><polygon class="st0" points="78,105 15,105 24,87 87,87  " /><polygon class="st0" points="96,69 33,69 42,51 105,51   " /><polygon class="st0" points="78,33 15,33 24,15 87,15  " /></g></svg>
        </button>
        <ul class="navbar-nav d-flex flex-row">
            <li class="nav-item dropdown ml-lg-0">
                <a class="nav-link dropdown-toggle text-muted" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="avatar avatar-sm mt-2">
                        <img src="<?=$baseURL?>/assets/avatars/face-1.jpg" alt="..." class="avatar-img rounded-circle">
                    </span>
                </a>
                <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
                    <li class="nav-item">
                        <a class="nav-link pl-3" href="#">Settings</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link pl-3" href="#">Profile</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link pl-3" href="#">Activities</a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</nav>
<nav class="navbar navbar-expand-lg navbar-light bg-white flex-row border-bottom shadow">
	<div class="container-fluid"> 
        <div class="navbar-slide bg-white ml-lg-4" id="navbarSupportedContent">
            <a href="#" class="btn toggle-sidebar d-lg-none text-muted ml-2 mt-3" data-toggle="toggle">
                <i class="fe fe-x">
                    <span class="sr-only"></span>
                </i>
            </a>
            <ul class="navbar-nav mr-auto"> 
			                <!-- No child menu -->
                <li class="nav-item">
                    <a href="
								/" class="nav-link" role="button">
                        <i class="
									fe fe-home fe-16">
                        </i>
                        <!-- Add your icon class here -->
                        <span class="ml-lg-2"> Dashboard </span>
                        <span class="sr-only">(current)</span>
                    </a>
                </li> 
			 
			                <!-- Parent menu with dropdown -->
                <li class="nav-item dropdown">
                    <a class="dropdown-toggle nav-link pl-lg-3" href="#" id="appsDropdown_295" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fe fe-settings fe-16"></i>
                        <span class="ml-lg-2"> User Management </span>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="appsDropdown_295"> 
											<!-- Child menu with third-level dropdown -->
						<li class="nav-item dropdown">
							<a class="dropdown-toggle nav-link pl-lg-2" href="#" id="contactDropdown_204" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="fe fe-user fe-16"></i>
								<span class="ml-1"> User </span>
							</a>
							<ul class="dropdown-menu" aria-labelledby="contactDropdown_204"> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="add-user.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> Add User </span>
									</a>
								</li> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="list-user.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> List User </span>
									</a>
								</li> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="add-access-menu.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> Modify User Level </span>
									</a>
								</li> 
							 
							</ul>
						</li> 
						 
											<!-- Child menu with third-level dropdown -->
						<li class="nav-item dropdown">
							<a class="dropdown-toggle nav-link pl-lg-2" href="#" id="contactDropdown_208" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="fe fe-trello fe-16"></i>
								<span class="ml-1"> Access Level </span>
							</a>
							<ul class="dropdown-menu" aria-labelledby="contactDropdown_208"> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="add-user-level.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> Add User Access Level </span>
									</a>
								</li> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="list-accesslvl.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> View User Access Level </span>
									</a>
								</li> 
							 
							</ul>
						</li> 
						 
											<!-- Child menu with third-level dropdown -->
						<li class="nav-item dropdown">
							<a class="dropdown-toggle nav-link pl-lg-2" href="#" id="contactDropdown_232" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="fe fe-menu fe-16"></i>
								<span class="ml-1"> Dynamic Menu </span>
							</a>
							<ul class="dropdown-menu" aria-labelledby="contactDropdown_232"> 
							 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="list_of_dynamic_menu.php">
										<i class="fe fe-minus fe-16"></i>
										<span class="ml-1"> List Dynamic Menu </span>
									</a>
								</li> 
							 
							</ul>
						</li> 
						 
					                    </ul>
				</li> 
				 
			                <!-- Parent menu with dropdown -->
                <li class="nav-item dropdown">
                    <a class="dropdown-toggle nav-link pl-lg-3" href="#" id="appsDropdown_308" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fe fe-git-pull-request fe-16"></i>
                        <span class="ml-lg-2"> Donation </span>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="appsDropdown_308"> 
											<!-- Child menu (no further children) -->
						<li class="nav-item">
							<a class="nav-link pl-lg-2" href="items">
								<i class="fe fe-check fe-16"></i>
								<span class="ml-1"> Item List </span>
							</a>
						</li> 
						 
											<!-- Child menu (no further children) -->
						<li class="nav-item">
							<a class="nav-link pl-lg-2" href="list_for_approval_request.php">
								<i class="fe fe-check-circle fe-16"></i>
								<span class="ml-1"> Approve Request </span>
							</a>
						</li> 
						 
											<!-- Child menu (no further children) -->
						<li class="nav-item">
							<a class="nav-link pl-lg-2" href="list_request.php">
								<i class="fe fe-list fe-16"></i>
								<span class="ml-1"> List of Request Donation </span>
							</a>
						</li> 
						 
					                    </ul>
				</li> 
				 
						</ul>
		</div>
		<!-- <form class="form-inline ml-md-auto d-none d-lg-flex text-muted" hidden>
		<input class="form-control mr-sm-2 bg-transparent border-0 pl-4 text-muted" type="search" placeholder="Type something..." aria-label="Search">
		</form> -->
		<ul class="navbar-nav d-flex flex-row" hidden="">
			<li class="nav-item">
				<a class="nav-link text-muted my-2" href="./#" id="modeSwitcher" data-mode="light" hidden="">
					<i class="fe fe-sun fe-16"></i>
				</a>
			</li>
			<li class="nav-item" hidden="">
				<a class="nav-link text-muted my-2" href="./#" data-toggle="modal" data-target=".modal-shortcut" hidden="">
					<i class="fe fe-grid fe-16"></i>
				</a>
			</li>
			<li class="nav-item nav-notif" hidden="">
				<a class="nav-link text-muted my-2" href="./#" data-toggle="modal" data-target=".modal-notif">
					<i class="fe fe-bell fe-16"></i>
					<span class="dot dot-md bg-success"></span>
				</a>
			</li>
			<li class="nav-item dropdown ml-lg-0" hidden="">
				<a class="nav-link dropdown-toggle text-muted" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					<span class="avatar avatar-sm mt-2">
						<img src="http://66.113.234.121/senior/assets/avatars/face-1.jpg" alt="..." class="avatar-img rounded-circle">
					</span>
				</a>
				<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Settings</a>
					</li>
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Profile</a>
					</li>
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Activities</a>
					</li>
				</ul>
			</li>
		</ul>
	</div>
    <div class="container-fluid"> 
        <div class="navbar-slide bg-white ml-lg-4" id="navbarSupportedContent">
            <a href="#" class="btn toggle-sidebar d-lg-none text-muted ml-2 mt-3" data-toggle="toggle">
                <i class="fe fe-x">
                    <span class="sr-only"></span>
                </i>
            </a>
            <ul class="navbar-nav mr-auto"> 
			<?php
			while ($parentMenu = mysqli_fetch_assoc($query)) {
				$parentid = $parentMenu['id'];
				$checkChildSql = "SELECT * FROM tbl_users 
								INNER JOIN access_level ON access_level_cde=access_level_id 
								INNER JOIN access_level_menu_navbar ON access_level_id=userid  
								INNER JOIN tbl_menu_list ON nav_menu_id=id 
								WHERE userstatus=1 AND uname='$username' AND parentid = '$parentid' 
								ORDER BY id";
				$runQuery = mysqli_query($con, $checkChildSql);
				$count_rows = mysqli_num_rows($runQuery);

				if ($count_rows == 0) {
			?>
                <!-- No child menu -->
                <li class="nav-item">
                    <a href="
								<?= $parentMenu['link'] ?>" class="nav-link" role="button">
                        <i class="
									<?= $parentMenu['icon'] ?>">
                        </i>
                        <!-- Add your icon class here -->
                        <span class="ml-lg-2"> <?= $parentMenu['title'] ?> </span>
                        <span class="sr-only">(current)</span>
                    </a>
                </li> 
			<?php } else { ?>
                <!-- Parent menu with dropdown -->
                <li class="nav-item dropdown">
                    <a class="dropdown-toggle nav-link pl-lg-3" href="#" id="appsDropdown_<?= $parentid ?>" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="<?= $parentMenu['icon'] ?>"></i>
                        <span class="ml-lg-2"> <?= $parentMenu['title'] ?> </span>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="appsDropdown_<?= $parentid ?>"> 
					<?php 
						while ($childItem = mysqli_fetch_assoc($runQuery)) {
						$parentid1 = $childItem['id'];
						$checkChildSql1 = "SELECT * FROM tbl_menu_list WHERE parentid = '$parentid1' ORDER BY id ASC";
						$runQuery1 = mysqli_query($con, $checkChildSql1);
						$count_rows1 = mysqli_num_rows($runQuery1);

						if ($count_rows1 == 0) { ?>
						<!-- Child menu (no further children) -->
						<li class="nav-item">
							<a class="nav-link pl-lg-2" href="<?= $childItem['link'] ?>">
								<i class="<?= $childItem['icon'] ?>"></i>
								<span class="ml-1"> <?= $childItem['title'] ?> </span>
							</a>
						</li> 
						<?php } else { ?>
						<!-- Child menu with third-level dropdown -->
						<li class="nav-item dropdown">
							<a class="dropdown-toggle nav-link pl-lg-2" href="#" id="contactDropdown_<?= $parentid1 ?>" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="<?= $childItem['icon'] ?>"></i>
								<span class="ml-1"> <?= $childItem['title'] ?> </span>
							</a>
							<ul class="dropdown-menu" aria-labelledby="contactDropdown_<?= $parentid1 ?>"> 
							<?php 
								while ($childItem1 = mysqli_fetch_assoc($runQuery1)) { ?> 
								<li class="nav-item">
									<a class="nav-link pl-lg-2" href="<?= $childItem1['link'] ?>">
										<i class="<?= $childItem1['icon'] ?>"></i>
										<span class="ml-1"> <?= $childItem1['title'] ?> </span>
									</a>
								</li> 
							<?php } ?> 
							</ul>
						</li> 
						<?php } ?> 
					<?php } ?>
                    </ul>
				</li> 
				<?php } ?> 
			<?php } ?>
			</ul>
		</div>
		<!-- <form class="form-inline ml-md-auto d-none d-lg-flex text-muted" hidden>
		<input class="form-control mr-sm-2 bg-transparent border-0 pl-4 text-muted" type="search" placeholder="Type something..." aria-label="Search">
		</form> -->
		<ul class="navbar-nav d-flex flex-row" hidden>
			<li class="nav-item">
				<a class="nav-link text-muted my-2" href="./#" id="modeSwitcher" data-mode="light" hidden>
					<i class="fe fe-sun fe-16"></i>
				</a>
			</li>
			<li class="nav-item" hidden>
				<a class="nav-link text-muted my-2" href="./#" data-toggle="modal" data-target=".modal-shortcut" hidden>
					<i class="fe fe-grid fe-16"></i>
				</a>
			</li>
			<li class="nav-item nav-notif" hidden>
				<a class="nav-link text-muted my-2" href="./#" data-toggle="modal" data-target=".modal-notif">
					<i class="fe fe-bell fe-16"></i>
					<span class="dot dot-md bg-success"></span>
				</a>
			</li>
			<li class="nav-item dropdown ml-lg-0" hidden>
				<a class="nav-link dropdown-toggle text-muted" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					<span class="avatar avatar-sm mt-2">
						<img src="<?=$baseURL?>/assets/avatars/face-1.jpg" alt="..." class="avatar-img rounded-circle">
					</span>
				</a>
				<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Settings</a>
					</li>
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Profile</a>
					</li>
					<li class="nav-item">
						<a class="nav-link pl-3" href="#">Activities</a>
					</li>
				</ul>
			</li>
		</ul>
	</div>
</nav>
<?= endSection() ?> 