<?php
class Inquiries_Model extends CI_Model {
	function __construct(){

	}

	
	public function getInquiriesCount($listid){
		$this->db->select('*');
		$this->db->from('inquiries');
		$this->db->where('listing_id',$listid);
		$query=$this->db->count_all_results();
		return $query;
	}
	public function getInquiries($listid=null){
		$this->db->select('inquiries.id,inquiries.listing_id,inquiries.user_id,inquiries.cname,inquiries.cemail,inquiries.contact,inquiries.comment,inquiries.view_status,inquiries.dt_created,inquiries.dt_modified');
		$this->db->from('inquiries');
                if(!empty($listid)){
                    $this->db->where('listing_id',$listid);
                }else{
                    $this->db->join('postings', 'postings.id = inquiries.listing_id');
                    $this->db->where('postings.user_id',$this->session->userdata('user_id'));
                }
                $this->db->order_by('inquiries.dt_created','desc');
		$query=$this->db->get();
		return $query->result();
	}
        public function getDetails($id){
            $this->db->select('*');
            $this->db->from('inquiries');
            $this->db->where('id',$id);
            $query=$this->db->get();
            return $query->row();
        }
	
} 
?>
