HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/nt/application/models/admin/Mdemand.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Mdemand extends CI_Model {

    public function __construct() {
        parent::__construct();

    }
	
	public function getAgreementDetails($where = array()){
        $this->db->select('ag.agreement_id, ag.allotment_id, ag.lessee_id, ag.agreement_number, ag.agreement_duration, ag.agreement_start_date, ag.agreement_end_date, ag.lease_rent_per_unit, ag.increment_lease_rent, ag.increment_percentage, ag.increment_interval, ag.interest_percentage_if_not_paid, ag.existing_agreement_number, ag.existing_agreement_date, ag.existing_opening_balance, ag.opening_balance_date, ag.agreement_remarks, ag.security_deposit, ag.advance_amount, ag.lumpsum_deposit, ag.last_payment_fy, ag.type, ag.is_active, ag.is_terminated, ag.termination_date, ag.terminated_remarks, ag.created_by, ag.created_at, ag.updated_by, ag.updated_at, a.allotment_id, a.industrial_park_id, a.property_type, a.plot_module_id, a.lessee_id, a.agreement_type, a.application_date, a.application_money, a.app_money_payment_mode, a.allotment_date, a.allotment_money, a.cgst_percent, a.sgst_percent, a.gst_percent, a.cgst_amt, a.sgst_amt, a.gst_amt, a.payable_amount, a.txnid, a.order_id, a.payment_status, b.park_name, IF(a.property_type = "Plot",c.plot_ref_no,d.module_ref_no) AS ref_no, IF(a.property_type = "Plot",c.total_area,d.total_area) AS total_area, IF(a.property_type = "Plot",c.uom_id,d.uom_id) AS uom_id, e.register_lessee_type, e.name, e.address, e.gst_no, e.primary_contact_person, e.primary_designation, e.primary_email, e.primary_contact_no1, e.primary_contact_no2, e.secondary_contact_person, e.secondary_designation, e.secondary_email, e.secondary_contact_no1, e.secondary_contact_no2, h.payment_date, h.payment_mode, h.status');
        $this->db->from('agreement ag');
		$this->db->join('allotment a', 'ag.allotment_id = a.allotment_id', 'LEFT');
		$this->db->join('industrial_park_master b', 'a.industrial_park_id = b.industrial_park_id', 'LEFT');
		$this->db->join('plot_header c', 'a.plot_module_id = c.plot_header_id', 'LEFT');
		$this->db->join('module_master d', 'a.plot_module_id = d.module_id', 'LEFT');
		$this->db->join('register_lease_master e', 'a.lessee_id = e.register_lessee_id', 'LEFT');
		$this->db->join('allotment_payment_info h', 'a.allotment_id = h.allotment_id', 'LEFT');
        if(!empty($where)){
            $this->db->where($where);
        }
        $query=$this->db->get();
		//echo $this->db->last_query();die;
        return $query->row_array();
    }
	
	public function getTaxDetail()
	{
		$sql = "SELECT a.tax_id, a.tax_name, a.tax_percentage, a.cgst_percentage, a.sgst_percentage, a.eff_start_date, a.eff_end_date, a.is_active, a.created_by, a.created_at, a.updated_by, a.updated_at FROM tax_master a
				WHERE a.is_active = 1
				AND IF(a.eff_end_date != '0000-00-00', a.eff_end_date >= CURDATE(), a.eff_end_date < CURDATE()) ";
				
		$query = $this->db->query($sql);
		//echo $this->db->last_query(); die;
        return $query->row_array();
	}
	
	public function getDemandDetails($where = array()){
        $this->db->select('a.demand_id, a.schedule_id, a.agreement_id, a.lessee_id, a.notice_number, a.notice_date, a.schedule_from_date, a.schedule_to_date, a.schedule_amount, a.schedule_due_date, a.rent_per_unit_after_increment, a.balance_bf, a.penalty_amount, a.cgst_rate, a.cgst_amount, a.sgst_rate, a.sgst_amount, a.gst_rate, a.gst_amount, a.net_payable_amount, a.is_publish, a.is_active, a.created_at, a.published_by, a.updated_at, a.remarks, a.demand_type, a.payment_status, a.order_id, a.txnid,  e.register_lessee_type, e.name, e.address, e.gst_no, e.primary_contact_person, e.primary_designation, e.primary_email, e.primary_contact_no1, e.primary_contact_no2, e.secondary_contact_person, e.secondary_designation, e.secondary_email, e.secondary_contact_no1, e.secondary_contact_no2, ag.allotment_id, ag.agreement_start_date, ag.interest_percentage_if_not_paid, at.allotment_date, b.park_name, IF(at.property_type = "Plot",c.plot_ref_no,d.module_ref_no) AS ref_no, IF(at.property_type = "Plot",c.total_area,d.total_area) AS total_area, IF(at.property_type = "Plot",c.uom_id,d.uom_id) AS uom_id');
        $this->db->from('agreement_demand a');
		$this->db->join('register_lease_master e', 'a.lessee_id = e.register_lessee_id', 'LEFT');
		$this->db->join('agreement ag', 'a.agreement_id = ag.agreement_id', 'INNER');
		$this->db->join('allotment at', 'ag.allotment_id = at.allotment_id', 'INNER');
		$this->db->join('industrial_park_master b', 'at.industrial_park_id = b.industrial_park_id', 'INNER');
		$this->db->join('plot_header c', 'at.plot_module_id = c.plot_header_id', 'LEFT');
		$this->db->join('module_master d', 'at.plot_module_id = d.module_id', 'LEFT');
        if(!empty($where)){
            $this->db->where($where);
        }
        $query=$this->db->get();
		//echo $this->db->last_query();die;
        return $query->row_array();
    }
	
	public function get_previous_demand($demand_id = 0)
	{
		$sql = "SELECT MAX(demand_id) AS previous_demand_id FROM agreement_demand WHERE demand_id < $demand_id ";
		$query = $this->db->query($sql);
		//echo $this->db->last_query(); die;
        $row = $query->row_array();
		return $row['previous_demand_id'];
	}

}