<?php

if(!defined('BASEPATH')) exit('Hacking Attempt : Get Out of the system ..!');

class Propertytype_model extends CI_Model
{
	public function __construct(){
		parent::__construct();
	}
	
	
/*#################################################################################*/
/*############################################# General START ####################################*/
/*###################################################################################*/
	
	public function get_general($status=NULL){
		$this->db->select('*');
		if($status>=0){
			$where = array('status='=>$status);
			$this->db->where($where);
		}
		$this->db->order_by('updatedon','ASC');
		$query = $this->db->get('settings_property_type');
		
		return $query->result();
	}
	
	public function get_single_general($id){
		$this->db->select('*');
		$where = array('typeId='=>$id);
		$this->db->where($where);
		$query = $this->db->get('settings_property_type');		
		return $query->result();
	}
	
	public function delete_general($id){
		$this->db->where('typeId', $id );
		$this->db->delete('settings_property_type');
		
		$this->db->where(array('itemId='=>$id,'table='=>'types') );
		$this->db->delete('site_seo');
	}
	
	public function set_general($data,$id){		
		if($id>0)
		{
			$this->db->where('typeId', $id);
			$this->db->update('settings_property_type', $data);	
			
		}else{
			
			$this->db->insert('settings_property_type', $data);			
			$insert_id = $this->db->insert_id();
			
			$seo['itemId']=$insert_id;
			$seo['slug']=$data['slug'];
			$seo['table']='types';
			$this->db->insert('site_seo', $seo);	
		}
	}
/*########################################################################################*/
/*######################################### General END ################################*/
/*######################################################################################*/

public function set_page_seo($data,$id){
		
			$this->db->where('itemId', $id);
			$this->db->update('site_seo', $data);

			$this->db->where('typeId', $id);
			$this->db->update('settings_property_type', array('slug'=>$data['slug']));	
	}
		
		public function get_page_seo($id){
		$this->db->select('*');
		$where = array('itemId='=>$id,'table='=>'types');
		$this->db->where($where);
		$query = $this->db->get('site_seo');		
		return $query->result();
	}
	

}

?>