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

class header_model extends CI_Model {
	private $states;

	public function __construct() {
		parent::__construct();
		$this->lang->load('dashboard', $this->session->userdata('language'));
	}

	
	public function getDesignation(){
		$this->db->select('count(positionID) as totalPosition');
		$this->db->from('position');
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getCandidate(){
		$this->db->select('count(candidateID) as totalCandidate');
		$this->db->from('candidate');
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getVoter(){
		$this->db->select('count(userID) as totalVoter');
		$this->db->from('user');
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getVote(){
		$this->db->select('count(userID) as totalVote');
		$this->db->where('status', 1);
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$this->db->from('user');
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getCompany(){
		$this->db->select('count(companyID) as totalCompany');
		$this->db->from('company');
		$this->db->where('companyID <>', 0);
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getBlock(){
		$this->db->select('count(userID) as totalBlock');
		$this->db->from('user');
		$this->db->where('validity', 1);
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function getProfile($userID){
		$this->db->from('tbl_usermaster');
		$this->db->where('fldid', $userID);
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}
	
	public function update($tname, $userID, $data) {
        $this->db->where('fldid', $userID);
        $query = $this->db->update($tname, $data);
        if ($query === TRUE) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
	
	
	public function getreportsetting(){
		$this->db->from('report_setting');
		$this->db->where('reportID', element('userID', $this->session->userdata('logged_in')));
		$this->db->where('projectID', $this->session->userdata('projectID'));
		$query = $this->db->get();
        if($query->num_rows() >= 1){
            return $query->result();
        } else {
            return FALSE;
    	}
	}

	
}
?>
