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

class Check_If_Voted extends CI_Model
{
    function check_vote($electoralid,$datas)
    {
       $array = array('ballot_name' => $electoralid, 'client_id' => $datas);
       
        $query = $this->db->select('vote')->from('ballot_status')->where($array)->get();
       
       if($query->num_rows()>0)
       {   
          return $query->result()[0]->vote;
       }

       else
       {
           return false;
       }
    }

    function check_date($electoralid)
    {
       $array = array('ballot_name' => $electoralid);
       
        $query = $this->db->select('date')->from('ballot')->where($array)->get();
       
       if($query->num_rows()>0)
       {   
          if($query->result()[0]->date >= date("Y-m-d"))
            return true;
          else
            return false; 
       }

       else
       {
           return false;
       }
    }

}

?>
