<?php
	require_once('dbconfig.php');
	require_once('function.php');

  

    if(isset($_SESSION['SESS_TOKEN']))
	{
	$rows = sql($DBH, "SELECT * FROM tbl_user where hash = ?", array($SESS_HASH_USER), "rows");							
		foreach($rows as $row)
		{	
                $fullname 	 	= $row['fullname'];
                $profile_pic 		= $row['profile_pic'];
                $user_email	 	= $row['email'];
                $user_phone	 	= $row['phone'];
                $user_phone	 	= $row['phone'];
                $user_county	 	= $row['country'];
                $user_state	 	= $row['state'];
                $user_city	 	= $row['city'];
                $user_registration_date	= $row['registration_date'];
                $user_hash	 	= $row['hash'];
                $user_type	 	= $row['s_type'];
                $user_status	 	= $row['status'];
                $moderator	 	= $row['moderator'];
                
		}
		
		if($profile_pic == "default.jpg"){
		$user_true 			 = "<img class='user one' src='profile_pic/profile.jpg' width='200px'><a class='navbar-brand' href='index.php' style='font-weight: bold; color: gold'> $SESS_FULLNAME_USER</a>";
		}
		else{
		$user_true 			 = "<img class='user one' src='profile_pic/$profile_pic' width='200px'><a class='navbar-brand' href='index.php' style='font-weight: bold; color: gold'> $SESS_FULLNAME_USER</a>";
		}
		
}
            		$STH 			= $DBH->prepare("SELECT count(*) FROM tbl_message WHERE recipient_hash = ? AND status = ?");
			$result 	   	= $STH->execute(array($SESS_HASH_USER, "UNREAD"));
			$count		  	= $STH->fetchColumn();
			if($count > 0){
			$count_msg = "
            <span class='indicator text-primary d-none d-lg-block'>
              <h8><strong>...$count</strong></h8>
            </span>";
            }else{
			$count_msg = "
            <span class='indicator text-primary d-none d-lg-block'>
              <i class='fa fa-fw fa-circle'></i>
            </span>";
            }
				        
				        $rows3 = sql($DBH, "SELECT * FROM tbl_message WHERE recipient_hash = ?", 
				    array($SESS_HASH_USER), "rows");							
				        foreach($rows3 as $row3){
				        $sent_id		= $row3['id'];
				        $sent_message 	 	= $row3['sent_message'];
				        $sender_hash 		= $row3['sender_hash'];
				        
				        $rows4 = sql($DBH, "SELECT * FROM tbl_user WHERE hash = ?", 
				    array($sender_hash), "rows");							
				        foreach($rows4 as $row4){
				        
				        $b_fullname 	= $row4['fullname'];
			        
            $inbox_msg ="
            <div class='dropdown-divider'></div>
            <a class='dropdown-item' href='message.php?sender_hash=$sender_hash'>
              <strong>$b_fullname</strong>
              <span class='small float-right text-muted'>11:21 AM</span>
              <div class='dropdown-message small'> $sent_message </div>
            </a>";
            }
         }
            
			if($count > 0){
			$view_count = "
            <div class='dropdown-divider'></div>
            <a class='dropdown-item small' href='#'>View all messages</a>
          </div>";
          }else{
			$view_count = "
            <div class='dropdown-divider'></div>
            <a class='dropdown-item small' href='#'>No Message</a>
          </div>";
          }
          
	$header_web = "<header>
	
  <nav class='navbar navbar-expand-lg navbar-dark bg-dark fixed-top' id='mainNav'>
  $user_true
    <button class='navbar-toggler navbar-toggler-right' type='button' data-toggle='collapse' data-target='#navbarResponsive' aria-controls='navbarResponsive' aria-expanded='false' aria-label='Toggle navigation'>
      <span class='navbar-toggler-icon'></span>
    </button>
    <div class='collapse navbar-collapse' id='navbarResponsive'>
      <ul class='navbar-nav navbar-sidenav' id='exampleAccordion'>
        <li class='nav-item' data-toggle='tooltip' data-placement='right' title='Dashboard'>
          <a class='nav-link' href='index.php'>
            <i class='fa fa-fw fa-dashboard fa-spin' style='color: #3498db'></i>
            <span class='nav-link-text' style='color: yellow'>Dashboard</span>
          </a>
        </li>
        <li class='nav-item' data-toggle='tooltip' data-placement='right' title='Charts'>
          <a class='nav-link' href='account.php'>
            <i class='fa fa-fw fa-user-o fa-spin' style='color: #3498db'></i>
            <span class='nav-link-text' style='color: yellow'>Personal Account</span>
          </a>
        </li>
        <li class='nav-item' data-toggle='tooltip' data-placement='right' title='Menu Levels'>
          <a class='nav-link nav-link-collapse collapsed' data-toggle='collapse' href='#collapseMulti' data-parent='#exampleAccordion'>
            <i class='fa fa-fw fa-money fa-spin' style='color: blue'></i>
            <span class='nav-link-text' style='color: yellow'>P2P Market Place</span>
          </a>
          <ul class='sidenav-second-level collapse' id='collapseMulti'>
            <li>
              <a style='color: white' href='p2p_market_buy.php'>Buy Cryptocurrencies</a>
            </li>
            <li>
              <a style='color: white' href='p2p_market_sell.php'>Sell Cryptocurrencies</a>
            </li>
            <li>
              <a style='color: white' href='p2p_market_items.php'>Buy and Sell Items</a>
            </li>
           </ul>
        </li>
        <li class='nav-item' data-toggle='tooltip' data-placement='right' title='Tables'>
          <a class='nav-link' href='#'>
            <i class='fa fa-fw fa-money fa-spin' style='color: #3498db'></i>
            <span class='nav-link-text' style='color: yellow'>Crypto-Exchange</span>
          </a>
        </li>
      </ul>
      <ul class='navbar-nav ml-auto'>
        <li class='nav-item dropdown'>
          <a class='nav-link dropdown-toggle mr-lg-2' id='messagesDropdown' href='#' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
            <i class='fa fa-fw fa-envelope'></i>
            <span class='d-lg-none'>Messages
              <span class='badge badge-pill badge-primary'>12 New</span>
            </span>
            $count_msg
          </a>
          <div class='dropdown-menu' aria-labelledby='messagesDropdown'>
            <h6 class='dropdown-header'>New Messages:</h6>
            
            <ul>
            $inbox_msg
            </ul>
            
            $view_count
        </li>
        <li class='nav-item dropdown'>
          <a class='nav-link dropdown-toggle mr-lg-2' id='alertsDropdown' href='#' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
            <i class='fa fa-fw fa-bell'></i>
            <span class='d-lg-none'>Alerts
              <span class='badge badge-pill badge-warning'>6 New</span>
            </span>
            <span class='indicator text-warning d-none d-lg-block'>
              <i class='fa fa-fw fa-circle'></i>
            </span>
          </a>
          <div class='dropdown-menu' aria-labelledby='alertsDropdown'>
            <h6 class='dropdown-header'>New Alerts:</h6>
            <div class='dropdown-divider'></div>
            <a class='dropdown-item' href='#'>
              <span class='text-success'>
                <strong>
                  <i class='fa fa-long-arrow-up fa-fw'></i>Status Update</strong>
              </span>
              <span class='small float-right text-muted'>11:21 AM</span>
              <div class='dropdown-message small'>This is an automated server response message. All systems are online.</div>
            </a>
            <div class='dropdown-divider'></div>
            <a class='dropdown-item' href='#'>
              <span class='text-danger'>
                <strong>
                  <i class='fa fa-long-arrow-down fa-fw'></i>Status Update</strong>
              </span>
              <span class='small float-right text-muted'>11:21 AM</span>
              <div class='dropdown-message small'>This is an automated server response message. All systems are online.</div>
            </a>
            <div class='dropdown-divider'></div>
            <a class='dropdown-item' href='#'>
              <span class='text-success'>
                <strong>
                  <i class='fa fa-long-arrow-up fa-fw'></i>Status Update</strong>
              </span>
              <span class='small float-right text-muted'>11:21 AM</span>
              <div class='dropdown-message small'>This is an automated server response message. All systems are online.</div>
            </a>
            <div class='dropdown-divider'></div>
            <a class='dropdown-item small' href='#'>View all alerts</a>
          </div>
        </li>
        </li>
        <li class='nav-item'>
          <a class='nav-link' data-toggle='modal' data-target='#exampleModal' style='color: white'>
            <i class='fa fa-fw fa-btc'></i>1BTC = ?	|</a>
        </li>
        </li>
        <li class='nav-item'>
          <a class='nav-link' data-toggle='modal' data-target='#exampleModal' style='color: white'>
            <img src='image/eth.png' alt='' title='' /></img>1 ETH= ?	|</a>
        </li>
        <li class='nav-item'>
          <a class='nav-link' data-toggle='modal' data-target='#exampleModal' style='color: white'>
            <img src='image/verg.png' alt='' title='' /><img>1 Verge= ?	|</a>
        </li>
        <li class='nav-item'>
          <a class='nav-link' data-toggle='modal' data-target='#exampleModal' style='color: yellow'>
            <i class='fa fa-fw fa-sign-out'></i>Logout</a>
        </li>
      </ul>
    </div>
  </nav>
        	</header>";
?>