From 29252cc95d14ee61712ae1c238e5d0e74f0f24ad Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 13 Jul 2022 23:05:52 +0530 Subject: [PATCH] DigiLocker Coapplicant Related Changes : ps --- .../controllers/Flyhi_Controller.php | 34 +++++++++++++++---- .../helpers/digital_locker_helper.php | 20 ++++++++--- api/application/views/digital_locker.php | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index eddcd5ce..d99e171c 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2190,9 +2190,9 @@ class Flyhi_Controller extends REST_Controller { $this->load->helper('digital_locker'); // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; $code = $this->get('code'); - $state = $this->get('state'); - log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code); - $response_data = digital_locker::getAccessToken($code); + $co_applicant = $this->get('state'); + log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant : ".$co_applicant); + $response_data = digital_locker::getAccessToken($code,$co_applicant); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; @@ -2200,6 +2200,7 @@ class Flyhi_Controller extends REST_Controller { }else{ $view_data['list'] = json_decode($response_data['records'], true); $view_data['token']= $response_data['token']; + $view_data['pd_id']=$response_data['pd_id']; log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); $this->load->view("digital_locker",$view_data); @@ -2214,16 +2215,35 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post())); $form_data = $this->post(); $token = $form_data['token']; + $pd_id = $form_data['pd_id']; log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']); unset($form_data['token']); $reindexed_array = array_values($form_data); if(count($reindexed_array)>0){ for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); - $this->load->library('upload', $config); + // $folder_to_check = XLPATH.'/tmp'; + // $bytes = file_put_contents($folder_to_check, json_decode($reponse, true)); + // $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); + // $this->load->library('upload', $config); + $fields = array('pd_id','fk_lender_id'); + $where_condition_array = array('pd_id' => $pd_id); + $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; + $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; + + $tempdocname = "IDPROOF - ".$i+1; + $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; + $key = 'pd'.$pd_id.'/'.$tempdocname ; + $sourcefile = json_decode($reponse, true); + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>"DigiLocker Files (".$tempdocname.")",'pd_document_name'=>$tempdocname); + $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); + } log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse)); }} $data['dataStatus'] = true; diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index aaa9480d..ec12869c 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -6,9 +6,9 @@ class DIGITAL_LOCKER static $TOKEN_AS_GLOBAl = null; static public $myVAR = null; - public static function getAccessToken($code) + public static function getAccessToken($code,$applicant) { - log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code); + log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code." & applicant :".$applicant); $CI =&get_instance(); $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); @@ -28,11 +28,21 @@ class DIGITAL_LOCKER return array('dataStatus'=>false,'msg'=>$response->error_description); }else{ log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token); - return self::getFileIssuedList($response->access_token); + $CI->db->SELECT("fk_pd_id"); + $CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS"); + $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); + $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); + $dtls = $CI->db->GET()->result_array(); + $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; + + $CI->db->where('pd_co_applicant_id =',$applicant); + $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); + + return self::getFileIssuedList($response->access_token,$pd_id); } } - public static function getFileIssuedList($access_token) + public static function getFileIssuedList($access_token,$pd_id) { log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); @@ -44,7 +54,7 @@ class DIGITAL_LOCKER $result=curl_exec($ch); log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id); } public static function downloadFiles($uri,$access_token) diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index 0ef6c67b..7290e7f0 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -103,6 +103,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''.$list['items'][$i]['issuer'].''; } echo ''; + echo ''; echo '