DigiLocker fixes 1 : ps

This commit is contained in:
VE10-Sanjeev 2022-07-15 10:06:06 +05:30
parent 29252cc95d
commit de35af21eb
3 changed files with 26 additions and 15 deletions

View File

@ -2200,7 +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'];
$view_data['dtls']=$response_data['dtls'];
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);
@ -2216,23 +2216,28 @@ class Flyhi_Controller extends REST_Controller {
$form_data = $this->post();
$token = $form_data['token'];
$pd_id = $form_data['pd_id'];
$applicant_name = $form_data['applicant_name'];
log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']);
unset($form_data['token']);
unset($form_data['pd_id']);
unset($form_data['applicant_name']);
$reindexed_array = array_values($form_data);
if(count($reindexed_array)>0){
for($i=0;$i<count($reindexed_array);$i++){
$key_name = "digilocker_docname".$i;
$digilocker_doc_name = $reindexed_array[$key_name];
unset($reindexed_array[$key_name]);
$reponse = digital_locker::downloadFiles($reindexed_array[$i],$token);
// $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);
$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;
$tempdocname = $applicant_name."-id_proof-".$i+1;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id;
$key = 'pd'.$pd_id.'/'.$tempdocname ;
$sourcefile = json_decode($reponse, true);
@ -2241,7 +2246,7 @@ class Flyhi_Controller extends REST_Controller {
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);
$record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name);
$this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS);
}
log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse));

View File

@ -28,21 +28,20 @@ class DIGITAL_LOCKER
return array('dataStatus'=>false,'msg'=>$response->error_description);
}else{
log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token);
$CI->db->SELECT("fk_pd_id");
$CI->db->SELECT("fk_pd_id,pd_co_applicant_id,applicant_name");
$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);
return self::getFileIssuedList($response->access_token,$dtls);
}
}
public static function getFileIssuedList($access_token,$pd_id)
public static function getFileIssuedList($access_token,$dtls)
{
log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token);
$CI =&get_instance();
@ -54,7 +53,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,'pd_id'=>$pd_id);
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls);
}
public static function downloadFiles($uri,$access_token)

View File

@ -3,7 +3,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$uparrow = '<span style="color:green;">↑</span>';
$downarrow = '<span style="color:red;">↓</span>';
$dash = '<span style="color:black;"> </span>';
if(count($dtls)>0){
$pd_id = isset($dtls[0]['fk_pd_id']) ? $dtls[0]['fk_pd_id'] : null;
$applicant_name = isset($dtls[0]['applicant_name']) ? $dtls[0]['applicant_name'] : null;
}
?>
<!DOCTYPE html>
<html lang="en">
@ -101,9 +105,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo '<td class = "tdcenteralign" colspan="2">'.$list['items'][$i]['name'].'</td>';
echo '<td class = "tdcenteralign" colspan="3">'.$list['items'][$i]['description'].'</td>';
echo '<td class = "tdcenteralign" colspan="4">'.$list['items'][$i]['issuer'].'</td></tr>';
echo '<input type="hidden" id="digilocker_docname'.$i.'" name="digilocker_docname'.$i.'" value='.$list['items'][$i]['name'].'>';
}
echo '<input type="hidden" id="token" name="token" value='.$token.'>';
echo '<input type="hidden" id="pd_id" name="pd_id" value='.$pd_id.'>';
echo '<input type="hidden" id="applicant_name" name="applicant_name" value='.$applicant_name.'>';
echo '</tbody></table>
<br>