 <?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 disclaimer()
	{
		$this->load->view('Backend/disclaimer');
	}

	  public function article()
	{
		$data['article'] = $this->View_data->article();
		$this->load->view('Backend/article',$data);
	}

	public function password()
	{
		$data['password'] = $this->View_data->password();
		$this->load->view('Backend/password',$data);
	}

	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->View_data->article_id($a_id);
		$this->load->view('Backend/edit_article',$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 edit_slider($s_id)
	{
		if($this->session->userdata('logged_in'))
   	   {
		 $session_data = $this->session->userdata('logged_in');
		 $data['username'] = $session_data['username'];
		 $data['slider'] = $this->View_data->get_slider_id($s_id);
		 $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 enquiry()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['enquiry'] = $this->View_data->get_enquiry();
			$this->load->view('Backend/enquiry',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}

	public function case_study()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['case'] = $this->View_data->get_case();
			$this->load->view('Backend/case_study',$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 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 infra()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$data['infra'] = $this->Common_model->select('infrastructure');
			$this->load->view('Backend/infra', $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'];
			$this->load->view('Backend/new_infra', $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();
			$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->get_product_id($p_id);
		 $this->load->view('Backend/edit_product', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }
	}

	public function project()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];	
			$data['project'] = $this->View_data->get_project();
			$this->load->view('Backend/project', $data);

		}
		else
		{
			redirect('App','refresh');
		}
	}

		public function new_project()
	{
		if($this->session->userdata('logged_in'))
		{
			$session_data = $this->session->userdata('logged_in');
			$data['username'] = $session_data['username'];
			$this->load->view('Backend/new_project',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}public function project_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_where_in('a_status', '1', 'project_images');
			$data['project'] = $this->Common_model->select_where_in('p_id', $p_id, 'projects');
			$this->load->view('Backend/project_image',$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->View_data->all_images();
			$data['product'] = $this->View_data->get_product_id($p_id);
			$this->load->view('Backend/add_image',$data);
		}
		else
		{
			redirect('App','refresh');
		}
	}
	public function add_video($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_video');
			$data['product'] = $this->View_data->get_product_id($p_id);
			$this->load->view('Backend/add_video',$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 edit_testmonial($t_id)
	{
		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_id($t_id);
			$this->load->view('Backend/edit_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 edit_news($n_id)
	{
		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_id($n_id);
		 $this->load->view('Backend/edit_news', $data);
	   }
	   else
	   {
		 redirect('app', 'refresh');
	   }
	}



	function logout()
	 {
	   error_reporting(0);
	   $this->session->unset_userdata('logged_in');
	   session_destroy();
	   redirect('App', 'refresh');
	 }



}
