<?php
defined('BASEPATH') OR exit('No direct script access allowed');
Class User Extends MY_Controller{
	function __construct()
	{
		parent::__construct();	
		$this->load->model('admin_api/User_model');
		$this->config->load('my_constants');
	}

	public function user_list()
	{
		$data['active_user'] = 'open';
		$data['title'] = 'User List';
		$data['header_title'] = 'User';
		$data['category_info'] = $this->User_model->get_user_list();
		//print_r($data['package_info']);exit();
		$data['main_content'] = 'admin/user/add_user';
        $this->load->view('admin/includes/template', $data);
	}

	
	
	public function save_User()
	{
		$post_data = $this->input->post();
			$query=$this->User_model->save_user($post_data);
			if($query){
				$this->session->set_flashdata('success_message', 'User Added successfully!');

				redirect('admin/User/user_list','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to Add User!');
				redirect('admin/User/user_list','refresh');
			}
	}
	
		public function update_user()
	{
		$post_data = $this->input->post();
			$query=$this->User_model->update_user($post_data);
			if($query){
				$this->session->set_flashdata('success_message', 'User  Updated successfully!');

				redirect('admin/User/user_list','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to Updated user!');
				redirect('admin/User/user_list','refresh');
			}
	}

	public function delete_user($id=NULL,$status=NULL)
	{
	
	//	$post_data = $this->input->post();
			$query=$this->User_model->delete_user($id,$status);
			if($query){
				$this->session->set_flashdata('success_message', 'User delete successfully!');

				redirect('admin/User/user_list','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to delete user!');
				redirect('admin/User/user_list','refresh');
			}
	}
	


}?>