<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class App extends CI_Controller {
	function __construct() {
	parent::__construct();
	$this->load->model('view_data');	
	}
	public function index()
	{
		$this->load->view('Backend/login');
	}	
	public function home()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		// $data['products'] =$this->view_data->getproduct_all();
		 $this->load->view('Backend/profile');
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }		
	}
	public function profile()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['profile'] = $this->view_data->getcompany_profile();
		 $this->load->view('Backend/profile', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }		
	}
	public function about()
	{
		if($this->session->userdata('logged_in'))
   		{
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['about'] = $this->view_data->getabout_us();
		 $this->load->view('Backend/about', $data);
	    }
	    else
	    {
		 redirect('app', 'refresh');
	    }		
	}
	public function technology()
	{
		if($this->session->userdata('logged_in'))
   		{
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['technology'] = $this->view_data->gettechnology();
		 $this->load->view('Backend/technology', $data);
	    }
	    else
	    {
		 redirect('app', 'refresh');
	    }		
	}
	public function services_amc()
	{
		if($this->session->userdata('logged_in'))
   		{
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		$data['services'] = $this->view_data->getservices_amc();
		 $this->load->view('Backend/services_amc', $data);
	    }
	    else
	    {
		 redirect('app', 'refresh');
	    }		
	}
	public function products()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['products'] =$this->view_data->getproduct();
		 $this->load->view('Backend/products', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
    public function new_product()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $this->load->view('Backend/new_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function edit_product($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['product'] =$this->view_data->getproduct_id($p_id);
		 $this->load->view('Backend/edit_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	 public function new_sub_product($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['product']=$this->view_data->getproduct_id($p_id);
		 $this->load->view('Backend/new_sub_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function edit_sub_product($sp_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['products'] =$this->view_data->getproduct();
		 $data['sub_product']=$this->view_data->getsub_product_id($sp_id);
		 $this->load->view('Backend/edit_sub_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}			
	public function sub_products($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		// $data['categories'] =$this->view_data->getcategories();
		 $data['sub_products'] =$this->view_data->getsub_product($p_id);
		 $data['p_id']=$p_id;
		 $this->load->view('Backend/sub_products', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	
	public function slider()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		// $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 $data['slider'] = $this->view_data->getslider();
		 $this->load->view('Backend/slider', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function new_slider()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $this->load->view('Backend/new_slider', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
   /* public function gallery()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];	
		// $data['products'] = $this->view_data->getproduct_all();	
		 $data['gallery'] = $this->view_data->getgallery();
		 $this->load->view('Backend/gallery',$data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function new_image()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $this->load->view('Backend/new_image', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}		
	public function new_category()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 //$data['products'] =$this->view_data->getproduct_all();
		 //$data['type']=$type;	
		 $this->load->view('Backend/new_category', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function edit_category($c_id)
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		// $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		// $data['category'] = $this->view_data->getcategory_id($c_id);
		 $this->load->view('Backend/edit_category', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }		
	}
	

	public function channel_partners()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['products'] = $this->view_data->getproduct_all();
		 $data['partners'] = $this->view_data->getpartners();
		 $this->load->view('Backend/channel_partners', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	public function new_partner()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['products'] = $this->view_data->getproduct_all();
		 $this->load->view('Backend/new_partner', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	public function edit_partner($c_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['products'] = $this->view_data->getproduct_all();
		 $data['partner']=$this->view_data->getpartner_id($c_id);
		 $this->load->view('Backend/edit_partner', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	

	
		
	public function catalogs()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];		
		 $data['catalog'] = $this->view_data->getcatalog();
		 $this->load->view('Backend/catalogs', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function news()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 $data['news'] = $this->view_data->getnews();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/news', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function add_news()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 //$data['news'] = $this->view_data->getnews();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/add_news', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function new_catalog()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 //$data['news'] = $this->view_data->getnews();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/new_catalog', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function edit_news($n_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 $data['news'] = $this->view_data->getnews_id($n_id);
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/edit_news', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function testimonials()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 $data['testimonials'] = $this->view_data->gettestimonials();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/testimonials', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function new_testimonials()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 //$data['news'] = $this->view_data->getnews();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/new_testimonials', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function edit_testimonial($t_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['products'] =$this->view_data->getproduct_all();
		 $data['username'] = $session_data['username'];
		 $data['testimonial']=$this->view_data->get_testimonial_id($t_id);
		 //$data['news'] = $this->view_data->getnews();
		 $this->load->view('Backend/edit_testimonials', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	
	/*public function chemical()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['category'] = $this->view_data->getchemical();
	    // echo  count($data['category']);
		 //die();
		 $this->load->view('Backend/chemical', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	public function chromatography()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['category'] = $this->view_data->getcategories_croma();
		 $this->load->view('Backend/chromatography', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function hexonbio()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		$data['category'] = $this->view_data->getcategories_hexon();
		 $this->load->view('Backend/hexonbio', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	} 
	
	
	
	
	
	
	
	
	
	public function services()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['services'] = $this->view_data->getservices();
		 $this->load->view('Backend/services', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
		
	}
	
    
	public function chemical_products($c_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['product'] = $this->view_data->getproducts_category($c_id);
		 $data['p_code'] =$this->view_data->getproduct_artical();
		 $data['p_cas'] =$this->view_data->getproduct_cas();
		 $data['category']=$this->view_data->getcategory_id($c_id);
		 $this->load->view('Backend/chemical_products', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function products($c_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['product'] = $this->view_data->getproducts_category($c_id);
		 $data['category']=$this->view_data->getcategory_id($c_id);
		 $this->load->view('Backend/products', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function new_chemical($c_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['about'] = $this->view_data->getabout_us();
		 $data['category']=$this->view_data->getcategory_id($c_id);
		 $this->load->view('Backend/new_chemical', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	 public function edit_chemical($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['category'] = $this->view_data->getcategories_all();
		 $data['product'] = $this->view_data->getproduct_id($p_id);
		 $data['p_details'] = $this->view_data->getproduct_details_id($p_id);
		 $data['p_physical'] =$this->view_data->getphysical_id($p_id);
		 $data['p_specification'] =$this->view_data->getspecification_id($p_id);
		 $data['p_packing'] =$this->view_data->getpacking_id($p_id);
		 $data['p_safety'] =$this->view_data->getsafety_id($p_id);
		 $this->load->view('Backend/edit_chemical', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}	
	 public function edit_product($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['category'] = $this->view_data->getcategories_all();
		 $data['product'] = $this->view_data->getproduct_id($p_id);
		 $data['p_details'] = $this->view_data->getproduct_artical_id($p_id); 
		 //$data['p_physical'] =$this->view_data->getphysical_id($p_id);
		 //$data['p_specification'] =$this->view_data->getspecification_id($p_id);
		 //$data['p_packing'] =$this->view_data->getpacking_id($p_id);
		 //$data['p_safety'] =$this->view_data->getsafety_id($p_id);
		 $this->load->view('Backend/edit_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}	
	
	 
		
	
	
	public function website_pages()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $this->load->view('Backend/website_pages', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	
	public function room_tariff()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['room'] = $this->view_data->getroom();
		 $data['discount'] = $this->view_data->getdiscount();
		 $this->load->view('Backend/room_tariff', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	
	public function new_room()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $this->load->view('Backend/new_room', $data);
	   }
	   else	
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function update_room($r_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];		 
		 $data['room'] = $this->view_data->getroom_id($r_id);
		 $this->load->view('Backend/update_room', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function video_gallery()
	{
	   if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];		
		 $data['gallery'] = $this->view_data->getgallery();
		 $this->load->view('Backend/video_gallery', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	
	public function view_coa($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['product'] = $this->view_data->getproduct_id($p_id);
		 $data['coa'] =$this->view_data->getcoa($p_id);
		 $data['msds']=$this->view_data->getmsds($p_id);
		 $this->load->view('Backend/view_coa', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	
	/*public function products()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		
		 $data['product'] = $this->view_data->getproduct();
		 $this->load->view('Backend/products', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	
	}

	public function update_product($p_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 
		 $data['product'] = $this->view_data->getproduct_id($p_id);
		 $this->load->view('Backend/update_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
		
	}
	public function settings()
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		
		 $data['company_profile'] = $this->view_data->getcompany_profile();
		 $this->load->view('Backend/settings', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
 	    
	}
*/	 function logout()
	 {
	   error_reporting(0);	  
	   $this->session->unset_userdata('logged_in');
	   session_destroy();
	   redirect('app', 'refresh');
	 }
}
