<?php
namespace App\Controllers;
SESSION_START();
use \Core\View;
use \Core\Menu;
use \Core\Form;
use \Core\Inputs;
use App\Models\Homem;
class Hindu extends \Core\Controller
{
    private static function styles()
    {
        $a = '
                <head>
                    <meta charset="UTF-8" />
                    <meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover" />
                    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
                    <title>Hindu College & High Schools` Council :: Guntur</title>
                    <link rel="icon" href = "/mainsite/img/logo.png" type = "image/x-icon"> 
                    <link rel="stylesheet" href="/mainsite/bootstrap-4.3.1-dist/css/bootstrap.min.css" />
                    <link rel="stylesheet" href="/mainsite/css/font-awesome.min.css" />
                    <link rel="stylesheet" href="/mainsite/css/animate.css" />
                    <link rel="stylesheet" href="/mainsite/css/lightbox.css" />
                    <link rel="stylesheet" href="/mainsite/css/owl.carousel.css" />
                    <link rel="stylesheet" href="/mainsite/css/owl.theme.default.css" />
                    <link rel="stylesheet" href="/mainsite/css/arrow.css" />
                    <link rel="stylesheet" href="/mainsite/css/fixed.css" />
                    <link rel="stylesheet" href="/mainsite/css/waypoints.css" />
                    <link rel="stylesheet" href="/mainsite/css/style.css" />
                    <style>
                    @font-face {
                      font-family: headfont;
                      src: url(/mainsite/css/newfonts/glitch-esports-demo.italic.woff);
                    }         
                    .newhead {
                      font-family: headfont;
                    }
                    @font-face {
                      font-family: bodytitle;
                      src: url(/mainsite/css/newfonts/Poppins-Medium.woff);
                    }         
                    .bodytitle {
                      font-family: bodytitle;
                    }
                    @font-face {
                      font-family: bodyfont;
                      src: url(/mainsite/css/newfonts/Poppins-Light.woff);
                    }         
                    .bodyfont {
                      font-family: bodyfont;
                    }
                    body {
                      font-family: bodyfont;
                    }
                    .navbar-toggler{
                      width: 47px;
                      height: 34px;
                      <!--background-color: #023e73;-->
                      }
                      .topmargin
                      {
                        margin-top: 20px;
                      }
                     @media (max-width: 991px) {
                      .topmargin
                      {
                        margin-top: 0px;
                      }
                     }
                     .margintop
                      {
                        /* margin-top: 20px; */
                      }
                     @media (max-width: 991px) {
                      .margintop
                      {
                        margin-top: 35px;
                      }
                     }
                     .mobilejust
                     {
                        text-align: justify;
                     }
                     .deskonly
                     {
                        display: block;
                     }
                     .mobileonly
                     {
                        display: none;
                     }
                     @media (max-width: 991px) {
                    .mobilejust
                     {
                        text-align: left;
                     }
                     .mobileonly
                     {
                        display: block;
                     }
                     .deskonly
                     {
                        display: none;
                     }
                     }
                     .missionborder
                     {
                      border: 0.5px #E8E8E8 solid; 
                      border-radius: 10px;
                     }
                     .missionborder:hover
                     {
                      border: 0.5px #98c17d solid; 
                      border-radius: 10px;
                     }
                    </style>
                </head>
            ';
            return  $a;
    }
    private static function scripts()
    {
        $a = '
            <div id="" ><!--class="offset"-->
              <footer style="background-color: none !important;">
                <div class="row" style="background-color: #E8E8E8; color:#023e73;">
                  <div class="col-md-12">
                      <img src="/mainsite/img/logo.png" alt="" />
                  </div>
                  <div class="col-md-4">
                    <h6><strong>ADDRESS</strong></h6>
                    <p>
                      Guntur, <br />
                      Andhra Pradesh, India
                    </p>
                  </div>
                  <div class="col-md-4">
                    <h6><strong>CONTACT INFO</strong></h6>
                    <p style="color: #023e73;">(+91) xxx<br /><a style="color: #023e73;" href="mailto:info@hindu.in">info@hindu.in</a></p>
                    <!-- <a href="#"><i class="fab fa-facebook-square"></i></a>-->
                    <!-- <a href="#"><i class="fab fa-twitter-square"></i></a>-->
                    <a href="#"><i class="fab fa-instagram"></i></a>
                    <!-- <a href="#"><i class="fab fa-reddit-square"></i></a>-->
                    <a href="#"><i class="fab fa-linkedin" ></i></a>
                  </div>
                  <div class="col-md-4">
                  <h6><strong>LOCATION</strong></h6>
                  <div class="mapouter"><div class="gmap_canvas"><iframe src="https://maps.google.com/maps?width=100%25&amp;height=600&amp;hl=en&amp;q=hindu%20college,%20guntur+(hindu%20college%20guntur)&amp;t=&amp;z=14&amp;ie=UTF8&amp;iwloc=B&amp;output=embed"width="auto" height="150" id="gmap_canvas" src="" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><style>.mapouter{position:relative;text-align:right;height:200px;width:200px;}</style><style>.gmap_canvas {overflow:hidden;background:none!important;height:200px;width:300px;}</style></div></div>
                  </div>
                  <hr class="socket" />
                    Hindu College & High Schools` Council &copy; 2020 all rights reserved.
                </div>
              </footer>
            </div>
            <a href="#home" class="top-scroll">
              <i class="fas fa-angle-up"></i>
            </a>
            <script src="/mainsite/js/jquery-3.3.1.min.js"></script>
            <script src="/mainsite/bootstrap-4.3.1-dist/js/bootstrap.min.js"></script>
            <script src="https://use.fontawesome.com/releases/v5.10.2/js/all.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
            <script src="/mainsite/js/custom.js"></script>
            <script src="/mainsite/js/jquery.waypoints.min.js"></script>
            <script src="/mainsite/js/waypoints.js"></script>
            <script src="/mainsite/js/lightbox.js"></script>
            <script src="/mainsite/js/owl.carousel.js"></script>
            <script src="/mainsite/js/jquery.counterup.js"></script>
            <script src="/mainsite/js/validator.js"></script>
            <script src="/mainsite/js/contact.js"></script>
            <script>$(".navbar, .dropdown-menu").addClass("solid");</script>
        ';
        return $a;
    }
    private static function script()
    {
        $a = '
        <div id="" ><!--class="offset"-->
          <footer style="background-color: none !important;">
            <div class="row" style="background-color: #E8E8E8; color:#023e73;">
              <div class="col-md-12">
                  
              </div>
              <div class="col-md-4">
              <img src="/mainsite/img/logo.png" alt="" style="display: block;   margin-top: 40px; margin-left: auto; margin-right: auto;"/>
                
              </div>
              <div class="col-md-3">
              <h6 style="font-size:12px; margin-top: 20px;" ><strong>ADDRESS</strong></h6>
                <p style="font-size:12px;">
                 Guntur,<br />
                  Andhra Pradesh, India
                </p>
              </div>
              <div class="col-md-3">
              <h6 style="font-size:12px; margin-top: 20px;" ><strong>CONTACT INFO</strong></h6>
              <p style="font-size:12px;" style="color: #023e73;">(+91) <br />
              <a style="color: #023e73;" href="mailto:info@hindu.in">info@hcet.in</a></p>
              </div>
              <div class="col-md-2">
              <a href="#"><i class="fab fa-instagram"></i></a>
              <a href="#"><i class="fab fa-linkedin" ></i></a>
              
              </div>
              <hr class="socket" />
                Hindu College & High Schools` Council &copy; 2020 all rights reserved.
            </div>
          </footer>
        </div>
        <a href="#home" class="top-scroll">
          <i class="fas fa-angle-up"></i>
        </a>
        <script src="/mainsite/js/jquery-3.3.1.min.js"></script>
        <script src="/mainsite/bootstrap-4.3.1-dist/js/bootstrap.min.js"></script>
        <script src="https://use.fontawesome.com/releases/v5.10.2/js/all.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
        <script src="/mainsite/js/custom.js"></script>
        <script src="/mainsite/js/jquery.waypoints.min.js"></script>
        <script src="/mainsite/js/waypoints.js"></script>
        <script src="/mainsite/js/lightbox.js"></script>
        <script src="/mainsite/js/owl.carousel.js"></script>
        <script src="/mainsite/js/jquery.counterup.js"></script>
        <script src="/mainsite/js/validator.js"></script>
        <script src="/mainsite/js/contact.js"></script>
        <script>$(".navbar, .dropdown-menu").addClass("solid");</script>
      ';
      return $a;
    }
    private static function webmenu()
    {
        $a = '
        <nav class="navbar navbar-expand-lg fixed-top">
          <div class="container-fluid">
            <a class="navbar-brand" href="/hindu/index"><img src="/mainsite/img/logo.png" alt=""/></a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive">
              <span class="custom-toggler-icon"><i class="fas fa-bars"  style="color: #023e73;"></i></span>
            </button>
  
            <div class="collapse navbar-collapse" id="navbarResponsive">
              <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/index">Home</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/aboutus">About Us</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/list">Members</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/organizations">Our Organizations</a>
                </li>
                <!--
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" id="dropdown1" aria-haspopup="true" aria-expanded="false">About Us</a>
                  <ul class="first dropdown-menu" aria-labelledby="dropdown1">
                    <li><a class="dropdown-item" href="/hindu/aboutus">Organization Profile</a></li>
                    <li><a class="dropdown-item" href="/hindu/vision">Mission & Vision</a></li>
                    <li><a class="dropdown-item" href="/hindu/team">Our Team</a></li>
                  </ul>
                </li>
                -->

                <!--
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/index">Our Clients</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/career">Careers</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/blog">Sports Blog</a>
                </li>
                <li class="nav-item">
                <a class="nav-link" href="/hindu/login">Login</a>
                </li>
                -->
                <li class="nav-item">
                  <a class="nav-link" href="/hindu/contactus">Contact Us</a>
                </li>

              </ul>
            </div>
          </div>
        </nav>
        ';
        return $a;
    }
    public static function index()
    {
        View::render("HinduCouncil/index.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::scripts()]);
    }
    public static function aboutus()
    {
        View::render("HinduCouncil/aboutus.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::script()]);
    }
    public static function list()
    {
        $country = Homem::getdata("SELECT * FROM members m JOIN member_desg md ON m.id=md.fk_member_id");
        View::render("HinduCouncil/members.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::script(), 'data'=>$country]);
    }
    public static function organizations()
    {
        $country = Homem::getdata("SELECT * FROM `org_details` WHERE `fk_orgtype_id`='2'");
        View::render("HinduCouncil/organizations.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::script(), 'data'=>$country]);
    }
    public static function contactus()
    {
      $country = Inputs::select('country', Inputs::optionsdb(Homem::getdata("SELECT * FROM `add_country`"), 'country_id', 'country_name'), Inputs::options([''], ['Select Country']), 'onchange="get_addstates(this)"', 'required');
      $state = Homem::getdata("SELECT * FROM `add_state`");
      $city = Homem::getdata("SELECT * FROM `add_city`");
      View::render("HinduCouncil/contactus.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::scripts(), 'country'=>$country, 'state'=>$state, 'city'=>$city]);
    }
    public static function savecontactus()
    {
      if(isset($_POST['email']) && isset($_POST['mobile']))
      {
        date_default_timezone_set('Asia/Kolkata'); 
        $date =  date('Y-m-d'); 
        Homem::insert("INSERT INTO `contactus` (`name`, `email`, `mobile`, `fk_country_id`, `fk_state_id`, `fk_city_id`, `subject`, `message`, `regdate`, `checked_by`, `check_date`, `status`) VALUES 
        ('$_POST[name]', '$_POST[email]', '$_POST[mobile]', '$_POST[country]', '$_POST[state]', '$_POST[city]', '$_POST[subject]', '$_POST[message]', '$date', '', '', '1')");
        echo '<script>window.location="/";</script>';
      }
    }
    public static function login()
    {
        View::render("HinduCouncil/login.php", ['style'=>static::styles(), 'menu'=>static::webmenu(), 'script'=>static::script()]);
    }
    public static function auth()
    {
      if(isset($_POST['name']))
      {
        $data = Homem::getdata("SELECT * FROM `user_details` WHERE `email`='$_POST[name]' AND `password`='$_POST[password]' AND `status`='1'");
        if(sizeof($data) == 1)
        {
          $_SESSION['name'] = $data[0]['name'];
          $_SESSION['email'] = $_POST['name'];
          $_SESSION['user_id'] = $data[0]['user_id'];
          echo '<script>window.location="/user/home";</script>';
        }
        else
        {
          echo '<script>window.location="/";</script>';
        }
      }
    }
    public static function logout()
    {
      unset($_SESSION['email']);
      unset($_SESSION['user_id']);
      SESSION_DESTROY();
      echo '<script>window.location="/";</script>';
    }
}