Digilocker Files Changes : ps

This commit is contained in:
VE10-Sanjeev 2022-07-25 10:00:56 +05:30
parent 58019d0122
commit fad9c90653
4 changed files with 161 additions and 49 deletions

View File

@ -133,7 +133,7 @@ defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_UR
defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData');
defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token');
defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/');
}
else if(ENVIRONMENT == 'testing')
@ -159,7 +159,7 @@ else if(ENVIRONMENT == 'testing')
defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData');
defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token');
defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/');
}
else if(ENVIRONMENT == 'production')
{
@ -184,7 +184,7 @@ else if(ENVIRONMENT == 'production')
defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData');
defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token');
defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/');
defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/');
}
/*********************END of AWS resources Constants*************************************************/

View File

@ -2191,7 +2191,7 @@ class Flyhi_Controller extends REST_Controller {
// $code = "66e28b748d5f73186206a03f27f6aee73191a087";
$code = $this->get('code');
$co_applicant = $this->get('state');
log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant : ".$co_applicant);
log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant id : ".$co_applicant);
$response_data = digital_locker::getAccessToken($code,$co_applicant);
if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){
@ -2202,8 +2202,11 @@ class Flyhi_Controller extends REST_Controller {
$view_data['token']= $response_data['token'];
$view_data['pd_id']=$response_data['pd_id'];
$view_data['applicant_name']=$response_data['applicant_name'];
$view_data['applicant_id']=$response_data['applicant_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->header_title = "new";
$view_data['page_title']="PD GENIE : Digitial Documents";
$this->load->view("digital_locker",$view_data);
// echo $html_content; die();
// $response_data['status'] = REST_Controller::HTTP_OK;
@ -2214,14 +2217,18 @@ class Flyhi_Controller extends REST_Controller {
public function downloadDigiLockerDocs_post(){
$this->load->helper('digital_locker');
log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post()));
$temp_flag = 0 ;
$form_data = $this->post();
$token = $form_data['token'];
$pd_id = $form_data['pd_id'];
$applicant_name = $form_data['applicant_name'];
$applicant_id = $form_data['applicant_id'];
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']);
unset($form_data['applicant_id']);
for($i=0;$i<count($form_data);$i++){
$key_name = "digilocker_docname".$i;
if(!empty($form_data[$key_name])){
@ -2240,33 +2247,62 @@ class Flyhi_Controller extends REST_Controller {
log_message('ERROR','### 5.6th User Choosen Files inx '.$i);
$reponse = digital_locker::downloadFiles($reindexed_array[$i],$token);
log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse));
$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);
$doc_name = str_replace(' ', '_',$digilocker_doc_name[$i]);
$doc_renamed = $applicant_name."_".$doc_name.'.pdf';
log_message('ERROR','### 7.1th doc_name '.$doc_renamed.' inx : '.$i);
$src_local_file = XLPATH.'/tmp/'.$doc_renamed;
$ifp = fopen( $src_local_file, 'wb' );
fwrite( $ifp, $reponse );
fclose( $ifp );
chmod($src_local_file, 0777);
$tempdoc = $src_local_file;
$tempdocname = $doc_renamed;
$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 = $applicant_name."-id_proof-".$digilocker_doc_name[$i];
$bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id;
$key = 'pd'.$pd_id.'/'.$tempdocname ;
$sourcefile = json_decode($reponse, true);
$key = 'pd'.$pd_id.'/'.$doc_renamed ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
// $MyFile = file_get_contents($src_local_file);
log_message('ERROR',"### 7.2 : Choosen Files s3-result :".json_encode($s3result));
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name[$i]);
$this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS);
$pd_document_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$doc_renamed,'pd_document_name'=>$doc_renamed,'fk_form_id'=>18,'co_applicant_id'=>$applicant_id);
$pd_document_id = $this->Flyhi_Model->saveRecords($pd_document_data,PDDOCUMENTS);
if($pd_document_id != "" || $pd_document_id != null){ $temp_flag++; }
unlink($src_local_file);
}
log_message('ERROR',"### 8 : Choosen Files reponse :".json_encode($reponse));
}}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'File Uploaded Successfully';
$this->response($data,REST_Controller::HTTP_OK);
if($temp_flag != 0){
$msg = count($reindexed_array). 'User Select File . '.$temp_flag.' File Uploaded Successfully';
$reponse_data['dataStatus'] = true;
$reponse_data['status'] = REST_Controller::HTTP_OK;
$reponse_data['msg'] = $msg;
echo '<script language="javascript">';
echo 'alert("'.$msg.'")';
echo '</script>';
// sleep for 8 seconds
sleep(8);
// redirect("https://demo.pdgenie.com/pd/#/home");
}else{
$reponse_data['dataStatus'] = false;
$reponse_data['status'] = REST_Controller::HTTP_NO_CONTENT;
$reponse_data['msg'] = 'No File Uploaded';
}
$this->response($reponse_data,REST_Controller::HTTP_OK);
}
public function getDigiLockerDocs2_get(){
$this->load->helper('digital_locker');

View File

@ -35,17 +35,18 @@ class DIGITAL_LOCKER
$dtls = $CI->db->GET()->result_array();
$pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null;
$applicant_name = (count($dtls)>0) ? $dtls[0]['applicant_name'] : null;
$applicant_id = $applicant;
$CI->db->where('pd_co_applicant_id',$applicant);
$CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $result));
// print_r($CI->db->last_query());
return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name);
return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name,$applicant_id);
}
}
public static function getFileIssuedList($access_token,$pd_id,$applicant_name)
public static function getFileIssuedList($access_token,$pd_id,$applicant_name,$applicant_id)
{
log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token);
$CI =&get_instance();
@ -57,9 +58,33 @@ 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,'applicant_name'=>$applicant_name);
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name,'applicant_id'=>$applicant_id);
}
// public static function downloadFiles($uri,$access_token)
// {
// log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri);
// log_message('ERROR',"### 6.1 : Dummy API ");
// $image_url = "http://p.twimg.com/AW2-vIUCAAE_1FN.png";
// $ch = curl_init();
// curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt ($ch, CURLOPT_URL, $image_url);
// curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
// curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
// curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
// curl_setopt($ch, CURLOPT_HEADER, true);
// curl_setopt($ch, CURLOPT_NOBODY, true);
// $content = curl_exec ($ch);
// log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($content));
// $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
// echo $contentType;
// echo "<br/>";
// curl_close ($ch);
// echo "<pre>";
// print_r($content);
// }
public static function downloadFiles($uri,$access_token)
{
log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri);
@ -70,8 +95,10 @@ class DIGITAL_LOCKER
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
$result=curl_exec($ch);
log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($result));
curl_close( $ch );
log_message('ERROR',"### 6.1 : DIGILOCKERGETFILEURI Reponse :".json_encode($result));
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
log_message('ERROR',"### 6.2 : DIGILOCKERGETFILEURI contentType:".$contentType);
curl_close ($ch);
return $result;
}

View File

@ -11,8 +11,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
@page {
margin: 100px 50px;
@ -35,7 +35,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
font-size: 10px;
text-align: left;
}
.headlines {
font: 500 20px/32px Roboto,"Helvetica Neue",sans-serif;
text-align: left;
margin: 0; }
/* #########Score Card Table Styles######### */
.scorecard_table {
@ -47,9 +51,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
.scorecard_table td, .scorecard_table th {
border: 1px solid #000;
padding: 8px;
page-break-inside: inline;
}
.scorecard_table tr:nth-child(even){background-color: #f2f2f2;page-break-inside: inline; }
@ -60,20 +64,48 @@ defined('BASEPATH') OR exit('No direct script access allowed');
padding-top: 8px;
padding-bottom: 8px;
text-align: center;
background-color: #0d93a9;
background-color: #FF0000;
color: white;page-break-inside: inline;
}
/* #########End of Score Card Table Styles######### */
.tdcenteralign{ text-align: center; }
.thlargefont{ font-size: 20px; }
/* HTML - Red ;Hex Code - #FF0000;Decimal Code - (255,0,0) */
.bodycss{
font-weight: 400;
font-size: 1.2rem;
color: rgba(0,0,0,.87);
line-height: 1.5;
font-family: Roboto,"Helvetica Neue",sans-serif;
padding: 0 40px;
}
.buttoncss{
background-color: #FF0000;
border: none;
color: white;
padding: 14px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
}
.branding {
display: block;
border-bottom: 2px solid red;
page-break-inside: inline;
}
</style>
<title><?php echo $page_title; ?></title>
</head>
<body style="font-family:Merriweather;font-size:12px;margin:15px 30px">
<body>
<div class="branding"><a><img src="https://pdgenie.com/logo/sineedge_red.png" style="height: 45px;"></a></div>
<br>
<div class="bodycss">
<footer>
<hr>
@ -88,40 +120,57 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<?php
if(count($list))
{
echo '<div>
<span class="headlines">
<span style= "font-weight: bold;"> Digital Documents</span>
<br>
Applicant Name : "<i>'.$applicant_name.'</i>"</span>
</div>';
echo '<form id="form1" name="form1" method="post" action="downloadDigiLockerDocs">
<table class="scorecard_table"><tbody>
<tr><th class="thlargefont" colspan="10">DIGI LOCKER Docs List</th></tr>
<tr><td colspan="1" > Serial Number / Checkbox </td>
<td class = "tdcenteralign" colspan="2">Name</td>
<td class = "tdcenteralign" colspan="3">Description</td>
<td class = "tdcenteralign" colspan="4">Issuer</td></tr>';
<tr>
<th colspan="1" > Sr. No. </th>
<th colspan="1" > Select </th>
<th colspan="3" > Document Name</th>
<th colspan="1" > Document Uploaded Date</th>
<th colspan="2" > Document Description</th>
<th colspan="2" > Document Issuer</th></tr>';
for($i=0;$i<count($list['items']);$i++){
echo '<tr><td colspan="1" ><div style="text-align:right">'.($i+1).'<input type="checkbox" id="'.$i.'" name="'.$i.'" value="'.$list['items'][$i]['uri'].'">
echo '<tr>
<td colspan="1" ><div style="text-align:right;padding-right: 8px;">'.($i+1).'
<td colspan="1" ><div style="text-align:center"><input type="checkbox" id="'.$i.'" name="'.$i.'" value="'.$list['items'][$i]['uri'].'">
<input type="hidden" id="digilocker_docname'.$i.'" name="digilocker_docname'.$i.'" value='.$list['items'][$i]['name'].'></div></td>'; //checkbox
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 '<td colspan="3"><div style="text-align:left;padding-left: 8px;">'.$list['items'][$i]['name'].'</td>';
echo '<td colspan="1"><div style="text-align:center">'.$list['items'][$i]['date'].'</td>';
echo '<td colspan="2"><div style="text-align:left;padding-left: 8px;">'.$list['items'][$i]['description'].'</td>';
echo '<td colspan="2"><div style="text-align:left;padding-left: 8px;">'.$list['items'][$i]['issuer'].'</td></tr>';
}
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 '<input type="hidden" id="applicant_name" name="applicant_name" value='.$applicant_name.'>';
echo '<input type="hidden" id="applicant_id" name="applicant_id" value='.$applicant_id.'>';
echo '</tbody></table>
<br>
<div style="text-align:right"><input type="submit" value="Download"></div></form>';
<div style="text-align:right;">
<button class="buttoncss" data-toggle="tooltip" title="Download" data-placement="right" type="submit"><i class="fa fa-download"></i> Download</button>
</div></form>';
}
else{
echo '<table class="scorecard_table"><tbody>
<tr><th class="thlargefont" colspan="10">Digi-Locker Docs List</th></tr>
<tr><td colspan="1" > Serial Number / Checkbox </td>
<td class = "tdcenteralign" colspan="2">Name</td>
<td class = "tdcenteralign" colspan="3">Description</td>
<td class = "tdcenteralign" colspan="4">Issuer</td></tr>
<tr><td class = "tdcenteralign" colspan="10">There is No Digi-Locker Docs</td></tr>
<tr>
<th colspan="1" > Sr. No. </th>
<th colspan="1" > Select </th>
<th colspan="3" > Document Name</th>
<th colspan="1" > Document Uploaded Date</th>
<th colspan="2" > Document Description</th>
<th colspan="2" > Document Issuer</th></tr>
<tr><td colspan="10"><div style="text-align:center">There is No Digi-Locker Docs</div></td></tr>
</tbody></table><br>';
}
?>
</div>
</body>
</html>