diff --git a/api/application/config/constants.php b/api/application/config/constants.php index a5ec60a0..bd6e88e3 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -86,7 +86,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto // define login route name for token verification //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getFullPDDetails'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'triggerNewPD'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/controllers/Common_Masters_Controller.php b/api/application/controllers/Common_Masters_Controller.php index b3a6b8ff..c77a1e04 100644 --- a/api/application/controllers/Common_Masters_Controller.php +++ b/api/application/controllers/Common_Masters_Controller.php @@ -487,12 +487,18 @@ class Common_Masters_Controller extends REST_Controller { /* End Of Get PD Team Details (Master Table info)*/ /* For Get PD Team Mapping Details (Child Table info)*/ - public function getListOfPDTeamMap_post(){ - - $PK = $this->post('primary_key'); + public function getListOfPDTeamMap_post(){ + if(!empty($this->post())){ + $PK = $this->post('primary_key'); + } + else{ + $PK = ''; + } + $columns = array('m_city.name as city_name', - 'm_entities.full_name as lender_name', + 'm_entities.full_name as lender_name', + 'm_pdteam.team_name as team_name', 'PDTEAMMAP.pdteam_map_id as pdteam_map_id', 'PDTEAMMAP.fk_city_id as fk_city_id', 'PDTEAMMAP.fk_team_id as fk_team_id', @@ -510,12 +516,22 @@ class Common_Masters_Controller extends REST_Controller { 'table' => 'm_entities', 'condition' => 'PDTEAMMAP.fk_lender_id = m_entities.entity_id', 'jointype' => 'INNER' + ), + array( + 'table' => 'm_pdteam', + 'condition' => 'PDTEAMMAP.fk_team_id = m_pdteam.pdteam_id', + 'jointype' => 'INNER' ) ); - $where_condition_array = array('PDTEAMMAP.fk_team_id'=> $PK); - - $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); - + if($PK != '') + { + $where_condition_array = array('PDTEAMMAP.fk_team_id'=> $PK); + $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + } + else{ + $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); + } + if(count($result) > 0) { $data['dataStatus'] = true; @@ -533,6 +549,8 @@ class Common_Masters_Controller extends REST_Controller { } /* End of Get PD Team Mapping Details (Child Table info)*/ + + /** * Company File Upload diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 9a6d68e1..2dd192d0 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -180,17 +180,18 @@ class PD_Controller extends REST_Controller { */ public function triggerNewPD_post() { + + $pd_details = json_decode($this->post('pd_details'),true); $pd_applicant_details = json_decode($this->post('pd_applicant_details'),true); - $pd_document_titles = json_decode($this->post('pd_document_titles'),true); + $pd_document_titles = ""; + if($this->post('pd_document_titles')){ json_decode($this->post('pd_document_titles'),true); } $pd_documents = array(); - if(!empty($_FILES['pddocuments'])) - { - - } + $count = 0; /***********************CHOOSE PD TEMPALATE*********************/ + $fields = array('fk_template_id'); $where_condition_array = array('fk_lender_id'=>1 ,'fk_product_id'=> 1,'fk_customer_segment'=> 1,'isactive' => 1); @@ -207,6 +208,7 @@ class PD_Controller extends REST_Controller { /***********************PD ALLOCATION TYPE PROCESS **********/ + $pd_details['fk_pd_allocated_to'] = TRIGGERED; $pd_details['fk_pd_allocated_to'] = null; $where_condition_array = array('fk_city_id' => $pd_details['fk_city'],'fk_lender_id' => $pd_details['fk_lender_id']); $temp_city_id = $this->PD_Model->selectRecords(PDTEAMMAP,$where_condition_array,$limit=0,$offset=0); @@ -272,13 +274,13 @@ class PD_Controller extends REST_Controller { /***********************PD DOCUMENTS UPLOAD SECTION ***********/ if($pd_id != null || $pd_id != '') { - if(!empty($_FILES['pddocuments'])) + if(!empty($_FILES['pddocuments']) && !empty($pd_document_titles)) { - foreach($_FILES['pddocuments'] as $key => $file) + foreach($pd_document_titles as $iter => $title) { - $tempdoc = $file['pddocuments']['tmp_name']; - $tempdocname = $file['pddocuments']['name']; + $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; + $tempdocname = $_FILES['pddocuments']['name'][$iter]; $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details['fk_lender_id']; $key = 'pd'.$pd_id.'/'.$tempdocname ; $sourcefile = $tempdoc; @@ -288,7 +290,7 @@ class PD_Controller extends REST_Controller { if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$pd_document_titles[$key],'pd_document_name'=>$tempdocname); + $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title[$pd_document_title],'pd_document_name'=>$tempdocname); $this->saveRecords($record_data,PDDOCUMENTS); } @@ -372,7 +374,7 @@ class PD_Controller extends REST_Controller { $pd_applicant_details = $this->post('pd_applicant_details'); $count = 0; $pd_id = 0; - + //print_r($this->post());die(); foreach($pd_applicant_details as $pd_applicant_detail) { if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "") @@ -388,7 +390,7 @@ class PD_Controller extends REST_Controller { else { $pd_applicant_detail['fk_pd_id'] = $pd_id; - $co_applicant_id = $this->PD_Model->saveRecords(PDAPPLICANTSDETAILS,$pd_applicant_detail); + $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); if($co_applicant_id != null || $co_applicant_id != '') { $count = $count + 1; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 2c2aa442..4cd95329 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -15,20 +15,20 @@ class PD_Model extends SPARQ_Model { { $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.fk_pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id'); - $this->db->JOIN(PRODUCTS.' as PRODUCTS','PDTRIGGER.fk_product_id = PRODUCTS.product_id'); - $this->db->JOIN(SUBPRODUCTS.' as SUBPRODUCTS','PDTRIGGER.fk_subproduct_id = SUBPRODUCTS.subproduct_id'); - $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id'); + $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); + $this->db->JOIN(PRODUCTS.' as PRODUCTS','PDTRIGGER.fk_product_id = PRODUCTS.product_id','LEFT'); + $this->db->JOIN(SUBPRODUCTS.' as SUBPRODUCTS','PDTRIGGER.fk_subproduct_id = SUBPRODUCTS.subproduct_id','LEFT'); + $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id','LEFT'); $this->db->JOIN(PDSTATUS.' as PDSTATUS','PDTRIGGER.fk_pd_status = PDSTATUS.pd_status_id','LEFT'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE','PDTRIGGER.fk_createdby = USERPROFILE.userid'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE','PDTRIGGER.fk_createdby = USERPROFILE.userid','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE1','PDTRIGGER.fk_updatedby = USERPROFILE1.userid','LEFT'); - $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDTRIGGER.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id'); + $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDTRIGGER.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDTRIGGER.fk_pd_allocated_to = USERPROFILE2.userid','LEFT'); $this->db->JOIN(TEMPLATE.' as TEMPLATE','PDTRIGGER.fk_pd_template_id = TEMPLATE.template_id','LEFT'); - $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDTRIGGER.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id'); + $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDTRIGGER.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id','LEFT'); $this->db->JOIN(ENTITY.' as AGENCY','PDTRIGGER.pd_agency_id = AGENCY.entity_id','LEFT'); - $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id '); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id'); + $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT'); + $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT'); $this->db->ORDER_BY('PDTRIGGER.pd_id',$sort); $this->db->LIMIT($limit,$page); $result_array = $this->db->GET()->result_array();