File: /var/www/html/nt/application/models/admin/Mproperty.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mproperty extends CI_Model {
public function __construct() {
parent::__construct();
}
public function get_property_type($condn = null){
$this->db->select('property_types.*');
$this->db->from('property_types');
$this->db->where('is_active', 1);
$this->db->order_by("property_type_name","ASC");
$query = $this->db->get();
//echo $this->db->last_query(); die;
return $query->result_array();
}
public function get_property_terrain($condn = null){
$this->db->select('terrain_master.*');
$this->db->from('terrain_master');
$this->db->where($condn);
$query = $this->db->get();
return $query->result_array();
}
public function get_property_state($condn = null){
$this->db->select('state_master.*');
$this->db->from('state_master');
$this->db->where($condn);
$this->db->order_by('state_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_property_district($condn = null){
$this->db->select('district_master.*');
$this->db->from('district_master');
$this->db->where($condn);
$this->db->order_by('district_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
/*public function get_property_unit($condn = null){
$this->db->select('property_unit_master.*');
$this->db->from('property_unit_master');
$this->db->where($condn);
$this->db->where('property_unit_master.is_active != ', '2');
$this->db->order_by('unit_name', 'ASC');
$query = $this->db->get();
//echo $this->db->last_query(); die;
return $query->result_array();
}*/
public function get_property_facility($condn = null){
$this->db->select('facility_master.*');
$this->db->from('facility_master');
$this->db->where($condn);
$this->db->order_by('facility_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_property($where = array()){
$this->db->select('property_master.*, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name,ifnull(property_types.is_hall,0) as is_hall,property_types.property_type_name');
$this->db->from('property_master');
//$this->db->join('state_master', 'property_master.state_id = state_master.state_id', 'LEFT');
//$this->db->join('district_master', 'property_master.district_id = district_master.district_id', 'LEFT');
$this->db->join('property_unit_list_view', 'property_unit_list_view.id = property_master.property_unit_master_id', 'INNER');
$this->db->join('property_types', 'property_master.property_type_id = property_types.id', 'LEFT');
if(!empty($where)){
$this->db->where($where);
}
$this->db->order_by('property_id', 'DESC');
$query = $this->db->get();
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function submit_property($data){
$this->db->insert('property_master', $data);
return $this->db->insert_id();
}
public function property_attributemap($getArray) {
$sql = $this->db->insert_batch('property_attribute_detail', $getArray);
if($sql){
return true;
}
}
public function edit_property($property_id){
$this->db->select('property_master.*, lv.*');
$this->db->from('property_master');
$this->db->join('property_unit_list_view lv', 'property_master.property_unit_master_id = lv.id', 'LEFT OUTER');
$this->db->where('property_id',$property_id);
$query = $this->db->get();
return $query->row_array();
}
public function update_property($condition, $data){
$result=$this->db->update('property_master', $data, $condition);
return $result;
}
public function delete_property($condition,$data){
$result=$this->db->update('property_master', $data, $condition);
return $result;
}
public function get_property_details_by_sp($property_id ='', $start_date='', $end_date ='')
{
$query = $this->db->query("call get_property_available_accomm($property_id, '$start_date', '$end_date', 0, 0, 1)");
return $query->result();
}
public function get_user_property_details($user_id) {
/*$stored_procedure = "CALL get_user_property_details(?,0);";
$data = array('p_user_id' => $user_id);
$result = $this->db->query($stored_procedure, $data);
if ($result !== NULL) {
$response = $result->result_array();
$result->free_result();
mysqli_next_result( $this->db->conn_id);
return $response;
}
return FALSE;*/
//echo $user_id; die;
$this->db->select('property_master.*, district_name as district, state_name as state,ifnull(property_types.is_hall,0) as is_hall,property_types.property_type_name');
$this->db->from('property_master');
$this->db->join('state_master', 'property_master.state_id = state_master.state_id', 'LEFT');
$this->db->join('district_master', 'property_master.district_id = district_master.district_id', 'LEFT');
$this->db->join('property_types', 'property_master.property_type_id = property_types.id', 'LEFT');
$this->db->where('property_master.created_by', $user_id);
$this->db->order_by('property_id', 'DESC');
$query = $this->db->get();
return $query->result_array();
}
public function get_user_property_details1($where = array(), $property_unit_master_id){
$this->db->select('property_master.*, district_name as district, state_name as state,ifnull(property_types.is_hall,0) as is_hall,property_types.property_type_name');
$this->db->from('property_master');
$this->db->join('state_master', 'property_master.state_id = state_master.state_id', 'LEFT');
$this->db->join('district_master', 'property_master.district_id = district_master.district_id', 'LEFT');
$this->db->join('property_types', 'property_master.property_type_id = property_types.id', 'LEFT');
$this->db->where('property_master.property_unit_master_id', $property_unit_master_id);
if(!empty($where)){
$this->db->where($where);
}
$this->db->order_by('property_id', 'DESC');
$query = $this->db->get();
//echo nl2br($this->db->last_query()); die();
return $query->result_array();
}
public function get_propertyattribute($getType) {
$result = array();
$sql = "SELECT a.*, b.* FROM attribute_master a INNER JOIN property_attribute_mapping b ON a.attribute_id = b.attribute_id WHERE b.property_type_id = ".$getType." AND a.attribute_type in ('P','B')";
$query = $this->db->query($sql);
$rows = $query->result_array();
$i = 0;
foreach($rows as $row){
$sql1 = "SELECT * FROM attribute_master_static WHERE attribute_id = ".$row['attribute_id']."";
$query1 = $this->db->query($sql1);
$rows1 = $query1->result_array();
$result[$i] = $row;
$result[$i]['attribute_static'] = $rows1;
$i++;
}
//echo "<pre>"; print_r($result); die;
if($result){
return $result;
} else {
return false;
}
}
public function get_propertylist($getType, $getunitId) {
$sql = "SELECT A.*
FROM property_master AS A
LEFT JOIN agreement AS B
ON A.property_id = B.property_id
WHERE B.property_id IS NULL
AND A.property_unit_master_id = ".$getunitId."
AND A.property_type_id = ".$getType."
AND A.self_managed = 'no' ";
$query = $this->db->query($sql);
$rows = $query->result_array();
if($rows){
return $rows;
} else {
return false;
}
}
public function property_type_attribute($property_id) {
$result = array();
$sql = "SELECT a.*, b.* FROM property_attribute_detail a INNER JOIN attribute_master b ON a.attribute_id = b.attribute_id WHERE a.property_id = ".$property_id."";
$query = $this->db->query($sql);
$rows = $query->result_array();
$i = 0;
foreach($rows as $row){
$sql1 = "SELECT * FROM attribute_master_static WHERE attribute_id = ".$row['attribute_id']."";
$query1 = $this->db->query($sql1);
$rows1 = $query1->result_array();
$result[$i] = $row;
$result[$i]['attribute_static'] = $rows1;
$i++;
}
//echo "<pre>"; print_r($result); die;
if($result){
return $result;
} else {
return false;
}
}
public function property_attributedelete($property_id) {
$sql = "DELETE FROM property_attribute_detail WHERE property_id = ".$property_id."";
$query = $this->db->query($sql);
return true;
}
public function getPaymentDetails($unit_id = '', $start_date, $end_date, $property_unit_master_id = ''){
$condition = "";
if($unit_id) {
$condition = " AND payment_collection.property_unit_master_id = '".$unit_id."'";
}
if($start_date && $end_date) {
$condition .= " AND payment_collection.payment_date BETWEEN '".$start_date."' AND '".$end_date."'";
}
if($property_unit_master_id) {
$condition = " AND payment_collection.property_unit_master_id = '".$property_unit_master_id."'";
}
$sql = "SELECT payment_collection.*, property_types.property_type_name, property_master.property_name, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name FROM payment_collection
INNER JOIN property_types ON property_types.id = payment_collection.property_type_id
INNER JOIN property_master ON property_master.property_id = payment_collection.asset_id
INNER JOIN property_unit_list_view ON property_unit_list_view.id = payment_collection.property_unit_master_id
WHERE payment_collection.status = '0' ".$condition."
order by payment_collection.payment_collection_id DESC";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getBankDetails(){
$sql = "SELECT bank_account_master.*, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name FROM bank_account_master
INNER JOIN property_unit_list_view ON property_unit_list_view.id = bank_account_master.property_unit_master_id
WHERE bank_account_master.status = '0'
order by bank_account_master.account_master_id DESC";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getShopDetails() {
$sql = "SELECT shop_master.*, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name FROM shop_master
INNER JOIN property_unit_list_view ON property_unit_list_view.id = shop_master.property_unit_master_id
WHERE shop_master.status = '0'
order by shop_master.shop_id DESC";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getShopDetailsByUserId($property_unit_master_id) {
$sql = "SELECT shop_master.*, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name FROM shop_master
INNER JOIN property_unit_list_view ON property_unit_list_view.id = shop_master.property_unit_master_id
WHERE shop_master.status = '0' AND shop_master.property_unit_master_id = '{$property_unit_master_id}'
order by shop_master.shop_id DESC";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getBankDetailsByUserId($property_unit_master_id) {
$sql = "SELECT bank_account_master.*, property_unit_list_view.zilla_name, property_unit_list_view.panchayet_name, property_unit_list_view.gram_name FROM bank_account_master
INNER JOIN property_unit_list_view ON property_unit_list_view.id = bank_account_master.property_unit_master_id
WHERE bank_account_master.status = '0' AND bank_account_master.property_unit_master_id = '{$property_unit_master_id}'
order by bank_account_master.account_master_id DESC";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getPropertyTypeByUnitMaster($property_unit_master_id) {
$sql = "SELECT property_master.property_type_id,property_types.property_type_name FROM property_master
INNER JOIN property_types ON property_types.id = property_master.property_type_id
WHERE property_master.property_unit_master_id = '".$property_unit_master_id."' GROUP BY property_master.property_type_id";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function getCollectionDetails($payment_collection_id){
$sql = "SELECT payment_collection_details.*, payment_collection.total_amount, payment_collection.bank_upi_ref_num, payment_collection.bank_cash_ref_num, payment_collection.cheque_no, payment_collection.cheque_date, payment_collection.cheque_bank_name, payment_collection.edc_terminal, payment_collection.payment_mode, payment_collection_purpose_master.purpose_title FROM payment_collection_details
INNER JOIN payment_collection ON payment_collection.payment_collection_id = payment_collection_details.payment_collection_id
INNER JOIN payment_collection_purpose_master ON payment_collection_purpose_master.purpose_id = payment_collection_details.collection_purpose_id
WHERE payment_collection_details.payment_collection_id = '".$payment_collection_id."'";
$query = $this->db->query($sql);
//echo $this->db->last_query(); die();
return $query->result_array();
}
public function get_attribute_static_data($condn = null){
$this->db->select('attribute_master_static.*');
$this->db->from('attribute_master_static');
$this->db->where($condn);
$query = $this->db->get();
//echo $this->db->last_query(); die;
return $query->row_array();
}
public function get_attribute_static_value_data($condn = null){
$this->db->select('attribute_master_static_value.*');
$this->db->from('attribute_master_static_value');
$this->db->where($condn);
$this->db->order_by('attribute_type_name', 'ASC');
$query = $this->db->get();
//echo $this->db->last_query(); die;
return $query->result_array();
}
public function get_attribute_static_value_data_wise($condn = null){
$this->db->select('attribute_master_static_value.*');
$this->db->from('attribute_master_static_value');
$this->db->where($condn);
$query = $this->db->get();
//echo $this->db->last_query(); die;
return $query->row_array();
}
}