 <?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'];
		 $this->load->view('Backend/home', $data);
	   }
	   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->getprofile();
            $this->load->view('Backend/profile', $data);
        }
        else
        {
            redirect('App','refresh');
        }
    }
	
	public function slider()
	{
		 if($this->session->userdata('logged_in'))
        {
            $session_data = $this->session->userdata('logged_in');
            $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 about()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['about'] = $this->View_data->about();
			$this->load->view('Backend/about',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function director()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['director'] = $this->View_data->get_director();
			$this->load->view('Backend/director',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function quality()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['quality'] = $this->View_data->get_quality();
			$this->load->view('Backend/quality',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function company()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['company'] = $this->View_data->get_company();
			$this->load->view('Backend/company',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function team()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['team'] = $this->View_data->get_team();
			//$data['servicestype'] = $this->View_data->getservicestype();
			$this->load->view('Backend/team', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_team()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			//$data['services'] = $this->View_data->getservicestype();
			$this->load->view('Backend/new_team', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
		
	public function client()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['client'] = $this->View_data->get_client();
			//$data['servicestype'] = $this->View_data->getservicestype();
			$this->load->view('Backend/client', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_client()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			//$data['services'] = $this->View_data->getservicestype();
			$this->load->view('Backend/new_client', $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->get_product();
			//$data['product_category'] = $this->View_data->get_pcategory();
			$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->getsub_products_id($p_id);	    		 
		 $this->load->view('Backend/edit_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	
	
	public function service()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['service'] = $this->View_data->get_service();
			$this->load->view('Backend/service', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_service()
	{
		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/new_service', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function edit_service($s_id)
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['service'] = $this->View_data->getservice_id($s_id);
			//$data['product'] = $this->View_data->getproduct();
			//$data['servicestype'] = $this->View_data->getservicestype($su_id);
			$this->load->view('Backend/edit_service',$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['g_type'] = $this->View_data->get_gtype();
			$data['gallery'] = $this->View_data->get_gallery();
			$this->load->view('Backend/gallery', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function new_gallery()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['g_type'] = $this->View_data->get_gtype();
			$this->load->view('Backend/new_gallery', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function new_gallery_type()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$this->load->view('Backend/new_gallery_type',$data);
		}
			else
		{
			redirect('App','refresh');
		}
	}
	public function gallery_type()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['g_type'] = $this->View_data->get_gtype();
			$this->load->view('Backend/gallery_type',$data);
			
		}
			else
		{
			redirect('App','refresh');
		}
	}
	public function new_video()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['video'] = $this->View_data->get_video();
			$this->load->view('Backend/new_video', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
    public function video()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['video'] = $this->View_data->get_video();
			$this->load->view('Backend/video',$data);
			
		}
			else
		{
			redirect('App','refresh');
		}
	}
	public function new_testmonial()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_testmonial', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
    public function testmonial()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['test'] = $this->View_data->get_testmonial();
			$this->load->view('Backend/testmonial',$data);
			
		}
			else
		{
			redirect('App','refresh');
		}
	}
	public function new_news()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_news', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
    public function news()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['news'] = $this->View_data->get_news();
			$this->load->view('Backend/news',$data);
			
		}
			else
		{
			redirect('App','refresh');
		}
	}
   public function new_pdf()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_pdf', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
    public function pdf()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['pdf'] = $this->View_data->get_pdf();
			$this->load->view('Backend/pdf',$data);
			
		}
			else
		{
			redirect('App','refresh');
		}
	}
	public function product()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			//$data['product'] = $this->View_data->getproduct();
			$data['product'] = $this->View_data->getsub_products();
			$this->load->view('Backend/product', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	function logout()
	 {
	   error_reporting(0);	  
	   $this->session->unset_userdata('logged_in');
	   session_destroy();
	   redirect('App', 'refresh');
	 }	
	
}