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

class Delete_Vote_Data extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function Delete_Ballot()
    {
        $ballot_id= $this->input->get('ballot_id');
        $ballot_name= $this->input->get('ballot_name');

        $ballot_id=urldecode($ballot_id);
        $ballot_id=trim($ballot_id);

        $ballot_name=urldecode($ballot_name);
        $ballot_name=trim($ballot_name);

        $this->load->model('Delete_Vote_Data_Model');
      
        if($this->Delete_Vote_Data_Model->Delete_Ballot($ballot_id))
            {   
                if($this->Delete_Vote_Data_Model->Delete_Ballot_Status($ballot_name))
                {
                    $this->session->set_flashdata('deleted_ballot','Data Deleted');
                    redirect(base_url().'index.php/Ballot_Controller_Admin/Show_Ballots');
                } 
                else
                {
                    $this->session->set_flashdata('deleted_ballot','Data deleted');
                    redirect(base_url().'index.php/Ballot_Controller_Admin/Show_Ballots');
                }    
            }

        else
        {
            echo "not done";
        }
    } 
    
    function Delete_Candidate_Data($pid)
    {
        $pid=urldecode($pid);
        $pid=trim($pid);

        $this->load->model('Delete_Vote_Data_Model');

        if($this->Delete_Vote_Data_Model->Delete_Candidate($pid))
        {   
            $this->session->set_flashdata('deleted_candidate','Candidate Deleted');
            redirect(base_url().'index.php/Ballot_Controller_Admin/Show_Ballots'); 
        }

        else
        {
            $this->session->set_flashdata('deleted_candidate','Candidate not Deleted');
            redirect(base_url().'index.php/Ballot_Controller_Admin/Show_Ballots'); 
        }
    }

}
?>