<?php
Class Site extends CI_Controller{

     function __construct()
    {
	 parent::__construct();
	 $this->load->model('View_data');
	 $this->load->helper(array('html','language','form','text'));
   $this->load->helper('my_helper');
	 $this->load->model('Search_data');
	 $this->load->model('Common_model');
	 $this->load->library('form_validation');
    }

     public function index()
    {
      $data['title'] = 'Three Star Agro International: Home';
      $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['slider'] = $this->View_data->getslider();
	  $data['sub_slider'] = $this->View_data->getsub_slider();
	  $data['product'] = $this->View_data->get_product();
	  $data['test'] = $this->View_data->get_testmonial();
	   $data['products'] = $this->View_data->get_product();
	 $data['category'] = $this->View_data->get_category();
	 $data['certificate'] = $this->View_data->get_certificate();
	  $data['video'] = $this->View_data->get_video();
	 $data['sub_category'] = $this->View_data->get_subcategory();
    $this->load->view('Frontend/index', $data);
    }
    public function sitemap()
    {
      $this->load->view('sitemap');
    }
	  public function spices($c_name, $c_id)
    {
	 $c_id = base64_decode($c_id);
      $data['title'] = 'Three Star Agro International: Indian Spice';
      $data['page'] = 'Home';
	  $data['c_name'] = str_replace(' ','-',$c_name);
	  $data['about'] = $this->View_data->about();
	   $data['product'] = $this->View_data->get_product();
	  $data['products'] = $this->View_data->get_product_cid($c_id);
	 $data['category'] = $this->View_data->get_category();
	 $data['category_img'] = $this->View_data->get_category_img($c_id);
	 $data['contact'] = $this->View_data->getprofile();

    $this->load->view('Frontend/spices', $data);
    }

	  public function vission()
    {
      $data['title'] = 'Three Star Agro International: Vission & Mission';
      $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	  $data['product'] = $this->View_data->get_product();
	 $data['contact'] = $this->View_data->getprofile();
    $this->load->view('Frontend/vission', $data);
    }

	public function team()
    {
      $data['title'] = 'Three Star Agro International: Our Team';
      $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	  $data['product'] = $this->View_data->get_product();
	  $data['team'] = $this->View_data->get_team();
	 $data['contact'] = $this->View_data->getprofile();
    $this->load->view('Frontend/team', $data);
    }

	public function brands()
	{
	 $data['title'] = 'Three Star Agro International: Brands';
	  $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $this->load->view('Frontend/brands',$data);


	}

	 public function certificates()
    {
      $data['title'] = 'Three Star Agro International: Certificates';
      $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	  $data['certificate'] = $this->View_data->get_certificate();
	    $data['category'] = $this->View_data->get_category();
	   $data['product'] = $this->View_data->get_product();
	 $data['contact'] = $this->View_data->getprofile();

    $this->load->view('Frontend/certificates', $data);
    }

	  public function view_site()

    {
      $data['title'] = 'Three Star Agro International: Home';
      $data['page'] = 'Home';
	  $data['about'] = $this->View_data->about();
	  $data['category'] = $this->View_data->get_category();
	 $data['contact'] = $this->View_data->getprofile();

    $this->load->view('Frontend/view_site', $data);
    }
	public function product_details($p_name, $p_id)
	{
      $data['title'] = 'Three Star Agro International: Our Product ';
      $data['page'] = 'Product';
	  $data['p_name'] = str_replace('-',' ',$p_name);
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	  $data['product'] = $this->View_data->get_product();
	  $data['product_details'] = $this->View_data->get_product_id(base64_decode($p_id));
	 $data['category'] = $this->View_data->get_category();
      $this->load->view('Frontend/product_details', $data);
    }

    public function news()
	{
      $data['title'] = 'Three Star Agro International : News & Updates ';
      $data['page'] = 'Shopping-Cart';
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['category'] = $this->View_data->get_category();
	  $data['news'] = $this->View_data->get_news();
      $this->load->view('Frontend/news', $data);
    }

    public function checkout()
	{
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Shop-Cart';
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
  $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/checkout', $data);
    }

    public function shopping_details($s_id){
      $data['title'] = 'Three Star Agro International: Our Product ';
      $data['page'] = 'Shopping-details';
	 //$data['s_name'] = str_replace('-',' ',$s_name);
	 $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['product'] = $this->View_data->get_productid(base64_decode($s_id));
	 $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/shopping_details', $data);
    }

     public function pro($c_id){
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Shopping-details';
	 $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['product'] = $this->View_data->get_product_cid(base64_decode($c_id));
	 $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/pro', $data);
    }

	public function disclaimer()
	{
      $data['title'] = 'Three Star Agro International : Disclaimer ';
      $data['page'] = 'Shop-Cart';
	   $a_title = 'disclaimer';
    $data['disclaimer'] = $this->Common_model->select_by_id('a_title', $a_title, 'articles');
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	  $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/disclaimer', $data);
    }

    public function privacy()
	{
      $data['title'] = 'Three Star Agro International : Disclaimer ';
      $data['page'] = 'Shop-Cart';
	   $a_title = 'privacy';
    $data['privacy'] = $this->Common_model->select_by_id('a_title', $a_title, 'articles');
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	  $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/privacy', $data);
    }

    public function delivery()
	{
      $data['title'] = 'Shop_now : Our Product ';
      $data['page'] = 'Shop-Cart';
	   $a_title = 'delivary';
       $data['delivery'] = $this->Common_model->select_by_id('a_title', $a_title, 'articles');
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	  $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();

      $this->load->view('Frontend/delivery', $data);
    }

    public function terms()
	{
      $data['title'] = 'Shop_now : Our Product ';
      $data['page'] = 'terms';
	  $a_title = 'terms';
    $data['terms'] = $this->Common_model->select_by_id('a_title', $a_title, 'articles');

	 $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	  $data['category'] = $this->View_data->get_category();
	 $data['sub_category'] = $this->View_data->get_subcategory();
      $this->load->view('Frontend/terms', $data);
    }



    public function about()
    {
      $data['title'] = 'Three Star Agro International : About us ';
      $data['page'] = 'About';
	 $data['about'] = $this->View_data->about();
	 $data['category'] = $this->View_data->get_category();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['product'] = $this->View_data->get_product();

      $this->load->view('Frontend/about', $data);
    }


    public function product(){
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Product';
	  $data['about'] = $this->View_data->about();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['product'] = $this->View_data->get_product();
      $this->load->view('Frontend/product',$data);
    }

    public function gallery()
    {
      $data['title'] = 'Three Star Agro International : Gallery ';
      $data['page'] = 'Gallery';
      //$docket = $this->input->post('ts_docket');
	  $data['category'] = $this->View_data->get_category();
      $data['contact'] = $this->View_data->getprofile();
     $data['about'] = $this->View_data->about();
     $data['product'] = $this->View_data->get_product();
	$data['gt_type'] = $this->View_data->get_gtype();
     $data['gallery'] = $this->View_data->get_gallery();
     $this->load->view('Frontend/gallery',$data);
    }

      public function contact()
   {
     $data['title'] = 'Three Star Agro International : Contact ';
     $data['page'] = 'Contact';
	 $data['about'] = $this->View_data->about();
	 $data['category'] = $this->View_data->get_category();
    $data['contact'] = $this->View_data->getprofile();
    $data['product'] = $this->View_data->get_product();
    $this->load->view('Frontend/contact',$data);
   }
    public function search()
  {
    if(!empty($_POST["search"])) {
		$query ="SELECT * FROM product WHERE p_name like '%" . $_POST["search"] . "%' ORDER BY p_id LIMIT 0,6";
		//$result = $db_handle->runQuery($query);
		$result = $this->db->query($query)->result();
    echo "<ul>";
    if(!empty($result)) {

		foreach($result as $country) {
			echo "<li><a href='".base_url().'product-details/'.rm_blank($country->p_name)."/".base64_encode($country->p_id)."'>".trim($country->p_name)."</a></li>";
		}

		}
		else {
			echo '<li>No Results Found. <small style=color:#0083c9>Please Search Another Keywords....</small></li>';
		}
    }
    echo "</ul>";
  }

    public function blogs(){
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Product';
	  $data['about'] = $this->View_data->about();
	  $data['contact'] = $this->View_data->getprofile();
	  $data['news'] = $this->View_data->get_news();
	  $data['product'] = $this->View_data->get_product();
      $this->load->view('Frontend/blogs', $data);
    }

	public function blog($p_name, $p_id){
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Product';
	  $data['p_name'] = str_replace('-',' ',$p_name);
	  $data['about'] = $this->View_data->about();
	  $data['contact'] = $this->View_data->getprofile();
	  $data['product'] = $this->View_data->get_product();
	  $data['products'] = $this->View_data->get_product_id($p_id);
      $this->load->view('Frontend/blog', $data);
    }

	public function categories($c_name, $c_id)
	{
	  $data['title'] = str_replace('-',' ',$c_name);
	  $data['category'] = $this->View_data->get_category();
	  $data['blogs'] = $this->View_data->get_blogs();
	  $data['categories'] = $this->View_data->getsub_blogs_id(base64_decode($c_id));
	  $this->load->view('Frontend/categories',$data);
	}

	 public function search_blogs()
	{

   	  $name = $this->input->post('search');
      $data['search'] =$this->Search_data->search($name);
	  $data['category'] = $this->View_data->get_category();
	  $data['blogs'] = $this->View_data->get_blogs();
      $this->load->view('Frontend/search',$data);
  }



	 public function service($s_name, $s_id)
    {
      $data['title'] = str_replace('-',' ',$s_name);
      $data['page'] = 'Service';
      $data['contact'] = $this->View_data->getprofile();
	  $data['service'] = $this->View_data->getservice_id(base64_decode($s_id));
      $this->load->view('Frontend/service',$data);
    }

	public function product1($p_name, $p_id)
    {
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Product';
      $data['p_name'] = str_replace('-',' ',$p_name);
      $data['contact'] = $this->View_data->getprofile();
      $data['slider'] = $this->View_data->getslider();
     $data['service'] = $this->View_data->get_service();
     $data['services'] = $this->View_data->get_service_random();
     $data['about'] = $this->View_data->about();
     $data['printer_types'] = $this->View_data->get_product();
     $data['client'] = $this->View_data->get_client();
     $data['gallery'] = $this->View_data->get_gallery_random();
     $data['products'] = $this->View_data->getsub_products_id(base64_decode($p_id));
     $this->load->view('Frontend/product',$data);
    }
    public function details($p_name,$p_id)
      {
      $data['title'] = 'Three Star Agro International : Our Product ';
      $data['page'] = 'Product';
      $data['p_name'] = str_replace('-',' ',$p_name);
      $data['contact'] = $this->View_data->getprofile();
      $data['slider'] = $this->View_data->getslider();
      $data['service'] = $this->View_data->get_service();
      $data['services'] = $this->View_data->get_service_random();
      $data['about'] = $this->View_data->about();
      $data['printer_types'] = $this->View_data->get_product();
      $data['client'] = $this->View_data->get_client();
      $data['gallery'] = $this->View_data->get_gallery_random();
      $data['products'] = $this->View_data->getsub_products_id(base64_decode($p_id));
      $this->load->view('Frontend/details',$data);
      }

     public function video()
    {
    $data['title'] = 'Three Star Agro International : Video Gallery ';
      $data['page'] = 'Video';
	 $data['video'] = $this->View_data->get_video();
	$data['about'] = $this->View_data->about();
	 $data['category'] = $this->View_data->get_category();
	 $data['contact'] = $this->View_data->getprofile();
	 $data['product'] = $this->View_data->get_product();
    $this->load->view('Frontend/video',$data);
    }






}
