<?php
    defined('BASEPATH') OR exit('No direct script access allowed');
    
    class HomeController extends CI_Controller 
    {
        public function __construct() 
        {
            parent::__construct();
            
           /* if ($this->session->userdata('userName') == '' && $this->session->userdata('password') == '') 
            {
                redirect('login/LoginController', 'refresh');
            }*/
			$this->load->library('session');
			$this->load->helper('url');
			$this->load->database();

			$this->load->model('home/HomeModel');
			$this->load->model('cart/CartModel');
			$this->load->model('teamWork/TeamWorkModel');
			$this->load->model('company/CompanyModel');
			$this->load->model('menu/MenuModel');
			$this->load->model('subMenu/SubMenuModel');
			$this->load->model('slider/SliderModel');
			$this->load->model('aboutCompany/AboutCompanyModel');
			$this->load->model('certificateLogo/CertificateLogoModel');
			$this->load->model('whyUsMaster/WhyUsMasterModel');
			$this->load->model('testimonial/TestimonialModel');
			$this->load->model('products/ProductsModel');
			//$this->load->model('productMaster/ProductMasterModel');
        }
        
    	public function index()
    	{
    	    //print_r($this->session->all_userdata());exit;
			$companyResult			= $this->CompanyModel->getCompanyDetails();
			$teamWorkResult         = $this->TeamWorkModel->getTeamWorkDetails();
			$homeResult             = $this->HomeModel->getHomeDetails();
			$topMenuResult          = $this->MenuModel->getTopMenuDetails();
			$bottomMenuResult       = $this->MenuModel->getBottomMenuDetails();
			$subMenuResult          = $this->SubMenuModel->getSubMenuDetails();
			$sliderResult           = $this->SliderModel->getSliderDetails();
			$aboutCompanyResult     = $this->AboutCompanyModel->getAboutCompanyDetails();
			$certificateLogoResult  = $this->CertificateLogoModel->getCertificateLogoDetails();
			$whyUsMasterResult      = $this->WhyUsMasterModel->getWhyUsMasterDetails();
			$testimonialResult      = $this->TestimonialModel->getTestimonialDetails();
			$productsResult         = $this->ProductsModel->getProductsDetails();
			//$cartCount = $this->CartModel->getCartCount('1');
			
			/*if ($this->session->userdata('mailID') != '' && $this->session->userdata('customerID') != '') 
            {
				$customerID 		= $this->session->userdata('customerID');
				$cartCount			= $this->CartModel->getCartCount($customerID);
				$cartResult         = $this->CartModel->getCartDetails($customerID);
			}
			else
			{
				$cartCount	= 0;
				$cartResult = array();
			}*/
			
			if ($this->session->userdata('sessionID') != '') 
            {
				$customerID 		= $this->session->userdata('customerID');
				$sessionID 		= $this->session->userdata('sessionID');
				$cartCount			= $this->CartModel->getCartCount($sessionID);
				$cartResult = $this->CartModel->getCartDetails($sessionID);
			}
			else
			{
				$cartCount	= 0;
				$cartResult = array();
			}
			
			//$productMasterResult             = $this->ProductMasterModel->getProductMasterDetails();
			
			$this->load->view('home/Home',['productsResult'=>$productsResult,
											'teamWorkResult' => $teamWorkResult,
											'companyResult' => $companyResult,
											'homeResult' => $homeResult,
											'topMenuResult'=>$topMenuResult, 
											'bottomMenuResult'=>$bottomMenuResult, 
											'subMenuResult'=>$subMenuResult, 
											'sliderData'=>$sliderResult, 
											'aboutCompanyResult'=>$aboutCompanyResult,
											'certificateLogoResult'=>$certificateLogoResult, 
											'whyUsMasterResult'=>$whyUsMasterResult, 
											'testimonialResult'=>$testimonialResult, 
											'cartCount'=>$cartCount, 
											'cartResult'=>$cartResult]);
			//'productMasterResult'=>$productMasterResult, 
    	}
    }
    
?>
