From 9103f4ad0e7d0174514908668859d4bbcb2d02be Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Sat, 24 Aug 2019 17:06:59 +0530 Subject: [PATCH] LENDER PD LIST API CHANGED --- api/application/controllers/PD_Controller.php | 14 ++++++++++---- api/application/models/PD_Model.php | 9 +++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index f8d8a713..1ef659d6 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -1888,7 +1888,7 @@ public function assignPDTempalate($data) { //get role of lender_user_id` $user_role_details = $this->PD_Model->getLenderHierarchyForPDListing($lender_user_id); - //print_r($user_role_details); + //print_r($user_role_details);die(); if(count($user_role_details)) { $role_id = $user_role_details[0]['user_role']; @@ -1901,8 +1901,14 @@ public function assignPDTempalate($data) case 13:// Zonal Sales Head case 14:// Zonal Credit Head //Get all cities id's from m_entity_region_mapping table using region_id / zone id - $citiesInCurrentZone = $this->PD_Model->selectCustomRecords(array('fk_city_id'),ENTITYREGION,array('fk_region_id' => $user_role_details[0]['fk_region_id'])); + $temp_array = $this->PD_Model->selectCustomRecords(array('fk_city_id'),array('fk_region_id' => $user_role_details[0]['fk_region_id']),ENTITYREGION); //Get all PD's which were triggered in this entity id and city id's in current zone + //$citiesInCurrentZone = array(10,20); + $citiesInCurrentZone = array(); + if(count($temp_array)) + { + foreach ($temp_array as $key => $value) { $citiesInCurrentZone = array_merge($citiesInCurrentZone,array($value['fk_city_id'])); } + } return array('entity' => $user_role_details[0]['fk_entity_id'],'zone' => $citiesInCurrentZone); case 15://Area Sales Head case 16://Area Credit Head @@ -1914,8 +1920,8 @@ public function assignPDTempalate($data) return array('entity' => $user_role_details[0]['fk_entity_id'],'city' => $user_role_details[0]['fk_city']); case 17://Branch Sales case 18://Branch Credit - //Get all PD's which were triggered in this entity id and current branch - return array('entity' => $user_role_details[0]['fk_entity_id'],'branch' => $user_role_details[0]['entity_lender_branch_id']); + //Get all PD's which were triggered in this entity id and current lender user id + return array('entity' => $user_role_details[0]['fk_entity_id'],'lender_credit_person' => $lender_user_id); default: return array(); } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index e106ace3..ef86e448 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -53,8 +53,9 @@ class PD_Model extends SPARQ_Model { $this->db->WHERE('PDTRIGGER.fk_lender_id',$lender_details['entity']); } - if(isset($lender_details['zone'])) + if(isset($lender_details['zone']) && count($lender_details['zone'])) { + $this->db->WHERE_IN('PDTRIGGER.fk_city',$lender_details['zone']); } @@ -1918,16 +1919,16 @@ class PD_Model extends SPARQ_Model { function getLenderHierarchyForPDListing($lender_user_id) { - $this->db->select('USERPROFILE.userid, concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name,USERPROFILE.fk_entity_id,USERPROFILE.fk_city,USERPROFILE.fk_state,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id,ROLES.role_name,if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type,ENTITYREGION.fk_region_id,ENTITYLENDERBRANCH.entity_lender_branch_id'); + $this->db->select('USERPROFILE.userid, concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name,USERPROFILE.fk_entity_id,USERPROFILE.fk_city,USERPROFILE.fk_state,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id,ROLES.role_name,if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type,ENTITYREGION.fk_region_id'); $this->db->from(USERPROFILE.' as USERPROFILE'); $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->join(ENTITYREGION.' as ENTITYREGION','USERPROFILE.fk_city = ENTITYREGION.fk_city_id'); - $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"); + //$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"); $this->db->where('USERPROFILE.isactive',1); $this->db->where('USERPROFILE.userid',$lender_user_id); $result = $this->db->get()->result_array(); - //print_r($this->db->last_query()); + //print_r($this->db->last_query());die(); return $result; }