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

class Result extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->library('layouts');
		
		checkDashboard();
		$this->session->set_userdata('menu', "result");
		
	}
	
	
	public function index($mode=false){
		
		$this->lang->load("result",$this->session->userdata('language'));
		
		$this->load->model('result_model');
		
		
			$bodyData['rptDataDetail'] = $this->result_model->result_all();
			
			$gettotaluser = $this->result_model->get_totaluser();
			$gettotalvote = $this->result_model->get_totalvote();
			
			$this->load->model('header_model');
			$getheader = $this->header_model->getreportsetting();
			//var_dump($getheader);
			$headerData['getLogo'] = ($getheader)?$getheader[0]->logo_report:null;
			
			$bodyData['reportheader'] = ($getheader)?$getheader[0]->header_report:'';
			
			$headerData['rptTitle'] = "";
			
			$bodyData['memberNo'] = $gettotaluser[0]->totaluser;
			
			$bodyData['companyName'] = $gettotalvote[0]->totalvote;
			
			$bodyData['position'] = $this->result_model->get_position();
			
			$bodyData['countposition'] = sizeof($bodyData['position']);
			
			$bodyData['tableHeader'] = array($this->lang->line('designation'), $this->lang->line('candidate'), $this->lang->line('entity'), $this->lang->line('totalvote'));
			
			$bodyData['selectFields'] = array("positionName", "candidateName", "countvote");
			//$bodyData ['tdAmount'] = array("elected", "ordering");
			
			if (!$mode) {
				//print
				$this->load->view('layouts/report/headerresult', $headerData);
				$this->load->view('layouts/report/bodyresult', $bodyData);
				$this->load->view('layouts/report/footerresult');
			} else {
				//download excel
				$this->load->helper('excel');
				excel($headerData, array($bodyData), '');
			}
		
		
		
	}
	
	
	
	
}

?>