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

class Admin_Edit_Model extends CI_Model
{
    
    /**
     * This function used to check the login credentials of the user
     * @param string $email : This is email of the user
     * @param string $password : This is encrypted password of the user
     */
    function Edit_Data_Client_Admin($edit_data,$username)
    {   
        $username=urldecode($username);
        $username=trim($username);
         $this->db->set($edit_data);
        $this->db->where('cid', $username);
        $this->db->update('users');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
             //echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
    }

    function Edit_Data_Client_Candidate($edit_data,$username)
    {   
        $username=urldecode($username);
        $username=trim($username);
        $this->db->where('pid', $username);
        $this->db->update('participants', $edit_data);
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
            // echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
    }

    function Edit_Data_Client_Admin_Main($edit_data,$username)
    {   
        $username=urldecode($username);
        $username=trim($username);
        $this->db->where('cid', $username);
        $this->db->update('users', $edit_data);
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
            // echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
    }

    function Delete_Data_Client_Admin_Main($username)
    {   
        $username=urldecode($username);
        $username=trim($username);
        $query= $this->db->select('cid')->from('users')-> where('cid', $username)->get();
        if($query){
           $this -> db -> where('cid', $username);
        $this -> db -> delete('users');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
            // echo $username;   
             return $username;
       }

       else
       {
           return false;
       } 
        }else{
             return $username;
        }
        
    }

    function Delete_Data_Client_Admin_User($username)
    {   
        $username=urldecode($username);
        $username=trim($username);
        $query= $this->db->select('id')->from('user_list_type')-> where('username', $username)->get();
         if($query){
        $this -> db -> where('username', $username);
        $this -> db -> delete('user_list_type');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

           if($this->db->affected_rows()>0)
          {    
             //echo $username;   
             return $username;
          }

          else
          {
            return false;
          }
       
       }else{
             return $username;
        }
    }

    function Delete_Data_Client_Administrator($username)
    {   
        $username=urldecode($username);
        $username=trim($username);
         $query= $this->db->select('id')->from('administrator')-> where('username', $username)->get();
         if($query){
        $this -> db -> where('username', $username);
        $this -> db -> delete('administrator');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
            // echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
         }
         else{
             return $username;
        }
    }

    function Delete_Data_Client_Admin($username)
    {   
        $username=urldecode($username);
        $username=trim($username);
         $query= $this->db->select('name')->from('users')-> where('cid', $username)->get();
         if($query){
        $this -> db -> where('cid', $username);
        $this -> db -> delete('users');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
             //echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
         }
         else{
             return $username;
        }
    }

    function Delete_Data_Client_Admin_In_Ballot($username)
    {
        $username=urldecode($username);
        $username=trim($username);
         $query= $this->db->select('id')->from('ballot_status')-> where('client_id', $username)->get();
         if($query){
        $this -> db -> where('client_id', $username);
        $this -> db -> delete('ballot_status');
       // $query=$this->db->query("update user_details SET '$edit_data' where username='$username' ");

       if($this->db->affected_rows()>0)
       {    
             //echo $username;   
             return $username;
       }

       else
       {
           return false;
       }
         }
         else{
             return $username;
        }
    }


}

?>
