<?php 
include("db_connection.php");
if(!isset($_SESSION['aid']))
{
	?>
	<script>
    	window.location="index.php";
    </script>
	<?php
}

$selectadmin=mysql_query("select * from admin_login where aid='".$_SESSION['aid']."'");
$resadmin=mysql_fetch_assoc($selectadmin);

?>
<!DOCTYPE html>
<html class="no-js before-run" lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
  <meta name="description" content="bootstrap admin template">
  <meta name="author" content="">

  <title>OlxClone | PHP Classifieds Script</title>

  <link rel="apple-touch-icon" href="assets/images/apple-touch-icon.png">
  <link rel="shortcut icon" href="assets/images/favicon.ico">

  <!-- Stylesheets -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/css/bootstrap-extend.min.css">
  <link rel="stylesheet" href="assets/css/site.min.css">

  <link rel="stylesheet" href="assets/vendor/animsition/animsition.css">
  <link rel="stylesheet" href="assets/vendor/asscrollable/asScrollable.css">
  <link rel="stylesheet" href="assets/vendor/switchery/switchery.css">
  <link rel="stylesheet" href="assets/vendor/intro-js/introjs.css">
  <link rel="stylesheet" href="assets/vendor/slidepanel/slidePanel.css">
  <link rel="stylesheet" href="assets/vendor/flag-icon-css/flag-icon.css">

  <!-- Plugin -->
  <link rel="stylesheet" href="assets/vendor/chartist-js/chartist.css">
  <link rel="stylesheet" href="assets/vendor/aspieprogress/asPieProgress.css">
  <link rel="stylesheet" href="assets/vendor/datatables-bootstrap/dataTables.bootstrap.css">
  <link rel="stylesheet" href="assets/vendor/datatables-fixedheader/dataTables.fixedHeader.css">
  <link rel="stylesheet" href="assets/vendor/datatables-responsive/dataTables.responsive.css">

  <!-- Page -->
  <link rel="stylesheet" href="assets/css/dashboard/v2.css">
   <link rel="stylesheet" href="assets/css/pages/profile.css">

  <!-- Fonts -->
  <link rel="stylesheet" href="assets/fonts/web-icons/web-icons.min.css">
  <link rel="stylesheet" href="assets/fonts/brand-icons/brand-icons.min.css">
  <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Roboto:300,400,500,300italic'>


  <!--[if lt IE 9]>
    <script src="assets/vendor/html5shiv/html5shiv.min.js"></script>
    <![endif]-->

  <!--[if lt IE 10]>
    <script src="assets/vendor/media-match/media.match.min.js"></script>
    <script src="assets/vendor/respond/respond.min.js"></script>
    <![endif]-->

  <!-- Scripts -->
  <script src="assets/vendor/modernizr/modernizr.js"></script>
  <script src="assets/vendor/breakpoints/breakpoints.js"></script>
  
  


 <script>
    Breakpoints();
  </script>
</head>
<body class="dashboard">
  <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->

  <nav class="site-navbar navbar navbar-default navbar-fixed-top navbar-mega" role="navigation">

    <div class="navbar-header">
      <button type="button" class="navbar-toggle hamburger hamburger-close navbar-toggle-left hided"
      data-toggle="menubar">
        <span class="sr-only">Toggle navigation</span>
        <span class="hamburger-bar"></span>
      </button>
      <button type="button" class="navbar-toggle collapsed" data-target="#site-navbar-collapse"
      data-toggle="collapse">
        <i class="icon wb-more-horizontal" aria-hidden="true"></i>
      </button>
      <button type="button" class="navbar-toggle collapsed" data-target="#site-navbar-search"
      data-toggle="collapse">
        <span class="sr-only">Toggle Search</span>
        <i class="icon wb-search" aria-hidden="true"></i>
      </button>
      <div class="navbar-brand navbar-brand-center site-gridmenu-toggle" data-toggle="gridmenu">
        <img class="navbar-brand-logo" src="assets/images/logo.png" title="Remark">
        <!--<span class="navbar-brand-text"> Exchange Kar De</span>-->
      </div>
    </div>

    <div class="navbar-container container-fluid">
      <!-- Navbar Collapse -->
      <div class="collapse navbar-collapse navbar-collapse-toolbar" id="site-navbar-collapse">
        <!-- Navbar Toolbar -->
        <ul class="nav navbar-toolbar">
          <li class="hidden-float" id="toggleMenubar">
            <a data-toggle="menubar" href="#" role="button">
              <i class="icon hamburger hamburger-arrow-left">
                  <span class="sr-only">Toggle menubar</span>
                  <span class="hamburger-bar"></span>
                </i>
            </a>
          </li>
          <li class="hidden-xs" id="toggleFullscreen">
            <a class="icon icon-fullscreen" data-toggle="fullscreen" href="#" role="button">
              <span class="sr-only">Toggle fullscreen</span>
            </a>
          </li>
          
          
        </ul>
        <!-- End Navbar Toolbar -->

        <!-- Navbar Toolbar Right -->
        <ul class="nav navbar-toolbar navbar-right navbar-toolbar-right">
          
          <li class="dropdown">
          <?php 
				$sqln=mysql_query("SELECT * FROM ((SELECT tbl_users.date FROM tbl_users where admin_noti='')UNION ALL (SELECT tbl_ads.postdate FROM tbl_ads where admin_noti=''))results ORDER BY date ASC");
				$numn=mysql_num_rows($sqln);
				?>
            <a data-toggle="dropdown" href="javascript:void(0)" title="Notifications" class="Notifications" aria-expanded="false"
            data-animation="slide-bottom" role="button">
              <i class="icon wb-bell" aria-hidden="true"></i>
              
              <span class="badge badge-danger up"><?php if($numn>0) { echo $numn; }?></span>
            </a>
            <ul class="dropdown-menu dropdown-menu-right dropdown-menu-media" role="menu" style="overflow-y: scroll; height:400px;">
              <li class="dropdown-menu-header" role="presentation">
                <h5>NOTIFICATIONS</h5>
                
                
                <span class="label label-round label-danger">New <?php echo $numn;?></span>
              </li>
              
              
              <?php
			  
	
			  $sqlns=mysql_query("SELECT * FROM ((SELECT tbl_users.userid, NULL as ads_id, tbl_users.date, tbl_users.fullname, tbl_users.email, NULL AS posted_userid, NULL AS title, NULL AS maincategory FROM tbl_users where admin_click='')UNION ALL (SELECT NULL AS userid, tbl_ads.ads_id, tbl_ads.postdate, NULL AS fullname, NULL AS email, tbl_ads.posted_userid, tbl_ads.title, tbl_ads.maincategory FROM tbl_ads where admin_click=''))results ORDER BY date ASC ");
			  
			  while($resns=mysql_fetch_assoc($sqlns))
			  {
			  //echo'<pre>';print_r($resns['fullname']);
			      
				  ?>
				  		<li class="list-group" role="presentation">
                            <div data-role="container">
                              <div data-role="content">
				  <?php 
				  if($resns['fullname']!==NULL)
				  {
					  ?>
					  
                            <a href="users.php?id=<?php echo $resns['userid']?>" id="<?php echo $resns['userid']?>" class="list-group-item admin_click"  role="menuitem" title="user">
                              <div class="media">
                                <div class="media-left padding-right-10">
                                  <i class="icon wb-user bg-green-600 white icon-circle" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h6 class="media-heading">New User Registered</h6>
                                  <h6><b><?php echo ucwords($resns['fullname']);?></b></h6>
                                  <h6><b><?php echo $resns['email'];?></b></h6>
                                  <time class="media-meta" datetime="2015-06-11T18:29:20+08:00"><?php echo $resns['date']?></time>
                                </div>
                              </div>
                            </a>
                             
					  <?php 
				  }
				  if($resns['title']!==NULL)
				  {
					   ?>
					  	<a class="list-group-item admin_click" href="ads.php?id=<?php echo $resns['ads_id']?>" id="<?php echo $resns['userid']?>" role="menuitem" title="ad">
                              <div class="media">
                                <div class="media-left padding-right-10">
                                  <i class="icon wb-user bg-green-600 white icon-circle" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h6 class="media-heading">New Ad Listed</h6>
                                  <h6><b><?php echo ucwords($resns['title']);?></b>
                                  
                                  <?php $sqlmain=mysql_query("select * from tbl_maincategory where mcid='".$resns['maincategory']."'");
								  $resm=mysql_fetch_assoc($sqlmain);
								  
								  ?>In Main Category<b>
                                  <?php
								  echo $resm['name'];
								  ?></b></h6>
                                   <h6><?php $sqlu=mysql_query("select * from tbl_users where userid='".$resns['posted_userid']."'");
								  $resu=mysql_fetch_assoc($sqlu);
								  
								  ?>
								  By<b>
								  <?php
								  echo $resu['fullname'];
								  ?></b></h6>
                                  <time class="media-meta" datetime="2015-06-11T18:29:20+08:00"><?php echo $resns['date']?></time>
                                </div>
                              </div>
                            </a>
					  <?php 
				  }
				  
				  ?>
                   </div>
                            </div>
                        </li>
                        <?php
			  }
			  ?>
              
              <!--<li class="dropdown-menu-footer" role="presentation">
                <a class="dropdown-menu-footer-btn" href="javascript:void(0)" role="button">
                  <i class="icon wb-settings" aria-hidden="true"></i>
                </a>
                <a href="javascript:void(0)" role="menuitem">
                    All notifications
                  </a>
              </li>-->
            </ul>
          </li>
          
          <li class="dropdown">
            <a class="navbar-avatar dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false"
            data-animation="slide-bottom" role="button">
              <span class="avatar avatar-online">
                <img src="assets/portraits/<?php echo $resadmin['aimage']?>" alt="...">
                <i></i>
              </span>
            </a>
            <ul class="dropdown-menu" role="menu">

              <li role="presentation">
                <a href="profile.php" role="menuitem"><i class="icon wb-user" aria-hidden="true"></i> Profile</a>
              </li>
             <!-- <li role="presentation">
                <a href="javascript:void(0)" role="menuitem"><i class="icon wb-payment" aria-hidden="true"></i> Billing</a>
              </li>-->
              <li role="presentation">
                <a href="change_password.php" role="menuitem"><i class="icon wb-settings" aria-hidden="true"></i>Change Password</a>
              </li>
              <li class="divider" role="presentation"></li>
              <li role="presentation">
                <a href="logout.php" role="menuitem"><i class="icon wb-power" aria-hidden="true"></i> Logout</a>
              </li>
            </ul>
          </li>
        
          
          
        </ul>
        <!-- End Navbar Toolbar Right -->
      </div>
      <!-- End Navbar Collapse -->

      <!-- Site Navbar Seach -->
     <!-- <div class="collapse navbar-search-overlap" id="site-navbar-search">
        <form role="search">
          <div class="form-group">
            <div class="input-search">
              <i class="input-search-icon wb-search" aria-hidden="true"></i>
              <input type="text" class="form-control" name="site-search" placeholder="Search...">
              <button type="button" class="input-search-close icon wb-close" data-target="#site-navbar-search"
              data-toggle="collapse" aria-label="Close"></button>
            </div>
          </div>
        </form>
      </div>-->
      <!-- End Site Navbar Seach -->
    </div>
  </nav>
