<?php 
class Venue_model extends CI_Model {
	public function _consruct(){
		parent::_construct();
 	}

 	public function getVenueData($venue_id='',$view=''){
 		$cond  = (!empty($view))?" VNE.status IN ($view) ":" VNE.status != '2' ";
 		$cond .= (!empty($venue_id))?" AND VNE.id='$venue_id' ":"";

 		$sql = "SELECT VNE.id AS venue_id,VNE.*,REG.name AS region_name,HST.host_category,HST.show_layout
 				FROM venue AS VNE
 				INNER JOIN region AS REG ON (VNE.region_id=REG.id)
 				INNER JOIN host_categories AS HST ON (HST.host_cat_id=VNE.host_cat_id)
 				WHERE $cond";

 		$venueData = $this->db->query($sql);

 		if(!empty($venueData)){
 			return (empty($venue_id))?$venueData->result():$venueData->row();
 		}
 		return 0;
 	}

 	public function createVenue($venueData = array()){
 		if(empty($venueData)){
 			return 0;
 		}
 		$status = $this->db->insert('venue',$venueData);
 		return $status;
 	}

 	public function updateVenues($venue_id = '', $venueData = array()){
 		if(empty($venue_id) || empty($venueData)){
 			return 0;
 		}
 		$status = $this->db->update('venue',$venueData,array('id'=>$venue_id));
 		return $status;
 	}

 	public function changeStatus($venue_id = '', $status = '0'){
 		if(empty($venue_id)){
 			return 0;
 		}
 		$status = $this->db->update('venue',array('status'=>$status),array('id'=>$venue_id));
 		return $status;
 	}
}
?>