  <?php
 
$title=$_SERVER['REQUEST_URI'];
$title=explode('/',$title);
$title=$title[1];
if(!empty($title))
{
$condi=array('title'=>$title);
$page_condi=array('page_url'=>$title);
$pages=get_data('cms_menu',$page_condi,"=");
foreach($pages as $menu){
$page_name=$menu['page_name'];
$page_title=$menu['page_title'];
$page_keyword=$menu['page_keyword'];
$page_url=$menu['page_url'];
$page_description=$menu['page_description'];
$meta_description=$menu['message'];
$up_image=$menu['up_image'];
$himage=$menu['himage'];
$middle=$menu['fvicon'];
}
}elseif($_GET['alias']){
$alias=$_GET['alias'];
$condi=array('ct_pd_url'=>$alias,'status'=>1);
$categories=get_data('cat_prod',$condi,"=");
foreach($categories as $cat){
$meta_description=$cat['ct_pd_mt_ds'];
$page_title=$cat['ct_pd_title'];
$page_url=$cat['ct_pd_url'];
}
}else{
//$condi=array('title'=>'home');
$page_condi=array('page_url'=>'home');
$pages=get_data('cms_menu',$page_condi,"=");
foreach($pages as $menu){
$page_name=$menu['page_name'];
$page_title=$menu['page_title'];
$page_keyword=$menu['page_keyword'];
$page_url=$menu['page_url'];
$page_description=$menu['page_description'];
$meta_description=$menu['message'];
$up_image=$menu['up_image'];
$himage=$menu['himage'];
$middle=$menu['fvicon'];
}
}
$footers=get_data('users');
foreach($footers as $footer){
$mobile=$footer['mobile'];
$email=$footer['email'];
$company_name=$footer['company_name'];
$address=$footer['address'];
 
$facebook_link=$footer['facebook_link'];
$twittter_link=$footer['twittter_link'];
$linkedin_link=$footer['linkedin_link']; 
$instagram_link=$footer['instagram_link'];
$gstin=$footer['gstin'];
$youtube_link=$footer['youtube_link'];
$head_office=$footer['head_office'];
$whatsapp_number=$footer['whatsapp_number'];
$copyright=$footer['copyright'];
$google_map=$footer['google_map'];
}
if(!empty($_SESSION['authuserid']) && isset($_SESSION['authuserid']))
{
$authemailid= $_SESSION['authuserid'];
$data=array('email'=>$authemailid);
$authuser=get_data('tbl_user',$data,"=");
foreach($authuser as $auser)
{
$authid=$auser['id'];    
$auth_email=$auser['email'];    
$name=$auser['name'];       
$address=$auser['address'];    
$mobile=$auser['mobile'];    
$city=$auser['city'];   
$state=$auser['state'];    
$country=$auser['country'];    
$pincode=$auser['pincode'];    

}
}
$noimage=admin_base_url().'uploads/no-image.jpg';
?>
  <nav class="navbar navbar-expand-lg navbar-light sticky-top bg-white pt-3  shadow-sm" id="TopNav">
    <div class="container">
      <a class="navbar-brand" href="<?=base_url()?>">
         <?php

$logos=get_data('logo');
foreach($logos as $logo){

}
if(!empty($logo['logo_image']))
{
?>
        <img src="<?php echo admin_base_url().'uploads/logo/'. $logo['logo_image'];?>" alt="" width="100%">
         <?php    
}else{

echo $logo['logo_title'];

}

?>
      </a>
      <button class="navbar-toggler " type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03"
        aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarTogglerDemo03">
        <ul class=" me-auto  mb-lg-0">
        </ul>
        <ul class="navbar-nav me-auto  mb-lg-0 ">
        


<?php 
$menus=get_data('cms_menu');
$i=1;
foreach($menus as $menu){
if($i==1){
$active="active";
}else{
$active="";
}
if($menu['page_type']=='category'){ 
?>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
              <?php echo $menu["page_name"]; ?>
            </a>
    
            <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
              <ul class="cs-dropdown">
         <?php 
$condi=array('category_id'=>$menu['id']);
$produts_menu=get_data('cat_prod',$condi,"=");
foreach($produts_menu as $prodcut_menu){
?>
              <li><a class="dropdown-item" href="<?=base_url().$prodcut_menu['ct_pd_url']?>"><?php echo $prodcut_menu['ct_pd_name']; ?></a></li>
  <?php 

}
?>
            </ul>
            </ul>
                        
          </li>

<?php }else{
if($menu["page_url"] == 'home'){

$menuurl="";
}else{

$menuurl=$menu["page_url"].'/';
}
echo '<li class="nav-item"><a class="nav-link" aria-current="page" href="'.base_url().$menuurl.'">'.$menu["page_name"].'</a></li>';
}
$i++;

}
?>
    
          <li class="nav-item">
            <a class="nav-link" aria-current="page" href="<?=$facebook_link?>" target="_blank" ><i class="fa-brands fa-facebook"></i></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" aria-current="page" href="<?=$instagram_link?>" target="_blank" ><i class="fa-brands fa-instagram"></i></a>
          </li>
           
        </ul>
        
       
       
      </div>
    </div>
  </nav>