   <?php
   
   
   
		//Get all unread contact messages
		$stmt=$pdo->prepare("SELECT * FROM contact WHERE status='unread' AND userid !=:userid ORDER BY id DESC LIMIT 3");
		$stmt->bindParam(":userid",$userid, PDO::PARAM_STR);
		$stmt->execute();
		$contact=$stmt->fetchAll();
		
		
		//COUNT unread contact messages
		$stmt=$pdo->prepare("SELECT COUNT(*) AS countMsg FROM contact WHERE status='unread' AND userid !=:userid");
		$stmt->bindParam(":userid",$userid, PDO::PARAM_STR);
		$stmt->execute();
		$countMsg=$stmt->fetch();
		
	

   
   
   ?>
   
   <style>
   .navbar-custom .topnav-menu.topnav-menu-left {
    margin-left:0px!important;
	}
   </style>
   
   
   <div class="navbar-custom">
  
	
	  

      <!-- LOGO -->
      <div class="logo-box">
        <a href="../" class="logo logo-dark text-center">
		<img src="../img/logo.png" width="140px" height="50px;" style="margin-top:10px;">
        </a>
      </div>

      <ul class="list-unstyled topnav-menu topnav-menu-left mb-0">
        <li>
          <button class="button-menu-mobile disable-btn waves-effect" style="color:#fff!important">
            <i class="fe-menu" style="color:#fff!important"></i>
          </button>
        </li>

		<li>
		<div style="font-size:17px;margin:23px 10px;color:#b4c6d7;font-weight:600;">
		
		<?php
		
		if(isset($_GET["action"]) && $_GET["action"] == "Payment Transaction"){
			echo "<i class='fas fa-dollar-sign'></i> Payment Transaction";
		}elseif(isset($_GET["action"]) && $_GET["action"] == "Withdrawal Requests"){
			echo "<i class='fas fa-wallet'></i> Withdrawal Requests";
		}elseif(isset($_GET["action"]) && $_GET["action"] == "users"){
			echo "<i class='fas fa-users'></i> Users List";
		}
		
		
		$url = basename($_SERVER["PHP_SELF"]);
		
		switch($url){
		case "dashboard.php":
		echo "<i class='fas fa-tachometer-alt'></i> Admin Dashboard";
		break;
		
		case "profile.php":
		echo "<i class='fas fa-user'></i> Profile";
		break;
		
		case "inbox.php":
		echo "<i class='fas fa-inbox'></i> Chat Messages";
		break;
		
		case "changePassword.php":
		echo "<i class='fas fa-key'></i> Change Password";
		break;
	
		case "notifications.php":
		echo "<i class='fas fa-bell'></i> Notifications";
		break;
		
		case "userStats.php":
		echo "<i class='fas fa-user'></i> User Stats";
		break;
		
		case "visitorsMessage.php":
		echo "<i class='fas fa-envelope'></i> Visitors Messages";
		break;
		
		case "users.php":
		echo "<i class='fas fa-users'></i> Users List";
		break;
		
		case "pendingInvestment.php":
		echo "<i class='fas fa-dollar-sign'></i> Pnd. Investments";
		break;
		
		case "pendingWithdrawal.php":
		echo "<i class='fas fa-wallet'></i> Pnd. Withdrawals";
		break;
		
		case "maintainance.php":
		echo "<i class='fas fa-cog'></i> Site Maintenance";
		break;
		
		case "e-codeWithdrawal.php":
		echo "<i class='fas fa-lock'></i> e-code Withdrawal";
		break;
		
		case "alterReading.php":
		echo "<i class='fas fa-edit'></i> Alter Reading";
		break;
		
		case "editUser.php":
		echo "<i class='fas fa-user-cog'></i> Edit User";
		break;
		
		case "changeUserPassword.php":
		echo "<i class='fas fa-key'></i> Change User Password";
		break;
		
		case "mailUser.php":
		echo "<i class='fas fa-envelope'></i> Custom Mailing";
		break;
	
		};
		?>
		
		
		</div>
		</li>






		<!-- Messages Dropdown Menu -->
      <li class="dropdown" style="position:absolute;right:0;">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="far fa-bell" style="font-size:20px;"></i>
          <span class="badge badge-danger navbar-badge"><?php echo intval($countMsg["countMsg"]);?></span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right" style="margin-left:-20px!important;">
          


		<?php

		foreach($contact as $contacts){
		
		//get sender info
		$stmt=$pdo->prepare("SELECT * FROM users WHERE userid=:userid");
		$stmt->bindParam("userid", $contacts["userid"], PDO::PARAM_STR);
		$stmt->execute();
		$msg=$stmt->fetch();
		$msgImg = (!empty($msg["profilepix"]) ? "../img/users/".$msg["profilepix"]: "../img/avatar.png");

		?>



		<div id="<?php echo $msg["userid"];?>"  class="getMsg">
		  <a href="inbox.php?user=<?php echo $msg["userid"];?>" class="dropdown-item" >
            <!-- Message Start -->
            <div class="media">
              <img src="<?php echo $msgImg;?>" alt="User Avatar" class="img-size-50 mr-3 " 
			  style="width:60px; height:60px;border-radius:50%;border:2px solid #d3d6d7">
              <div class="media-body">
                <h3 class="dropdown-item-title" style="font-size:17px;">
                  <?php echo htmlspecialchars($msg["fullName"]);?>
                  <span class="float-right text-sm text-danger"><i class="fas fa-star"></i></span>
                </h3>
                <p class="text-sm">
				<?php echo htmlspecialchars(substr($contacts["message"],0,25))."...";?>
				</p>
                <p class="text-sm text-muted"><i class="far fa-clock mr-1"></i><?php echo date("jS F, Y", strtotime($contacts["received"]))?></p>
              </div>
            </div>
            <!-- Message End -->
          </a>
		  </div>
		<div class="dropdown-divider" style="margin:0.1rem 0;"></div>
		  
		  
	<?php } ?>	  
		  
		  
		  
		  
		  
		  <center><a href="notifications.php" class="dropdown-item">View all notifications &nbsp; &nbsp; 
		  <i class="fas fa-caret-right"></i> </a></center>
		  <div class="dropdown-divider"></div>
		  
		  
		  
		  <a href="profile.php" class="dropdown-item" >
            <div class="media">
        <img src="<?php echo $userimage;?>" alt="User Avatar" class="img-size-50 mr-3" 
		style="width:100px; height:100px;border-radius:50%;border:2px solid #d3d6d7">
              <div class="media-body">
                
			  <h3 class="dropdown-item-title">
                  <?php $namer = explode(" ",$row["fullName"]); echo $namer[0];?>
                </h3>
                <p class="text-sm">Profile information</p>
                <p class="text-sm text-muted">
				<i class="far fa-clock mr-1"></i> Registered<br>
				<?php echo date("l jS F, Y", strtotime($row["created"]));?>
				</p>
			  
			  </div>
            </div>
          </a>
         
          <div class="dropdown-divider"></div>
          <a href="profile.php" class="dropdown-item dropdown-footer">Admin Profile <span class="float-right fa fa-caret-right"></span></a>
        </div>
      </li>










      </ul>


    </div>
	
	
	
	  

