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

class Add_Zone_Controller extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
	public function Add_Zone_View()
	{
		$this->load->view('Add_Zone_View');
    }
    
    public function Add_Zone_Data()
	{
		$this->load->library('form_validation');
        $this->form_validation->set_rules('zone', 'zone', 'required');

        if($this->form_validation->run())
        {
            $zone=$this->input->post('zone');
            $edit_data['zone']=$zone;
            $this->load->model('Add_Zone_Model');
            if($this->Add_Zone_Model->Insert_Zone_Data($edit_data))
                {
                    //echo "Inserted";
                    $this->session->set_flashdata('zone_added','Zone added Successfully');
                    redirect(base_url().'index.php/Add_Zone_Controller/Add_Zone_View');
                }
                else
                {
                    //echo "Not Inserted";
                    $this->session->set_flashdata('zone_added','Zone not added');
                    redirect(base_url().'index.php/Add_Zone_Controller/Add_Zone_View');
                }
        }
        	else
        {
           $this->session->set_flashdata('error',validation_errors());
                redirect(base_url().'index.php/Add_Zone_Controller/Add_Zone_View'); 
		   
        }
    }
    
}
