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

class Voting_Titles_Admin_Data extends CI_Model
{
    function Fetch_Data_User($username)
    {
        $username=trim($username);
        $username=urldecode($username);
        $this->db->where('cid',$username);
        $query = $this->db->get('users');
        $res= $query->result();
       
       if($query->num_rows()>0)
       {
            return $res[0]->zone;
       }

       else
       {
           return false;
       }
    }

    function Fetch_Data($zone)
    {
        if($zone!='All')
        {
            $this->db->group_start()
            ->where('zone',$zone)
            ->or_where('zone','All')
            ->order_by('id', 'desc')
            ->group_end();

            $query = $this->db->get('ballot');
        }

        else
        {
            $query = $this->db->get('ballot');
        }
       

       if($query->num_rows()>0)
       {
             return $query->result();
       }

       else
       {
           return false;
       }
    }

    function Candidate_Data($electoralid)
    {
       $this->db->where('ballot_name',$electoralid);
       $query = $this->db->get('participants');
       $res= $query->result();
       
       if($query->num_rows()>0)
       {
            return $res;
       }

       else
       {
           return false;
       }
    }

}

?>
