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

class Details extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index($listing_title,$listing_id)
	{
		$this->load->model('categories_model');
		$parent_categories=$this->categories_model->getParentCategories();
		
		$this->load->model('postings_model');
                $this->load->model('inquiries_model');
		$details=$this->postings_model->getDetails($listing_id);
		$views=$details->views;
		if($details->user_id != $this->session->userdata('user_id')){
			$data=array('views'=>$views+1);
			$this->db->where('id',$listing_id);
			$this->db->update('postings',$data);
		}
		$this->load->model('user_model');
		$user=$this->user_model->getUser($details->user_id);
		$cid=$details->category_id;
		$itemCategory=$this->categories_model->getCategory($cid);
		$data['itemCategory']=$itemCategory->name;
		$data['itemCategoryId']=$itemCategory->id;
		
		if($itemCategory->parent_id > 0){
			$pCategory=$this->categories_model->getCategory($itemCategory->parent_id);
			$data['pCategory']=$pCategory->name;
			$data['pCategoryId']=$pCategory->id;
		}
                $data['parent_categories']=$parent_categories;
		$data['details']=$details;
		$data['user']=$user;
		$data['main_content']='listingdetail';
		$data['title']=$details->title.' Dewas,'.$itemCategory->name.' in Dewas';
		$data['bodyid']='list-details';
		$this->load->view('template',$data);
		
	}

	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */