<!-- Topbar -->
      <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 shadow fixed-top">
<!-- Sidebar Toggle (Topbar) -->
        <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
         <i class="fa fa-bars"></i>
        </button>
<!-- Topbar Search -->
        <a class="navbar-brand" href="/dashboard" style="padding-left:10px">ZADIOCARS</a>
<!-- Topbar Navbar -->
       <ul class="navbar-nav ml-auto mr-5 pr-5">
 <!-- Nav Item - Search Dropdown (Visible Only XS) -->
        <li class="nav-item dropdown no-arrow d-sm-none">
        <?php $session = session();?>
<!-- Nav Item - Alerts -->
       <?php if($session->getFlashdata('success')){ ?>
       <li class="dropdown-menu dropdown-item">
			<div id="alert" class="alert-success"><?= session()->getFlashdata('success') ?></div>
       </li>
       <?php } ?>
	   
	   <?php if(session()->has('error')){ ?>
       <li class="dropdown-menu dropdown-item">
			<div id="alert" class="alert-danger"><?= session()->getFlashdata('error') ?></div>
       </li>
       <?php } ?>
	   
<!-- Topbar Alerts --
        <li class="nav-item dropdown no-arrow mx-1">
         <a class="nav-link dropdown-toggle" href="#" id="alertsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <i class="fas fa-bell fa-fw"></i>
		  
		  

        <span class="badge badge-danger badge-counter">3+</span>
         </a>

         <div class="dropdown-list dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="alertsDropdown">
          <h6 class="dropdown-header">Alerts Center</h6>
          <a class="dropdown-item d-flex align-items-center" href="#">
          <div class="mr-3">
           <div class="icon-circle bg-primary">
            <i class="fas fa-file-alt text-white"></i>
           </div>
          </div>
          <div>
           <div class="small text-gray-500">August 12, 2024</div>
            <span class="font-weight-bold">A new monthly report is ready to download!</span>
           </div> 
          </a>
          <a class="dropdown-item text-center small text-gray-500" href="#">Show All Alerts</a>
         </div>
        </li>
	-->	
		<?php 
			use App\Models\UserModel;
			$usr=session()->get('id');
			$usrmodel = new UserModel();
			$msgs=$usrmodel->getUsrMsg($usr);
			$msgcnt=count($msgs);
			if($msgcnt>0)
			{
			?>
		
			<!-- Nav Item - Messages -->
					<li class="nav-item dropdown no-arrow mx-1">
					 <a class="nav-link dropdown-toggle" href="#" id="messagesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					  <i class="fas fa-envelope fa-fw"></i>
				<!-- Counter - Messages -->
					  <span class="badge badge-danger badge-counter"><?=$msgcnt?></span>
					 </a>
				
				<!-- Dropdown - Messages -->
					 <div class="dropdown-list dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="messagesDropdown">
					  <h6 class="dropdown-header">Message Center</h6>
					  <a class="dropdown-item d-flex align-items-center" href="/messages">
					    <?php
							foreach ($msgs as $msg){
							
						?>
					   <div class="dropdown-list-image mr-3">
						<img class="rounded-circle" src="/rs/undraw_profile.svg" alt="...">
						<div class="status-indicator bg-success"></div>
					   </div>
					   <div class="font-weight-bold">
						<div class="text-truncate"><?=$msg['msg']?></div>
						<div class="small text-gray-500">cars.zadio.bg</div>
					   </div>
						 <?php } ?>
					  </a>
					  <a class="dropdown-item text-center small text-gray-500" href="#">Read More Messages</a>
					 </div>
					</li>
		<?php }?> 
		
        <div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User Information -->
        <li class="nav-item dropdown no-arrow">
         <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <span class="mr-2 d-none d-lg-inline text-gray-600 small"><?= session()->get('email')?></span>
          <img class="img-profile rounded-circle" src="/rs/undraw_profile.svg">
         </a>
<!-- Dropdown - User Information -->
         <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
          <a class="dropdown-item" href="/profile"><i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i> Profile</a>
          <a class="dropdown-item" href="/changepwd"><i class="fas fa-key fa-sm fa-fw mr-2 text-gray-400"></i> Change password</a>
         
		  <div class="dropdown-divider"></div>
         <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal"><i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>Logout</a>
         </div>
        </li>

        <li class="nav-item dropdown no-arrow">
         <a class="nav-link dropdown-toggle" href="#" id="settingsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <i class="fas fa-cog fa-lg fa-fw mr-2 text-dark"></i>
         </a>
<!-- Dropdown - Settings -->
         <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="settingsDropdown">
          <h1 class="dropdown-header text-dark">Editables</h1>
          <div class="dropdown-divider"></div>

          <h4 class="dropdown-header text-dark">General</h4>
          <a id="countries_bar" class="dropdown-item" href="/countries"><i class="fas fa-globe fa-sm fa-fw mr-2 text-gray-400"></i> Countries</a>
          <a id="exchange_bar" class="dropdown-item" href="<?= site_url('exchangerates'); ?>"><i class="fas fa-globe fa-sm fa-fw mr-2 text-gray-400"></i> BGN-EUR exchange rate</a>
          <div class="dropdown-divider"></div>
          
          <h4 class="dropdown-header text-dark">Cars</h4>
          <a id="brands_bar" class="dropdown-item" href="/brands"><i class="fas fa-car fa-sm fa-fw mr-2 text-gray-400"></i> Car brands</a>
          <a id="models_bar" class="dropdown-item" href="/models"><i class="fas fa-list fa-sm fa-fw mr-2 text-gray-400"></i> Car models</a>
          <a id="cars_additionals_bar" class="dropdown-item" href="<?= site_url('cars_additionals/1'); ?>"><i class="fas fa-list fa-sm fa-fw mr-2 text-gray-400"></i> Car extra details</a>
          <div class="dropdown-divider"></div>
          
          <h4 class="dropdown-header text-dark">Policies</h4>
          <a id="public_cookies_bar" class="dropdown-item" href="<?= site_url('public_cookies/1'); ?>"><i class="fas fa-cookie fa-sm fa-fw mr-2 text-gray-400"></i> Public cookies policy</a>
          <a id="public_terms_bar" class="dropdown-item" href="<?= site_url('public_terms/1'); ?>"><i class="fas fa-scroll fa-sm fa-fw mr-2 text-gray-400"></i> Public terms and conditions</a>
          <a id="ctcs_bar" class="dropdown-item" href="<?= site_url('commercial_terms_sellers/1'); ?>"><i class="fas fa-scroll fa-sm fa-fw mr-2 text-gray-400"></i> Commercial terms and conditions for sellers</a>
          <a id="ctcb_bar" class="dropdown-item" href="<?= site_url('commercial_terms_buyers/1'); ?>"><i class="fas fa-scroll fa-sm fa-fw mr-2 text-gray-400"></i> Commercial terms and conditions for buyers</a>
          <div class="dropdown-divider"></div>
          
          <h4 class="dropdown-header text-dark">Zadio</h4>
          <a id="company_bar" class="dropdown-item" href="/company"><i class="fas fa-cookie fa-sm fa-fw mr-2 text-gray-400"></i> Company Info</a>
          <a id="contacts_bar" class="dropdown-item" href="/contacts"><i class="fas fa-scroll fa-sm fa-fw mr-2 text-gray-400"></i> Company Contacts</a>
         </div>
        </li>
       </ul>
      </nav>
<!-- End of Topbar -->

