<?
$sql_timer = "SELECT * FROM timer WHERE admin_id = '".$_SESSION['user_id']."' ";
$rs_timer = mysqli_query($conn,$sql_timer);
if(mysqli_num_rows($rs_timer) > 0){
	$_SESSION["timer_running"] = 1;
}

if(isset($_SESSION['job_user_id']) && $_SESSION['job_user_id'] !=""){
	$home_page = $siteURL."/index";
}else{
	$home_page = $siteURL."/index1";
}
?>
<style>
.navbar {
	background-color:#9c4893;
}
</style>
<!-- Navbar -->
<nav class="main-header navbar navbar-expand  navbar-light <? echo (isset($_REQUEST['hide_top']) &&  $_REQUEST['hide_top'] == 1) ? "hide" : "";?>">
<!-- Left navbar links -->
<ul class="navbar-nav">
  <li class="nav-item">
	<a class="nav-link text-white" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
  </li>
  <li class="nav-item d-none d-sm-inline-block">
	<a href="<?php echo $home_page; ?>" class="nav-link text-white">Home</a>
  </li>
</ul>

<!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- Navbar Search -->
      <!--<li class="nav-item">
        <a class="nav-link" data-widget="navbar-search" href="#" role="button">
          <i class="fas fa-search"></i>
        </a>
        <div class="navbar-search-block">
          <form class="form-inline">
            <div class="input-group input-group-sm">
              <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
              <div class="input-group-append">
                <button class="btn btn-navbar" type="submit">
                  <i class="fas fa-search"></i>
                </button>
                <button class="btn btn-navbar" type="button" data-widget="navbar-search">
                  <i class="fas fa-times"></i>
                </button>
              </div>
            </div>
          </form>
        </div>
      </li>-->

      <!-- Messages Dropdown Menu -->
      <!--------------- Start Appointment ---------------------------------------------->
      <li class="nav-item dropdown">
        <a href="#" class="nav-link" data-toggle="dropdown" title="Appointments">
          <i class="far fa-calendar text-white"></i>
          <span class="badge badge-warning navbar-badge"><? echo $gsi->getTotalActiveAppointment();?></span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
			<?
				$today_date = date("Y-m-d");
				$query = "SELECT * FROM appointment WHERE appointment_date >= '$today_date'  ORDER BY appointment_date ASC ";
				$sql=mysqli_query($conn,$query);
				$result=mysqli_num_rows($sql);
				if($result>0){
			?>
			<a href="#" class="dropdown-item">
				<!-- Message Start -->
				<div class="media">
				  <div class="media-body">
					<h3 class="dropdown-item-title">
					  Appointment(s)
					  <span class="float-right text-sm text-warning"><i class="far fa-calendar"></i></span>
					</h3>
					<? while($row =mysqli_fetch_array($sql)){?>
						<p class="text-sm"><?php echo utility::getFormatedDateReturn($row['appointment_date']);?></p>
						<p class="text-sm text-muted"><i class="far fa-calendar mr-1"></i> (<?php echo $gsi->getEnqQuoteJobById($row['job_id']); ?>)</p>
					
					<? } ?>
				  </div>
				</div>
				<!-- Message End -->
			</a>
			<?}else{ ?>
				<? echo "<span style='padding-left:10px;'>No Appointment...</span>"; ?>
			<? } ?>
          <div class="dropdown-divider"></div>
          <a href="<?php echo $siteURL ?>/appointment/index?page=view_appointment_for_admin" class="dropdown-item dropdown-footer">See All Appointments</a>
        </div>
      </li>
	  <!--------------- End Appointment ---------------------------------------------->
	  <!--------------- Start Reminder ---------------------------------------------->
	  <li class="nav-item dropdown">
        <a href="#" class="nav-link" data-toggle="dropdown" title="Reminders">
          <i class="far fa-bell text-white"></i>
          <span class="badge badge-warning navbar-badge"><? echo $gsi->getTotalActiveReminder();?></span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
			<?
				$today_date = date("Y-m-d");
				$query = "SELECT * FROM notes WHERE note_date >= '$today_date' AND note_type = 1 ORDER BY note_date ASC ";
				$sql=mysqli_query($conn,$query);
				$result=mysqli_num_rows($sql);
				if($result>0){
			?>
			<a href="#" class="dropdown-item">
				<!-- Message Start -->
				<div class="media">
				  <div class="media-body">
					<h3 class="dropdown-item-title">
					  Reminder(s)
					  <span class="float-right text-sm text-warning"><i class="far fa-bell"></i></span>
					</h3>
					<? while($row =mysqli_fetch_array($sql)){?>
						<p class="text-sm"><?php echo utility::getFormatedDateReturn($row['note_date']);?></p>
						<p class="text-sm text-muted"><i class="far fa-bell mr-1"></i> (<?php echo $gsi->getEnqQuoteJobById($row['job_id']); ?>)</p>
					
					<? } ?>
				  </div>
				</div>
				<!-- Message End -->
			</a>
			<?}else{ ?>
				<? echo "<span style='padding-left:10px;'>No Reminder...</span>"; ?>
			<? } ?>
          <div class="dropdown-divider"></div>
          <a href="<?php echo $siteURL ?>/notes/index?page=view_reminders_for_admin" class="dropdown-item dropdown-footer">See All Reminders</a>
        </div>
      </li>
	  <!--------------- End Reminder ---------------------------------------------->
	  
	  <?/* <li class="nav-item dropdown">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="far fa-comments"></i>
          <span class="badge badge-danger navbar-badge">3</span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
          <a href="#" class="dropdown-item">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user1-128x128.jpg" alt="User Avatar" class="img-size-50 mr-3 img-circle">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  Brad Diesel
                  <span class="float-right text-sm text-danger"><i class="fas fa-star"></i></span>
                </h3>
                <p class="text-sm">Call me whenever you can...</p>
                <p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  John Pierce
                  <span class="float-right text-sm text-muted"><i class="fas fa-star"></i></span>
                </h3>
                <p class="text-sm">I got your message bro</p>
                <p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user3-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  Nora Silvester
                  <span class="float-right text-sm text-warning"><i class="fas fa-star"></i></span>
                </h3>
                <p class="text-sm">The subject goes here</p>
                <p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item dropdown-footer">See All Messages</a>
        </div>
      </li>
      <!-- Notifications Dropdown Menu -->
      <li class="nav-item dropdown">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="far fa-bell"></i>
          <span class="badge badge-warning navbar-badge">15</span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
          <span class="dropdown-item dropdown-header">15 Notifications</span>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <i class="fas fa-envelope mr-2"></i> 4 new messages
            <span class="float-right text-muted text-sm">3 mins</span>
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <i class="fas fa-users mr-2"></i> 8 friend requests
            <span class="float-right text-muted text-sm">12 hours</span>
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <i class="fas fa-file mr-2"></i> 3 new reports
            <span class="float-right text-muted text-sm">2 days</span>
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item dropdown-footer">See All Notifications</a>
        </div>
      </li> */?>
      <li class="nav-item">
        <a class="nav-link" data-widget="fullscreen" href="#" role="button">
          <i class="fas fa-expand-arrows-alt text-white"></i>
        </a>
      </li>
      <!--<li class="nav-item">
        <a class="nav-link" data-widget="control-sidebar" data-controlsidebar-slide="true" href="#" role="button">
          <i class="fas fa-th-large"></i>
        </a>
      </li>-->
    </ul>
</nav>
<!-- /.navbar -->
  
<script type="text/javascript">
$(document).ready(function() {
	//////////////////////// Compare div scrolling ////////////////////////////
	$(window).ready(function() {
		scrollHeight = 100;
	});

	$(window).scroll(function() {
		if ($(document).scrollTop() >= scrollHeight) {
			$('#main_header').css({
				'position': 'fixed',
				'top':'0px',
				'z-index':'1040',
				'width':'100%',
				'background':'#eee',
				'border-top':'3px solid #ff7a59'
			});
		} else {
			$('#main_header').css({
				'position': 'relative',
				'z-index':'1030'
			});
		}
	});
////////////////////////////////////////////////////////////////////////
	
	$(".sidebar-toggle").click(function(){
		var collapse_left = $(this).attr("alt");
		$.ajax({
			async: false,
			type: "POST",
			url: site_url+"/ajax.php?action=collapse_left&collapse_left="+collapse_left,
			success: function(result){
				
			}
		});
		
	});
	
	$("#show_only_my_things").on("ifChecked",function(){
		$.ajax({
			async: false,
			type: "POST",
			url: site_url+"/ajax.php?action=show_only_my_things&checked=1",
			success: function(result){
				location.reload();
			}
		});
	});
	$("#show_only_my_things").on("ifUnchecked",function(){
		$.ajax({
			async: false,
			type: "POST",
			url: site_url+"/ajax.php?action=show_only_my_things&checked=0",
			success: function(result){
				location.reload();
			}
		});
	});
});     
</script>