<?php
		$email = $_SESSION['alogin'];
		$sql = "SELECT * from users where email = (:email);";
		$query = $dbh->prepare($sql);
		$query->bindParam(':email', $email, PDO::PARAM_STR);
		$query->execute();
		$result = $query->fetch(PDO::FETCH_OBJ);
		$cnt = 1;
        $_SESSION['user_id']=$result->id;
        $bbbb = $result->balance;
?>
<!--  Header Start -->
<header class="app-header" style="border-bottom: 1px dotted #adadad;">
    <nav class="navbar navbar-expand-lg navbar-light">
        <ul class="navbar-nav">
            <li class="nav-item d-block d-xl-none">
                <a class="nav-link sidebartoggler nav-icon-hover" id="headerCollapse" href="javascript:void(0)">
                    <i class="ti ti-menu-2"></i>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link nav-icon-hover notifDiv" id="" href="#" >
                    
                    
                    
                </a>
            </li>
        </ul>
        <div class="navbar-collapse justify-content-end px-0" id="navbarNav">
            <ul class="navbar-nav flex-row ms-auto align-items-center justify-content-end">
                <a href="#" target="_blank" class="btn btn-primary"><?php echo htmlentities($result->balance); ?> ৳</a>
                <li class="nav-item dropdown">
                    <a class="nav-link nav-icon-hover" href="javascript:void(0)" id="drop2" data-bs-toggle="dropdown" aria-expanded="false">
                        <img src="assets/images/logos/2.png" alt="" width="35" height="35" class="rounded-circle">
                    </a>
                    <div class="dropdown-menu dropdown-menu-end dropdown-menu-animate-up" aria-labelledby="drop2">
                        <div class="message-body">
                            <a href="profile.php" class="d-flex align-items-center gap-2 dropdown-item">
                                <i class="ti ti-user fs-6"></i>
                                <p class="mb-0 fs-3">প্রোফাইল</p>
                            </a>
                            <a href="change-password.php" class="d-flex align-items-center gap-2 dropdown-item">
                                <i class="ti ti-key fs-6"></i>
                                <p class="mb-0 fs-3">পাসওয়ার্ড পরিবর্তন</p>
                            </a>
                            
                            <a href="logout.php" class="btn btn-outline-primary mx-3 mt-2 d-block">লগ আউট</a>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </nav>
    
</header>
<!--  Header End -->
<script>

    var notifIcon = $(".notifIcon");
    var notifDiv = $(".notifDiv");
     // Create a new <div> element with the specified classes

    setInterval(() => {
        $.ajax({
            type: "POST",
            url: "lib/notification.php",
            data: {email:'<?php echo $_SESSION['alogin'] ?>'},
            dataType:"json",
            success: function (response) {
                if(response.sign != 0 || response.server != 0){
                    notifDiv.empty();
                    notifDiv.append("<i class=\"ti ti-bell-ringing\"></i>");
                    notifDiv.append("<div class=\"notification bg-danger rounded-circle\"></div>");
                    notifDiv.append("<div class=\"alert alert-primary notifText\" style=\"position: absolute;top: 3.5rem;width: 15rem;line-height: 1.5rem;padding: .5rem;display:none;\" role=\"alert\">আপনার সাইন/সার্ভার কপি অর্ডার ডেলিভারি করা হয়েছে।</div>");
                
                }else{
                    notifDiv.empty();
                } 
            }
        });
    }, 200);
    
    
</script>