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

class Report_Controller extends CI_Controller {

	public function index()
	{
		$this->load->model('Fetch_Ballot_Model');
      
        if($this->Fetch_Ballot_Model->Fetch_Data())
            {   
                $all_data['data']=$this->Fetch_Ballot_Model->Fetch_Data();
                        /*echo " "."admin ".$data[0]->name." ".$data[0]->email." ".$data[0]->type;
                        echo " "."admin ".$data[1]->name." ".$data[1]->email." ".$data[1]->type;*/

                $this->load->view('Report_Voting_View',$all_data);
                        //echo " ".$all_data[0]->id;
            }
        else
        {
            $all_data['data']=null;
            $this->session->set_flashdata('error'.'No Candidates found');
            $this->load->view('Report_Voting_View',$all_data);

        }
		
	}
	
	public function Candidate_Wise_Votes($ballot_name)
	{
		$ballot_name=urldecode($ballot_name);
        $ballot_name=trim($ballot_name);


		$this->load->model('Report_Models');
      
        if($this->Report_Models->Candidate_Data($ballot_name))
            {   
                $all_data['data']=$this->Report_Models->Candidate_Data($ballot_name);

                $this->load->view('Report_Votes_View',$all_data);
                        //echo " ".$all_data[0]->id;
            }
        else
        {
            $all_data['data']=null;
            $this->session->set_flashdata('error'.'No Candidates found');
            $this->load->view('Report_Votes_View',$all_data);

        }
	}
    
}
