 <?php if( ! defined ('BASEPATH')) exit('No direct Script access allowed');
Class App extends CI_Controller{
    
    function __construct()
    {
        parent:: __construct();
        $this->load->model('View_data');
		$this->load->model('Common_model');	
    }
    
    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 clients()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['clients'] = $this->View_data->get_clients();
			$this->load->view('Backend/clients', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_clients()
	{
		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_clients', $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 article()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['article'] = $this->Common_model->select('articles');
			$this->load->view('Backend/article',$data);
			}
		else
		{
			redirect('App','refresh');
		}
	}

	public function new_article()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
		    $this->load->view('Backend/new_article',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function edit_article($a_id)
	{
		if($this->session->userdata('logged_in'))
		{
		$session_data = $this->session->userdata('logged_in');
		$data['username'] = $session_data['username'];
		$data['article'] = $this->Common_model->select_where_in('a_id',$a_id,'articles');
		$this->load->view('Backend/edit_article',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function certificates()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['certificates'] = $this->Common_model->select_where_in('c_status','1','certificates');
			$this->load->view('Backend/certificates', $data);

		}
		else
		{
			redirect('App','refresh');
		}
	}
		public function new_certificates()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_certificates', $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 edit_slider($sid)
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			
			$data['slider'] = $this->Common_model->select_by_id('s_id',$sid,'slider');
			$this->load->view('Backend/edit_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 add_image($p_id)
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['images'] = $this->Common_model->select('add_image');
			$data['product'] = $this->Common_model->select_where2_in('p_id',$p_id,'p_status','1','sub_product');
			$this->load->view('Backend/add_image',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function vission()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['vission'] = $this->View_data->get_vission();
			$this->load->view('Backend/vission',$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 service()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['service'] = $this->Common_model->select_where_in('s_status','1','service');
			//$data['servicestype'] = $this->View_data->getservicestype();
			$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'];
			$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['product_category'] = $this->View_data->get_pcategory();
		 $data['service'] = $this->Common_model->select_where2_in('s_id',$s_id,'s_status','1','service');	    		 
		 $this->load->view('Backend/edit_service', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	
	public function product_category()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['product_category'] = $this->View_data->get_pcategory();
			//$data['servicestype'] = $this->View_data->getservicestype();
			$this->load->view('Backend/product_category', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_product_category()
	{
		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_product_category', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
		public function edit_product_cat($pt_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 //$data['product_category'] = $this->View_data->get_pcategory();
		 $data['product'] = $this->View_data->get_pcat_id($pt_id);	    		 
		 $this->load->view('Backend/edit_product_cat', $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'];
			$data['product_category'] = $this->View_data->get_pcategory();
			$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_category'] = $this->View_data->get_pcategory();
		 $data['product'] = $this->View_data->getsub_products_id($p_id);	    		 
		 $this->load->view('Backend/edit_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}	
	
	public function faq()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
		    $data['service'] =  $this->Common_model->select_where_in('s_status','1','service');
			$data['faq'] = $this->Common_model->select_where_in('status','1','faq');
			$this->load->view('Backend/faq', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_faq()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
		    $data['service'] =  $this->Common_model->select_where_in('s_status','1','service');
			$this->load->view('Backend/new_faq', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
		public function edit_faq($id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['service'] =  $this->Common_model->select_where_in('s_status','1','service');
		 $data['faq'] = $this->Common_model->select_where2_in('id',$id,'status','1','faq');	    		 
		 $this->load->view('Backend/edit_faq', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function consultancy()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['consultancy'] = $this->Common_model->select_where_in('status','1','consultancy');
			$this->load->view('Backend/consultancy', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_consultancy()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_consultancy', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
		public function edit_consultancy($id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['consultancy'] = $this->Common_model->select_where2_in('id',$id,'status','1','consultancy');	    		 
		 $this->load->view('Backend/edit_consultancy', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }	
	}
	public function infra_s()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['infra'] = $this->View_data->getinfra();
			$this->load->view('Backend/infra_s', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function new_infra()
	{
		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_infra', $data);			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	
	public function edit_infra($in_id)
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['infra'] = $this->View_data->getinfra_id($in_id);
			//$data['product'] = $this->View_data->getproduct();
			//$data['servicestype'] = $this->View_data->getservicestype($su_id);
			$this->load->view('Backend/edit_infra',$data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function project_gallery()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['gallery'] = $this->Common_model->select_where_in('g_status','1','project_gallery');
			$this->load->view('Backend/project_gallery', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function new_projectgallery()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_projectgallery', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function edit_projectgallery($id)
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['gallery'] = $this->Common_model->select_where2_in('g_id',$id,'g_status','1','project_gallery');
			$this->load->view('Backend/edit_projectgallery', $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 newjob()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/newjob', $data);
			
		}
		else
		{
			redirect('App','refresh');
		}
	}
    public function jobs()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] =$session_data['username'];
			$data['jobs'] = $this->View_data->get_jobs();
			$this->load->view('Backend/jobs',$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');
	 }	
	
}