From 42d0875b4f498558f64f54c29fd6ce5381f0cfc6 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 3 Oct 2018 12:48:36 +0530 Subject: [PATCH] PD UPDATED --- api/application/config/constants.php | 10 +- api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 56 ++++++++++ .../User_Management_Controller.php | 6 +- api/application/libraries/SPARQ_Model.php | 2 +- .../models/Entity_Management_Model.php | 20 ++-- api/application/models/PD_Model.php | 100 ++++++++++++++++++ 7 files changed, 179 insertions(+), 16 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 45e7b8d0..c84d2813 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -85,8 +85,8 @@ defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automat defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code // 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', '(listAllQuestions/:any)'); // no errors +//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getFullPDDetails'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); @@ -257,5 +257,11 @@ defined('PDNOTIFICATIONID') OR define('PDNOTIFICATIONID','pdnotification_id'); defined('PDDOCUMENTS') OR define('PDDOCUMENTS','t_pd_documents'); defined('PDDOCUMENTSID') OR define('PDDOCUMENTSID','pd_document_id'); +defined('PDLOGS') OR define('PDLOGS','h_pd_triggered'); +defined('PDLOGSID') OR define('PDLOGSID','pd_trigger_id'); + +defined('PDAPPLICANTSLOGS') OR define('PDAPPLICANTSLOGS','h_pd_co_applicants_details'); +defined('PDAPPLICANTSLOGSID') OR define('PDAPPLICANTSLOGSID','pd_co_applicant_trigger_id'); + diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 620d1a77..3c1a8543 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -111,4 +111,5 @@ $route['getListOfLenders'] = 'PD_Controller/getListOfLenders'; $route['getListOfCustomerSegments'] = 'PD_Controller/getListOfCustomerSegments'; $route['getListOfPDAllocationTypes'] = 'PD_Controller/getListOfPDAllocationTypes'; $route['getListOfStatesAndCities'] = 'PD_Controller/getListOfStatesAndCities'; +$route['getFullPDDetails'] = 'PD_Controller/getFullPDDetails'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 35234721..5fe8355a 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -404,6 +404,62 @@ class PD_Controller extends REST_Controller { } + /* + * Get Full PD Details like all applicant's details, all PD related documents, PD Template and + * answersd questions,PD History details. + */ + public function getFullPDDetails_post() + { + $pdid = $this->post('pdid'); + + // Get All Applicant's Details + $result_data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); + + // Get All PD Related Documents + $result_data['pd_documnets'] = $this->PD_Model->getSignedPDDocsURL($pdid); + + //Get All PD Template and It's Question with Answers + //$result_data['pd_question_answer'] = $this->getPDQuestionAnswer($pdid); + + //Get All PD Logs + $result_data['pd_logs'] = $this->PD_Model->getPDLogs($pdid); + + $applicant_msg = ''; + $pd_docs_msg = ''; + $pd_question_answer_msg = ''; + $pd_logs_msg = ''; + + if(!count($result_data['applicants_details'])) + { + $applicant_msg = 'Applicant Details Not Found'; + } + + if(!count($result_data['pd_documnets'])) + { + $pd_docs_msg = 'Documents Not Found'; + } + + // if(!count($result_data['pd_question_answer'])) + // { + // $pd_question_answer_msg = 'PD Details Not Found'; + // } + + if(!count($result_data['pd_logs'])) + { + $pd_logs_msg = 'PD Logs Not Found'; + } + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $data['msg'] = array('applicant_msg'=>$applicant_msg,'pd_docs_msg'=>$pd_docs_msg,'pd_question_answer_msg'=>$pd_question_answer_msg,'pd_logs_msg'=>$pd_logs_msg); + $this->response($data,REST_Controller::HTTP_OK); + + + } + + diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index 1484a76b..813ab381 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -39,7 +39,7 @@ class User_Management_Controller extends REST_Controller { { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_NO_CONTENT); + $this->response($data,REST_Controller::HTTP_OK); } } @@ -147,7 +147,7 @@ class User_Management_Controller extends REST_Controller { { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + $this->response($data,REST_Controller::HTTP_OK); } } @@ -269,7 +269,7 @@ class User_Management_Controller extends REST_Controller { { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + $this->response($data,REST_Controller::HTTP_OK); } } diff --git a/api/application/libraries/SPARQ_Model.php b/api/application/libraries/SPARQ_Model.php index d4ea0233..dbcf18e1 100644 --- a/api/application/libraries/SPARQ_Model.php +++ b/api/application/libraries/SPARQ_Model.php @@ -25,7 +25,7 @@ class SPARQ_Model extends CI_Model { } - public function selectRecords($table_name,$where_condition_array = array(),$limit = 50,$offset = 0,$order = 'ASC',$order_by_colum_name = '',$print_query = '') + public function selectRecords($table_name,$where_condition_array = array(),$limit = 1000000,$offset = 0,$order = 'ASC',$order_by_colum_name = '',$print_query = '') { $data = $this->db->order_by($order_by_colum_name,$order)->get_where($table_name,$where_condition_array,$limit,$offset)->result_array();//only AND condition if($print_query == '1') diff --git a/api/application/models/Entity_Management_Model.php b/api/application/models/Entity_Management_Model.php index c1750f34..e6b9167a 100644 --- a/api/application/models/Entity_Management_Model.php +++ b/api/application/models/Entity_Management_Model.php @@ -16,13 +16,13 @@ class Entity_Management_Model extends SPARQ_Model { $this->db->SELECT('ENTITY.entity_id, ENTITY.full_name, ENTITY.short_name, ENTITY.fk_region,REGIONS.name as region_name, ENTITY.fk_state,STATE.name as state_name, ENTITY.fk_city,CITY.name as city_name, ENTITY.fk_branch,BRANCH.name as branch_name, ENTITY.addressline1, ENTITY.addressline2, ENTITY.official_email, ENTITY.alt_email, ENTITY.phone_number, ENTITY.mobile_no, ENTITY.remarks, ENTITY.createdon, ENTITY.fk_createdby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby, ENTITY.updatedon, ENTITY.fk_updatedby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, ENTITY.isactive, ENTITY.pan, ENTITY.gst_no, ENTITY.gst_state_code, addressline3, ENTITY.tat, ENTITY.fk_entity_type_id,ENTITYTYPE.name as entity_name'); $this->db->FROM(ENTITY.' as ENTITY'); - $this->db->JOIN(REGIONS.' as REGIONS','ENTITY.fk_region = REGIONS.region_id AND REGIONS.isactive = 1'); - $this->db->JOIN(STATE.' as STATE','ENTITY.fk_state = STATE.state_id AND STATE.isactive = 1'); - $this->db->JOIN(CITY.' as CITY','ENTITY.fk_city = CITY.city_id AND CITY.isactive = 1'); - $this->db->JOIN(BRANCH.' as BRANCH','ENTITY.fk_branch = BRANCH.branch_id AND BRANCH.isactive = 1'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE','ENTITY.fk_createdby = USERPROFILE.userid AND USERPROFILE.isactive = 1'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE1','ENTITY.fk_updatedby = USERPROFILE1.userid AND USERPROFILE1.isactive = 1'); - $this->db->JOIN(ENTITYTYPE.' as ENTITYTYPE','ENTITY.fk_entity_type_id = ENTITYTYPE.entity_type_id AND ENTITYTYPE.isactive = 1'); + $this->db->JOIN(REGIONS.' as REGIONS','ENTITY.fk_region = REGIONS.region_id'); + $this->db->JOIN(STATE.' as STATE','ENTITY.fk_state = STATE.state_id'); + $this->db->JOIN(CITY.' as CITY','ENTITY.fk_city = CITY.city_id'); + $this->db->JOIN(BRANCH.' as BRANCH','ENTITY.fk_branch = BRANCH.branch_id '); + $this->db->JOIN(USERPROFILE.' as USERPROFILE','ENTITY.fk_createdby = USERPROFILE.userid'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE1','ENTITY.fk_updatedby = USERPROFILE1.userid','LEFT'); + $this->db->JOIN(ENTITYTYPE.' as ENTITYTYPE','ENTITY.fk_entity_type_id = ENTITYTYPE.entity_type_id'); $result = $this->db->get()->result_array(); @@ -31,9 +31,9 @@ class Entity_Management_Model extends SPARQ_Model { { $this->db->SELECT('ENTITYCHILD.entity_child_id,ENTITYCHILD.contact_person,ENTITYCHILD.contact_email,ENTITYCHILD.contact_mobile_no,ENTITYCHILD.contact_person,ENTITYCHILD.isactive,ENTITYCHILD.createdon,ENTITYCHILD.fk_createdby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,ENTITYCHILD.updatedon,ENTITYCHILD.fk_updatedby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby'); $this->db->FROM(ENTITYCHILD.' as ENTITYCHILD'); - $this->db->JOIN(ENTITY.' as ENTITY','ENTITYCHILD.fk_entity_id = ENTITY.entity_id AND ENTITY.isactive = 1'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE','ENTITYCHILD.fk_createdby = USERPROFILE.userid AND USERPROFILE.isactive = 1'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE1','ENTITYCHILD.fk_updatedby = USERPROFILE1.userid AND USERPROFILE1.isactive = 1'); + $this->db->JOIN(ENTITY.' as ENTITY','ENTITYCHILD.fk_entity_id = ENTITY.entity_id'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE','ENTITYCHILD.fk_createdby = USERPROFILE.userid '); + $this->db->JOIN(USERPROFILE.' as USERPROFILE1','ENTITYCHILD.fk_updatedby = USERPROFILE1.userid','LEFT'); $this->db->where('ENTITY.entity_id',$r['entity_id']); $entity_child_data = $this->db->get()->result_array(); diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 7de281ce..43cd169b 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -7,6 +7,7 @@ class PD_Model extends SPARQ_Model { public function __construct() { parent::__construct(); + $this->load->library('AWS_S3'); } @@ -81,4 +82,103 @@ class PD_Model extends SPARQ_Model { $sql = 'UPDATE '.PDOFFICIERSDETAILS.' SET total = total+1, allocated = allocated+1 WHERE fk_user_id ='.$userid; $modified = $this->db->query($sql); } + + + /* + *Get All PD Related Documents as signed and expired URL's from S3 Buckets + */ + public function getSignedPDDocsURL($pdid) + { + $document_lists = array(); + if($pdid != '' || $pdid != null) + { + + + // Get lenderid of this pd by using pid + $lender_id = $this->selectCustomRecords(array('fk_lender_id'),array('pd_id' => $pdid),PDTRIGGER); + if(count($lender_id)) + { + //Get PD Documenttitle and name from DB + $document_lists = $this->selectRecords(PDDOCUMENTS,array('fk_pd_id' => $pdid)); + if(count($document_lists)) + { + + $bucket_name = 'lender'.$lender_id[0]['fk_lender_id']; + $profilepics3path = 'pd'.$pdid; + foreach($document_lists as $key => $value) + { + $profilepics3path .=$value['pd_document_name']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+30 minutes'); + $document_lists['doc_url'] = $singed_uri; + } + + } + + } + + } + + return $document_lists; + } + + + /* + *Get all Applicants details by pdid + */ + public function getApplicantsDetails($pdid) + { + $this->db->SELECT('PDAPPLICANTSDETAILS.pd_co_applicant_id, PDAPPLICANTSDETAILS.fk_pd_id, PDAPPLICANTSDETAILS.applicant_name, PDAPPLICANTSDETAILS.applicant_type, PDAPPLICANTSDETAILS.mobile_no, PDAPPLICANTSDETAILS.email, PDAPPLICANTSDETAILS.addressline1, PDAPPLICANTSDETAILS.addressline2, PDAPPLICANTSDETAILS.addressline3, PDAPPLICANTSDETAILS.fk_city, PDAPPLICANTSDETAILS.fk_state, PDAPPLICANTSDETAILS.pincode'); + $this->db->FROM(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS'); + $this->db->JOIN(STATE.' as STATE','PDAPPLICANTSDETAILS.fk_state = STATE.state_id'); + $this->db->JOIN(CITY.' as CITY','PDAPPLICANTSDETAILS.fk_city = CITY.city_id'); + $this->db->WHERE('PDAPPLICANTSDETAILS.fk_pd_id ',$pdid); + $result_child_array = $this->db->GET()->result_array(); + + if(count($result_child_array) != 0) + { + return $result_child_array; + } + else + { + return array(); + } + } + + + /* + * GET PD Log Details by pdid + */ + public function getPDLogs($pdid) + { + $this->db->SELECT('PDLOGS.pd_id, PDLOGS.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDLOGS.lender_applicant_id, DATE_FORMAT(PDLOGS.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDLOGS.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDLOGS.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDLOGS.fk_pd_type,PDTYPE.type_name as pd_type_name, PDLOGS.fk_pd_status,PDSTATUS.pd_status_name, PDLOGS.pd_specific_clarification, DATE_FORMAT(PDLOGS.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDLOGS.fk_createdby, DATE_FORMAT(PDLOGS.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDLOGS.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDLOGS.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDLOGS.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDLOGS.fk_pd_template_id,TEMPLATE.template_name, PDLOGS.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDLOGS.pd_officier_final_judgement, PDLOGS.pd_agency_id,AGENCY.full_name as agency_name, PDLOGS.loan_amount,PDLOGS.addressline1,PDLOGS.addressline2,PDLOGS.addressline3,PDLOGS.fk_city,CITY.name as city_name,PDLOGS.fk_state,STATE.name as state_name,PDLOGS.pincode'); + $this->db->FROM(PDLOGS.' as PDLOGS'); + $this->db->JOIN(ENTITY.' as ENTITY','PDLOGS.fk_lender_id = ENTITY.entity_id '); + $this->db->JOIN(PRODUCTS.' as PRODUCTS','PDLOGS.fk_product_id = PRODUCTS.product_id'); + $this->db->JOIN(SUBPRODUCTS.' as SUBPRODUCTS','PDLOGS.fk_subproduct_id = SUBPRODUCTS.subproduct_id'); + $this->db->JOIN(PDTYPE.' as PDTYPE','PDLOGS.fk_pd_type = PDTYPE.pd_type_id'); + $this->db->JOIN(PDSTATUS.' as PDSTATUS','PDLOGS.fk_pd_status = PDSTATUS.pd_status_id'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE','PDLOGS.fk_createdby = USERPROFILE.userid'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE1','PDLOGS.fk_updatedby = USERPROFILE1.userid','LEFT'); + $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDLOGS.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDLOGS.fk_pd_allocated_to = USERPROFILE2.userid'); + $this->db->JOIN(TEMPLATE.' as TEMPLATE','PDLOGS.fk_pd_template_id = TEMPLATE.template_id'); + $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDLOGS.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id'); + $this->db->JOIN(ENTITY.' as AGENCY','PDLOGS.pd_agency_id = AGENCY.entity_id','LEFT'); + $this->db->JOIN(STATE.' as STATE','PDLOGS.fk_state = STATE.state_id '); + $this->db->JOIN(CITY.' as CITY','PDLOGS.fk_city = CITY.city_id'); + $this->db->WHERE('PDLOGS.pd_id ',$pdid); + //$this->db->ORDER_BY('PDLOGS.pd_id',$sort); + //$this->db->LIMIT($limit,$page); + $result_array['pd_master_logs'] = $this->db->GET()->result_array(); + + + $this->db->SELECT('PDAPPLICANTSLOGS.pd_co_applicant_id, PDAPPLICANTSLOGS.fk_pd_id, PDAPPLICANTSLOGS.applicant_name, PDAPPLICANTSLOGS.applicant_type, PDAPPLICANTSLOGS.mobile_no, PDAPPLICANTSLOGS.email, PDAPPLICANTSLOGS.addressline1, PDAPPLICANTSLOGS.addressline2, PDAPPLICANTSLOGS.addressline3, PDAPPLICANTSLOGS.fk_city, PDAPPLICANTSLOGS.fk_state, PDAPPLICANTSLOGS.pincode'); + $this->db->FROM(PDAPPLICANTSLOGS.' as PDAPPLICANTSLOGS'); + $this->db->JOIN(STATE.' as STATE','PDAPPLICANTSLOGS.fk_state = STATE.state_id'); + $this->db->JOIN(CITY.' as CITY','PDAPPLICANTSLOGS.fk_city = CITY.city_id'); + $this->db->WHERE('PDAPPLICANTSLOGS.fk_pd_id ',$pdid); + $result_array['pd_applicants_logs'] = $this->db->GET()->result_array(); + + return $result_array; + } } \ No newline at end of file