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

class Dashboard_Controller extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->view('Dashboard');
    }
    
    public function Count_Func()
	{
		$this->load->model('Dashboard_Model');
		
		$data=array();

		if($this->Dashboard_Model->Count_Users())
           {   
				$count_total_users=$this->Dashboard_Model->Count_Users();
				$data["users"]=$count_total_users;
				//echo $count_total_users;
		   }
		else
		{
			$data["users"]=null;
		}   
		   
		if($this->Dashboard_Model->Count_Titles())
           {   
				$count_total_titles=$this->Dashboard_Model->Count_Titles();
				$data["ballots"]=$count_total_titles;
				//echo $count_total_titles;
		   }
		else
		{
			$data["ballots"]=null;
		}   
		   

		if($this->Dashboard_Model->Count_Candidates())
           {   
				$count_total_candidates=$this->Dashboard_Model->Count_Candidates();
				$data["candidates"]=$count_total_candidates;
				//echo $count_total_titles;
		   }
		else
		   {
			   $data["candidates"]=null;
		   }     
		
		if($this->Dashboard_Model->Count_Votes())
           {   
				$count_total_votes=$this->Dashboard_Model->Count_Votes();
				$data["votes"]=$count_total_votes;
				//echo $count_total_votes;
		   }
		else
		   {
			   $data["votes"]=null;
		   }     

		if($this->Dashboard_Model->Fetch_Ballot_Data())
		{
			$data['datas']=$this->Dashboard_Model->Fetch_Ballot_Data();
			$this->load->view('Dashboard',$data);
		}
		else
		{
			$data["datas"]=null;
			$this->load->view('Dashboard',$data);
		}
		   
		   
	}

	public function voting_admin_details()
	{
		$this->load->view('Voting_Details_Admin');
	}

	
}
