From 55d3ac65f97b3680b8c2f6a0f58fc311cfb2e2e4 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Thu, 22 Aug 2019 14:59:53 +0530 Subject: [PATCH] GET LENDER LIST API --- api/application/controllers/PD_Controller.php | 4 +++- api/application/models/PD_Model.php | 18 ++++++++++++++++++ api/index.php | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index d3f7964c..e060876d 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -8347,6 +8347,8 @@ class PD_Controller extends REST_Controller { public function getLenderContactPersons_post() { $records = $this->post('records'); - print_r($records); + + $lender_contact_persons = $this->PD_Model->getLenderContactPersons($records['fk_lender_id'],$records['pd_branch_id']); + print_r($lender_contact_persons); } } \ No newline at end of file diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 8aa008bb..d4b03f9e 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1844,5 +1844,23 @@ class PD_Model extends SPARQ_Model { // $this->db->LIMIT($limit,$page); return $result_array = $this->db->GET()->result_array(); } + + function getLenderContactPersons($lender_id,$pd_branch_id) + { + $this->db->select('USERPROFILE.userid, concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name,USERPROFILE.fk_entity_id,USERPROFILE.fk_city,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id,ROLES.role_name,if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); + $this->db->from(USERPROFILE.' as USERPROFILE'); + $this->db->join(ENTITYLENDERBRANCH.' as ENTITYLENDERBRANCH',"USERPROFILE.fk_entity_id = ENTITYLENDERBRANCH.fk_entity_id and ENTITYLENDERBRANCH.isactive = 1 and ENTITYLENDERBRANCH.fk_city_id = USERPROFILE.fk_city and ENTITYLENDERBRANCH.entity_lender_branch_id = $pd_branch_id"); + //$this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1','LEFT'); + //$this->db->join(CITY.' as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1','LEFT'); + // $this->db->join(CITY.' as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1','LEFT'); + $this->db->join(USERPROFILEROLES. ' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1'); + $this->db->join(ROLES.' as ROLES','ROLES.role_id = USERPROFILEROLES.user_role'); + //$this->db->where('USERPROFILE.fk_city',$pd_branch_id); + $this->db->where('USERPROFILE.fk_entity_id',$lender_id); + $this->db->where('USERPROFILE.isactive',1); + $result = $this->db->get()->result_array(); + //print_r($this->db->last_query()); + return $result; + } } \ No newline at end of file diff --git a/api/index.php b/api/index.php index eb3f8ae3..3a812d16 100644 --- a/api/index.php +++ b/api/index.php @@ -67,9 +67,9 @@ { define('ENVIRONMENT','sparqprod'); } - else + else if(isset($_SERVER['HTTP_HOST']) && !strcasecmp($_SERVER['HTTP_HOST'],'localhost') && isset($_SERVER['REQUEST_URI']) && substr_count($_SERVER['REQUEST_URI'], 'sparqapi') == 1) { - define('ENVIRONMENT','development'); + define('ENVIRONMENT','testing'); }