<?php

 $lang = $this->Session->read('Config.language');
if(isset($_COOKIE['blog_lang']) && $_COOKIE['blog_lang'] != $lang) {
    setcookie('blog_lang', $lang, time()+3600*24);
} else if(!isset($_COOKIE['blog_lang']) && empty($_COOKIE['blog_lang'])) {
    setcookie('blog_lang', $lang, time()+3600*24);
}
?>
<!doctype html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
    
<meta name="viewport" content="width=device-width, initial-scale=1">

<?php if(IS_GOOGLE_ANALYTIC == 1){ ?>
<title>
        ExpenseCount - <?php echo __("LBL_WEBSITE_TITLE"); ?>
    </title>
    <meta name="description" content="<?php echo __('LBL_SITE_META_DESCRIPTION'); ?>" />
    <meta name="keywords" content="<?php echo __('LBL_SITE_META_KEYWORD'); ?>" />
<?php } ?>
    <link rel="shortcut icon" type="image/x-icon" href="<?php echo CDN_URL; ?>images/favicon.ico">
<link href="<?php echo CDN_URL; ?>css/bootstrap.css" rel="stylesheet" type="text/css">
<script src="<?php echo CDN_URL; ?>js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="<?php echo CDN_URL; ?>js/popper.min.js" type="text/javascript"></script>
<script src="<?php echo CDN_URL; ?>js/bootstrap.min.js" type="text/javascript"></script>
    <!--<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>-->
<script  src="<?php echo CDN_URL; ?>js/nav.js" type="text/javascript"></script>
<script src="<?php echo CDN_URL; ?>owlcarousel/owl.carousel.js" type="text/javascript"></script>
<!--    <script id="custom-reports-table" type="text/x-handlebars-template">-->
<link href="<?php echo CDN_URL; ?>css/style.css" rel="stylesheet" type="text/css">
<link href="<?php echo CDN_URL; ?>css/nav.css" rel="stylesheet" type="text/css">
<link href="<?php echo CDN_URL; ?>owlcarousel/assets/owl.carousel.min.css" rel="stylesheet" type="text/css">
<style type="text/css">
  .loginBtn{
    position: absolute;
    text-decoration: underline;
  }
  @media screen and (max-width: 360px){
    .loginBtn{
      top: 50px;
      right: 10px;
    }
  }
  @media screen and (min-width: 361px){
    .loginBtn{
      top: -18px;
      right: 10px;
    }
  }
  @media screen and (min-width: 576px){
    .loginBtn{
      top: -18px;
      right: 2px;
    }
  }
  @media screen and (min-width: 768px){
    .loginBtn{
      top: -18px;
      right: 2px;
    }
  }
  @media screen and (min-width: 992px){
    .loginBtn{
      top: -18px;
      right: 2px;
    }
  }
  @media screen and (min-width: 1260px){
    .loginBtn{
      top: 15px;
      right: -50px;
    }
  }
  @media screen and (min-width: 1300px){
    .loginBtn{
      top: 15px;
      right: -70px;
    }
  }
</style>
</head>

<body>
<!---->
<div class="header">
  <div class="container">
    <div class="row">
      <div class="col-sm-3 logo"><a href="<?php echo HTTP_SITE_URL;?>"><img src="<?php echo CDN_URL; ?><?php echo __("LBL_MAIN_LOGO");?>" alt=""/></a>
      </div>

      <div class="col-sm-9 no-padding">
      <?php $session_user_id = ($this->Session->read('userData.id')) ? $this->Session->read('userData.id') : '' ;
          if ($session_user_id != ''): ?>
            <a class="loginBtn d-none d-sm-none d-md-block" href="<?php echo HTTP_SITE_URL.'/users/logout';?>"><b><?php echo __("LBL_LOGOUT");?></b></a>
          <?php else: ?>
            <!-- Hide Login for now -->
            <a class="loginBtn d-none d-sm-none d-md-block" href="<?php echo HTTP_SITE_URL.'/users/login';?>"><b><?php echo __("LBL_LOGIN");?></b></a>
          <?php endif; ?>
        <div id="cssmenu">
          <div> </div>
          <div class="drop-nav">
            <select id="languageList">
            
                   <option value="eng" <?php echo ($current_lang == 'eng') ? 'selected="selected"':''; ?>>English  (EN)</option>
                   <option value="spa" <?php echo ($current_lang == 'spa') ? 'selected="selected"':''; ?>>Español (ES)</option>
                   <option value="ccn" <?php echo ($current_lang == 'ccn') ? 'selected="selected"':''; ?>>简体中文 (CN)</option>
                   <option value="czh" <?php echo ($current_lang == 'czh') ? 'selected="selected"':''; ?>>中国传统的 (ZH)</option>
                   <option value="ben" <?php echo ($current_lang == 'ben') ? 'selected="selected"':''; ?>>বাংলা (BN)</option>

                  <!-- 
                    <option value="fr" <?php echo ($current_lang == 'fr') ? 'selected="selected"':''; ?>>Français (FR)</option>
                    <option value="pl" <?php echo ($current_lang == 'pl') ? 'selected="selected"':''; ?>>Polski (PL)</option>
                    <option value="it" <?php echo ($current_lang == 'it') ? 'selected="selected"':''; ?>>Italiano (IT)</option
                    <option value="de" <?php echo ($current_lang == 'de') ? 'selected="selected"':''; ?>>Deutsch (DE)</option>
                    <option value="nl" <?php echo ($current_lang == 'nl') ? 'selected="selected"':''; ?>>Nederlands (NL)</option>
                    <option value="pt" <?php echo ($current_lang == 'pt') ? 'selected="selected"':''; ?>>Português (PT)</option>
                    <option value="hin" <?php echo ($current_lang == 'hin') ? 'selected="selected"':''; ?>>हिन्दी (HI)</option>
                    <option value="tr" <?php echo ($current_lang == 'tr') ? 'selected="selected"':''; ?>>Türkçe (TR)</option> -->
            </select>
          </div>
          <div id="head-mobile"></div>
          <div class="button"></div>
          <ul>
            <li ><a href="<?php echo HTTP_SITE_URL; ?>/"><?php echo __("LBL_HOME");?></a></li>
            <li <?php if($this->params['action'] == "mobileApps"){ ?> class="active" <?php }?>><a href='<?php echo HTTP_SITE_URL; ?>'><?php echo __("LBL_MOBILE_APPS");?></a>
              <ul>
                <li><a href='<?php echo HTTP_SITE_URL;?>/pages/mobileApps/1'><?php echo __("LBL_GROUP_EXPENSE");?></a></li>
                <li><a href='<?php echo HTTP_SITE_URL;?>/pages/mobileApps/2'><?php echo __("LBL_MESS_EXPENSE");?></a></li>
                <li><a href='<?php echo HTTP_SITE_URL;?>/pages/mobileApps/3'><?php echo __("LBL_FAMILY_EXPENSE");?></a></li>
              </ul>
            </li>
            <!--<?php if($this->params['controller'] != "Home" || $this->params['action'] != "index"){ ?>
                <li <?php if($this->params['action'] == "facebookApp"){ ?> class="active" <?php }?>>
                    <a href="<?php echo $this->Html->url(array('controller'=>'pages','action'=>'facebookApp'));?>"><?php echo __("LBL_FACEBOOK_APPS");?></a>
                </li>
            <?php } ?>-->

           <!-- <li <?php if($this->params['action'] == "aboutus"){ ?> class="active" <?php }?>>
                <a href="<?php echo $this->Html->url(array('controller'=>'pages','action'=>'aboutus'));?>"><?php echo __("LBL_ABOUT_US");?></a>
            </li>-->
          <li <?php if($this->params['action'] == "faq"){ ?> class="active" <?php }?>>
          <a href="<?php echo HTTP_SITE_URL;?>/pages/faq"><?php echo __("LBL_FAQ");?></a>
              </li>
          <li <?php if($this->params['action'] == "feedback"){ ?> class="active" <?php }?>>
          <a href="<?php echo HTTP_SITE_URL;?>/pages/feedback"><?php echo __("LBL_FEEDBACK");?></a>
          </li>
            <li <?php if($this->params['action'] == "termscondition"){ ?> class="active" <?php }?>>
                <a href="<?php echo HTTP_SITE_URL;?>/pages/myExpenses"><?php echo __("LBL_MY_EXPENSES");?></a>
            </li>
             <li <?php if($this->params['action'] == "logout" || $this->params['action'] == "login"){ ?> class="active d-sm-block d-md-none" <?php }else{ ?> class="d-sm-block d-md-none" <?php } ?>>
            <?php $session_user_id = ($this->Session->read('userData.id')) ? $this->Session->read('userData.id') : '' ;
          if ($session_user_id != ''): ?>
            <a class="text-primary" href="<?php echo HTTP_SITE_URL.'/users/logout';?>"><b><u> <?php echo __("LBL_LOGOUT");?></u></b></a>
          <?php else: ?>
            <!-- Hide Login for now -->
            <a class="text-primary"  href="<?php echo HTTP_SITE_URL.'/users/login';?>"><b><u><?php echo __("LBL_LOGIN");?></u></b></a>
          <?php endif; ?>
            </li>        
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- main body -->
<?php if ($this->request->here != $this->base.'/' && $this->request->here != $this->base.'/pages/myExpenses'): ?>
    <div class="block-2">
      <div class="container">
        <?php echo $this->Session->flash(); ?>
        <?php echo $this->fetch('content'); ?>
      </div>
    </div>
<?php else: ?>
    <?php echo $this->Session->flash(); ?>
    <?php echo $this->fetch('content'); ?>
<?php endif; ?>
<!-- end of main body -->

<?php echo $this->element('footer'); ?>

<?php 
        echo $this->Form->create("Home", array('id'=> 'languageSelectionForm','url' => array('controller' => 'Home', 'action' => 'changeLanguage')));
    
        echo $this->Form->input('global_selected_language', array('type' => 'hidden','id'=>'global_selected_language'));
        echo $this->Form->input('global_current_url', array('type' => 'hidden','id'=>'global_current_url'));
        
        echo $this->Form->end();    
    ?>
    
    <script>

    function changeLanguage(language){
 
        document.getElementById("global_selected_language").value = language;
         
        document.getElementById("global_current_url").value = "<?php echo $this->Html->url();?>";
         
        document.forms["languageSelectionForm"].submit();
         
     }

     $(document).on('change','#languageList',function(){
        var lang = $(this).val();
        changeLanguage(lang);


     });
    $(document).ready(function(){
        $('[data-toggle="tooltip"]').tooltip();
    });

    </script>
 
<?php if(IS_GOOGLE_ANALYTIC == 1){ ?>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-19803228-4', 'auto');
  ga('send', 'pageview');

</script>
<?php } ?>

</body>
</html>