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

	public function add_category()
	{
		$data['active_category'] = 'open';
		$data['title'] = 'category List';
		$data['header_title'] = 'category';
		$data['category_info'] = $this->Category_model->get_category_list();
		$data['product_info'] = $this->Category_model->get_master_product_list();
		//print_r($data['package_info']);exit();
		$data['main_content'] = 'admin/Category/add_category';
        $this->load->view('admin/includes/template', $data);
	}

	
	
	public function save_category()
	{
		$post_data = $this->input->post();
			$query=$this->Category_model->save_category($post_data);
			if($query){
				$this->session->set_flashdata('success_message', 'Category Added successfully!');

				redirect('admin/Category/add_category','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to Add Category!');
				redirect('admin/Category/add_category','refresh');
			}
	}
	
	
		public function update_category()
	{
		$post_data = $this->input->post();
			$query=$this->Category_model->update_category($post_data);
			if($query){
				$this->session->set_flashdata('success_message', 'Master Product Updated successfully!');

				redirect('admin/Category/add_category','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to Updated Master Product!');
				redirect('admin/Category/add_category','refresh');
			}
	}

	public function delete_category($id=NULL)
	{
	
	//	$post_data = $this->input->post();
			$query=$this->Category_model->delete_category($id);
			if($query){
				$this->session->set_flashdata('success_message', 'Master Product Deleted successfully!');

				redirect('admin/Category/add_category','refresh');
			}else{
				$this->session->set_flashdata('failure_message', 'You are fail to Deleted Master Product!');
				redirect('admin/Category/add_category','refresh');
			}
	}
	

}?>