<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dashboard extends CI_Controller {

	// public function __construct()
    // {
    //     parent::__construct();

    //     $this->isLoggedIn();
    // }

    // public function isLoggedIn(){
    //     $is_logged_in = $this->session->userdata('logged_in');
    //     if(!isset($is_logged_in) || $is_logged_in!==TRUE)
    //     {
    //         redirect(base_url());
    //         exit;
    //     }
    // }
	public function header_and_footer($page, $data)
    {
        
        $this->load->view('includes/header',$data);
		$this->load->view('includes/sidebar',$data);
        $this->load->view($page);
        $this->load->view('includes/footer');
    }
	public function index()
    {
        $data['title'] = 'Dashboard';
		$data['total_staff'] = $this->model->countData('staff',[]);
		$data['total_offering_category'] = $this->model->countData('offering_category',[]);
		$data['total_offering'] = $this->model->countData('offering',[]);
        $page = 'dashboard';
        $this->header_and_footer($page, $data);
    }
	public function logout(){
        if($this->session->userdata('usertype') == 'admin'){
            $redirect = 'admin';
        }else if($this->session->userdata('usertype') == 'staff'){
            $redirect = 'staff-login';
        }else if($this->session->userdata('usertype') == 'turf_owner'){
            $redirect = 'turf-owner-login';
        }
		$this->session->unset_userdata(array('logged_in','email','usertype','id','mobile'));
		redirect(base_url($redirect));
	}
	function multipleDel()
    {
		$this->multipleDelete();
    }
    function Status()
    {
		$this->changeStatus();
    }
    public function fetch_state()
    {
        if ($this->input->post('country_id')) {
            $cid = $this->input->post('country_id');
            $this->model->fetch_state($cid,$this->input->post('state_id'));
        }
    }
    public function fetch_city()
    {
        if ($this->input->post('state_id')) {
            $sid = $this->input->post('state_id');
            $this->model->fetch_city($sid,$this->input->post('city_id'));
        }
    }
}
