<?php	if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Product_type extends CI_Controller {

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

	function index()	{	
		$this->list_product_type();
	}

	function list_product_type() {
		$this->_page_data['page_title']="List of Product Type";
		$this->_page_data['bredcrum']=array(
										'Masters'=>'#',
										'Product Type'=>site_url('gc/product_type/list_product_type'),
										'List Product Type'=>'#',
										);  
                $select_array=array(
									'table_name'=>PRODUCT_TYPE_TABLE,
									'table_fields'=>'product_type_id,product_type,duration_refill',
									'limit'=>'',
									'offset'=>''
									);
		        $users['users'] = $this->master_model->get_table_data($select_array);

		        $this->load->view('gc/product_type_list.php',$users);
	}
	
	function view_product_type() {
		$this->_page_data['page_title']="View Product Type";
		$this->_page_data['bredcrum']=array(
										'Masters'=>'#',
										'Product Type'=>site_url('gc/product_type/list_product_type'),
										'List Product Type'=>site_url('gc/product_type/list_product_type'),
										'View Product Type'=>'#',
										);
		$this->load->view('gc/product_type_view.php',$this->_page_data);
	}
	
	function manage_product_type($purpose=NULL) {
		if($purpose=='')
			$purpose='Add';
		
		$this->_page_data['purpose']=$purpose;
		$this->_page_data['page_title']=$purpose." Product Type";
		$this->_page_data['bredcrum']=array(
										'Masters'=>'#',
										'Product Type'=>site_url('gc/product_type/list_product_type'),
										//'List Product Type'=>site_url('gc/product_type/list_gc_type'),
										$purpose.' Product Type'=>'#',
										);
		$this->load->view('gc/product_type_manage.php',$this->_page_data);
	}

	function add_product_type() {
		 

        $this->form_validation->set_rules('product_type','Product type','required|alpha');
		$this->form_validation->set_rules('expiry','Select of Duration Refill','required');

		if ($this->form_validation->run()==false) {
		$this->load->view('gc/product_type_manage');
	 }
	 else{
       
		$product_type = $this->input->post('product_type');
		$duration_refill = $this->input->post('expiry');
		
		$add_product_type=array(
								'product_type' => $product_type,
								'duration_refill' => $duration_refill,								
								'created_on' => date("Y-m-d H:i:s"),
								'created_by' =>'1',
								'modified_on' => date("Y-m-d H:i:s"),
								'modified_by' =>'1',
								'is_active' =>''
								);
	     $this->master_model->insert_record('product_type',$add_product_type);
	     redirect('https://shagoon.nityamhygiene.in/index.php/gc/product_type/list_product_type'); 
	 }
	}
}