<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Product extends CI_Controller {
	
	public function __construct()
    {
	    parent::__construct();
		 
	}
	
	public function _remap($method,$parameter)
	{    
		if($parameter[0] !=''){
			$pcode = $parameter[0];   
			$this->index($pcode);
		}
	}  
	
	
	//*******************product single page start *******************//	
	public function index($prod_code){
		if( $prod_code !='' ){
			 
			$where_data = array('prod_code' =>$prod_code,);
			$query_prod=$this->Data_access_model->select_data('*','hs_products',$where_data);
		 
			if($query_prod->num_rows() > 0){
				$data['productdetails'] = $query_prod->result();
			  
				$product_id = $data['productdetails'][0]->prod_id;
				$prodcate_id = $data['productdetails'][0]->prod_cateid;
				$data['page_title']=  $data['productdetails'][0]->prod_name;
				$data['page_descri'] = $data['productdetails'][0]->prod_description;
				$rand_product = $this->Data_access_model->select_random_record_where('*','hs_products',array('prod_cateid'=>$prodcate_id),'prod_id',6); 
				if($rand_product->num_rows() > 0 ){
					$data['randproduct']= $rand_product->result();
				}else{
					$data['randproduct']= '';
				}
			}else{
				$data['productdetails'] = ''; 
			}
			if(isset($product_id)){
				$query_rating=$this->Data_access_model->select_data_withlimit('*','hs_rating',array('rating_prod_id'=>$product_id,'rating_status'=>1),50,0);
		
				if($query_rating->num_rows() >0){
					$data['ratingdetails'] = $query_rating->result();
				}else{
					$data['ratingdetails'] = ''; 
				}
			}
		  
			$opening_time_query =$this->Data_access_model->select_all('hs_opening_schedule');
		
			if($opening_time_query->num_rows() > 0){
			   
				$setting_data['opening_time'] =$opening_time_query->result();
			 
			}else{ 
				$setting_data['opening_time'] = "";
			}
		  
			$partner_query=$this->Data_access_model->select_data('*','hs_partners',array('partner_status' =>1,));
			if($partner_query->num_rows() > 0){
			   
				$setting_data['all_partners'] =$partner_query->result();
			 
			}else{ 
				$setting_data['all_partners'] = "";
			  
			}
		
			$offer_query=$this->Data_access_model->select_data('*','hs_offers',array( 'offer_status' =>1,));
			if($offer_query->num_rows() > 0){
				   
				$data['all_offer'] =$offer_query->result();
				 
			}else{ 
				$data['all_offer'] = "";
			}
			$this->load->view('theme/common/header',$data);
			$this->load->view('theme/shop_single',$data);
			$this->load->view('theme/common/footer',$setting_data);
		}
	 }
	//*******************product single page end *******************//
	
	

 

	
	
	
}