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

class State extends CI_Controller {
	// Session Authoriesed
	public function __construct() {
		parent::__construct();
		
		$admin = $this->session->userdata('admin');
		$column['id'] = $admin['id'];
		$table = 'tbl_user';
		
	    // loading common model
	    $this->load->model('Common_model');
		$result = $this->Common_model->Result($column,$table);
		if($result['password'] == $admin['password']){
		    $login = true;
		} else {
		    $login = false;
		}
		
		if (empty($admin) || $login==false) {
			$this->session->set_flashdata('msg','Your Session Has Been Expired');
			redirect(base_url().'master/login/index');
		}
		
	   // loading common model
	    $this->load->model('Common_model');
	}

	public function index()
	{
        // we are setting data for get site data
		$column['id'] = '1';
		$table = 'tbl_settings';
		
        // we are getting results from common modal
		$result = $this->Common_model->Result($column,$table);
		
        // we are setting result in data array as $data
		$data['data'] = $result;
		$data['page'] = 'State';
		
		$table = 'tbl_state';
        // we are getting results from common modal
		$result = $this->Common_model->Results($table);
		
		$data['state'] = $result;
		
        // we are loading admin dashboard
		$this->load->view('master/state/list',$data);	
	}


	public function edit($id)
	{
        // we are setting data for get site data
		$column['id'] = '1';
		$table = 'tbl_settings';
		
        // we are getting results from common modal
		$result = $this->Common_model->Result($column,$table);
		
        // we are setting result in data array as $data
		$data['data'] = $result;
		$data['page'] = 'State';
		
		$table = 'tbl_state';
		$column['id'] = $id;
        // we are getting results from common modal
		$result = $this->Common_model->Result($column,$table);
		
		$data['state'] = $result;
		
        // we are loading admin dashboard
		$this->load->view('master/state/edit',$data);	
	}

	public function create()
	{
        // we are setting data for get site data
		$column['id'] = '1';
		$table = 'tbl_settings';
		
        // we are getting results from common modal
		$result = $this->Common_model->Result($column,$table);
		
        // we are setting result in data array as $data
		$data['data'] = $result;
		$data['page'] = 'State';
		
		
        // we are getting results from common modal
		$result = $this->Common_model->Results($table);
		
		$data['state'] = $result;
		
        // we are loading admin dashboard
		$this->load->view('master/state/create',$data);	
	}

	
}

?>