FInal Digilocker : ps

This commit is contained in:
VE10-Sanjeev 2022-08-03 21:26:53 +05:30
parent 347dbde7e9
commit 865c29d5ac
6 changed files with 205 additions and 59 deletions

View File

@ -95,7 +95,8 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage');
defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors
defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP');
defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP');
defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs');
defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'previewDigiLockerDocs');
// defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs');
defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs');
defined('ROUTE_LOGIN_D') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors
defined('ROUTE_LOGIN_C') OR define('ROUTE_LOGIN_C', 'getCreditPDReportforCETApp');

View File

@ -396,3 +396,5 @@ $route['downloadDigiLockerDocs']='Flyhi_Controller/downloadDigiLockerDocs';
$route['archivePDSMCImages'] = 'SMC_Credit_PD_Controller/archivePDImages';
$route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload';
$route['myFunction']='Flyhi_Controller/myFunction';
$route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs';

View File

@ -2186,25 +2186,29 @@ class Flyhi_Controller extends REST_Controller {
}
}
public function getDigiLockerDocs_get(){
public function getDigiLockerDocs_get(){
$this->load->helper('digital_locker');
// $code = "66e28b748d5f73186206a03f27f6aee73191a087";
$code = $this->get('code');
$co_applicant = $this->get('state');
log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant id : ".$co_applicant);
log_message('ERROR',"### 1 Msg : Inside flyhi Controller GetDigilockerDocs fns");
log_message('ERROR',"### 1 Params : i have code :".$code." & applicant id : ".$co_applicant);
$response_data = digital_locker::getAccessToken($code,$co_applicant);
log_message('ERROR',"### 5 Helper Reponse : ".json_encode($response_data));
if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){
$response_data['status'] = REST_Controller::HTTP_NOT_FOUND;
$this->response($response_data,REST_Controller::HTTP_OK);
}else{
$view_data['list'] = json_decode($response_data['records'], true);
$other_data = $response_data['dtls'];
$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));
$view_data['list'] = json_decode($response_data['records'], true);
$view_data['pd_id'] = (count($other_data)>0) ? $other_data[0]['fk_pd_id'] : null;
$view_data['applicant_name'] = (count($other_data)>0) ? $other_data[0]['applicant_name'] : null;
$view_data['pd_sno'] = (count($other_data)>0) ? $other_data[0]['pd_sno'] : null;
$view_data['applicant_id']=(count($other_data)>0) ? $other_data[0]['pd_co_applicant_id'] : null;
log_message('ERROR',"### 5 ViewData :".json_encode($view_data));
$this->header_title = "new";
$view_data['page_title']="PD GENIE : Digitial Documents";
$this->load->view("digital_locker",$view_data);
@ -2304,7 +2308,12 @@ class Flyhi_Controller extends REST_Controller {
$this->response($reponse_data,REST_Controller::HTTP_OK);
}
public function getDigiLockerDocs2_get(){
public function myFunction_post(){
echo '<script language="javascript">';
echo 'alert("NEW Function")';
echo '</script>';
}
public function getDigiLockerDocs3_get(){
$this->load->helper('digital_locker');
// echo " 1- ".digital_locker::userCh_check1();
$view_data['list2'] = array (
@ -2398,7 +2407,9 @@ class Flyhi_Controller extends REST_Controller {
$reponse = digital_locker::userCh_check3($code,$co_applicant);
$view_data['token']= "response_data['token']";
$view_data['pd_id']="3258";
$view_data['applicant_name']="Sanjeev Soni";
$view_data['applicant_name']="Sanjeev ";
$view_data['applicant_id']="7128";
$view_data['pd_sno']="M7128";
$this->load->view("digital_locker",$view_data);
// echo $html_content; die();
}
@ -2406,4 +2417,108 @@ $this->load->view("digital_locker",$view_data);
$this->load->helper('digital_locker');
echo " 3- ".digital_locker::userCh_check3();
}
public function previewDigiLockerDocs_post(){
$this->load->helper('digital_locker');
log_message('ERROR',"### 6 Msg : inside Controller PreviewDigiLockerDocs fns");
log_message('ERROR','### 6 Params : '.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'];
$doc_name = $form_data['doc_name'];
$doc_uri = $form_data['doc_uri'];
log_message('ERROR','### 6 Form data : '.json_encode($form_data));
if(count($form_data)>0){
$doc_name = str_replace(' ', '_',$doc_name);
$doc_renamed = $applicant_name."_".$doc_name.'.pdf';
log_message('ERROR','### 6 Doc renamed : '.$doc_renamed);
// $src_local_file = XLPATH.'/tmp/'.$doc_renamed;
$src_local_file = XLPATH.'/pd_reports/'. $pd_id .'/'.$doc_name.'.pdf';
log_message('ERROR','### 6 Doc path : '.$doc_renamed);
if(!file_exists($src_local_file))
{
mkdir(XLPATH.'/pd_reports/'. $pd_id .'/',0777);
$reponse = digital_locker::downloadFiles($doc_uri,$token);
log_message('ERROR',"### 6 Reponse :".json_encode($reponse));
$ifp = fopen( $src_local_file, 'wb' );
fwrite( $ifp, $reponse );
fclose( $ifp );
$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;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id;
$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);
log_message('ERROR',"### 8 S3-result :".json_encode($s3result));
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$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);
}
}else{
log_message('ERROR','### 6 else ');
}
// chmod($src_local_file, 0777);
$this->readfile($src_local_file);
// $tofile= realpath($src_local_file);
// header('Content-Type: application/pdf');
// // $MyFile = file_get_contents($src_local_file);
// readfile($tofile);
}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 readfile($file){
chmod($file, 0777);
$tofile= realpath($file);
header('Content-Type: application/pdf');
// $MyFile = file_get_contents($file);
readfile($tofile);
}
public function previewDigiLockerDoc_get(){
$this->load->helper('digital_locker');
$fname = $this->get('doc');
$fname = "Komal_Covid_old.pdf";
$token = $this->get('token');
$pdid = $this->get('pdid');
$src_local_file = XLPATH.'/tmp/'.$fname;
// $src_local_file = XLPATH.'/pd_reports/'. $pdid .'/'.$fname.'.pdf';
if(!file_exists($src_local_file))
{
// $reponse = digital_locker::downloadFiles($fname,$token);
// $ifp = fopen( $src_local_file, 'wb' );
// fwrite( $ifp, $reponse );
// fclose( $ifp );
}
chmod($src_local_file, 0777);
$tofile= realpath($src_local_file);
header('Content-Type: application/pdf');
readfile($tofile);
// $call = digital_locker::callTheFiles($src_local_file);
// return $fname;
// $tofile= realpath("uploaddir/".$fname);
// header('Content-Type: application/pdf');
// readfile($tofile);
}
}// Class Ends

View File

@ -10265,14 +10265,14 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
if($video_info->num_rows())
{
$video_info = $video_info->result_array();
//print_r($video_info);die();
foreach ($video_info as $key => $value)
{
if($value['composition_id'] && $value['vsp'] != 'google')
{
$res = $this->twlio->getCompositionStatus($value['composition_id']);
//echo $res['status'];
if(count($res) && $res['status'] == 'completed')
{
@ -10319,10 +10319,12 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
//echo $singed_uri;
$file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ;
$lender_id = $pd_master_details[0]['fk_lender_id'];
$internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos';
$internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos';
if($pd_catgory == "2"){
EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id'],$internal_server_tmp_location);
}
$internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4');
//echo $internal_server_tmp_location;
if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location); };
if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location,0777); };
$is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri));
//upload it to aws s3
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id;

View File

@ -8,7 +8,8 @@ class DIGITAL_LOCKER
public static function getAccessToken($code,$applicant)
{
log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code." & applicant :".$applicant);
log_message('ERROR',"### 2 Msg : Inside Digi Helper getAccessToken Fns");
log_message('ERROR',"### 2 Params : i have code :".$code." & applicant :".$applicant);
$CI =&get_instance();
$headers = array('Content-Type: multipart/form-data');
// $headers = array('Content-Type: application/json');
@ -22,33 +23,32 @@ class DIGITAL_LOCKER
$result=curl_exec($ch);
$response = json_decode($result);
curl_close( $ch );
log_message('ERROR',"### 2th : getAccessToken Reponse :".json_encode($response));
log_message('ERROR',"### 2 Response :".json_encode($response));
if(isset($response->error_description)){
log_message('ERROR',"### 3 : getAccessToken Access Error :".$response->error_description);
log_message('ERROR',"### 2 Error :".$response->error_description);
return array('dataStatus'=>false,'msg'=>$response->error_description);
}else{
log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token);
$CI->db->SELECT("fk_pd_id,pd_co_applicant_id,applicant_name");
log_message('ERROR',"### 3 Token :".$response->access_token);
$CI->db->SELECT("PDAPPLICANTSDETAILS.fk_pd_id,PDAPPLICANTSDETAILS.pd_co_applicant_id,PDAPPLICANTSDETAILS.applicant_name,
PDTRIGGER.lender_applicant_id, PDTRIGGER.pd_sno");
$CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS");
$CI->db->JOIN(PDTRIGGER .' as PDTRIGGER','PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id','LEFT');
$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;
$applicant_name = (count($dtls)>0) ? $dtls[0]['applicant_name'] : null;
$applicant_id = $applicant;
// 9 840-2 714
$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,$applicant_id);
// print_r($CI->db->last_query());die();
log_message('ERROR',"### 3 SQL Reponse :".json_encode($dtls));
return self::getFileIssuedList($response->access_token,$dtls);
}
}
public static function getFileIssuedList($access_token,$pd_id,$applicant_name,$applicant_id)
public static function getFileIssuedList($access_token,$dtls)
{
log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token);
log_message('ERROR',"### 4 Msg : Inside Helper getFileIssuedList");
log_message('ERROR',"### 4 Token :".$access_token);
$CI =&get_instance();
$headers = array('Authorization: Bearer '.$access_token);
$ch = curl_init();
@ -56,9 +56,9 @@ class DIGITAL_LOCKER
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
$result=curl_exec($ch);
log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result));
log_message('ERROR',"### 4 Reponse :".json_encode($result));
curl_close( $ch );
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name,'applicant_id'=>$applicant_id);
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls);
}
// public static function downloadFiles($uri,$access_token)
@ -87,7 +87,8 @@ class DIGITAL_LOCKER
// }
public static function downloadFiles($uri,$access_token)
{
log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri);
log_message('ERROR',"### 7 MSG : Inside Helper DIGILOCKERGETFILEURI");
log_message('ERROR',"### 7 Token :".$access_token." & URI :".$uri);
$CI =&get_instance();
$headers = array('Authorization: Bearer '.$access_token);
$ch = curl_init();
@ -95,9 +96,9 @@ class DIGITAL_LOCKER
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
$result=curl_exec($ch);
log_message('ERROR',"### 6.1 : DIGILOCKERGETFILEURI Reponse :".json_encode($result));
log_message('ERROR',"### 7 Reponse :".json_encode($result));
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
log_message('ERROR',"### 6.2 : DIGILOCKERGETFILEURI contentType:".$contentType);
log_message('ERROR',"### 7 ContentType :".$contentType);
curl_close ($ch);
return $result;
}
@ -124,6 +125,9 @@ class DIGITAL_LOCKER
$CI->db->where('pd_co_applicant_id',$applicant);
$CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response));
}
public static function callTheFiles($src_local_file){
}
}

View File

@ -84,7 +84,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
background-color: #FF0000;
border: none;
color: white;
padding: 14px;
padding: 8px;
text-align: center;
text-decoration: none;
display: inline-block;
@ -99,7 +99,25 @@ defined('BASEPATH') OR exit('No direct script access allowed');
page-break-inside: inline;
}
</style>
.fa-disabled {
opacity: 0.6;
cursor: not-allowed;
}
a i {
transition: all 0.3s linear;
}
a:hover i {
transform: scale(1.5);
}
a:hover {
color: red;
}
</style>
<title><?php echo $page_title; ?></title>
</head>
<body>
@ -124,49 +142,53 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<span class="headlines">
<span style= "font-weight: bold;"> Digital Documents</span>
<br>
PD Number : "<i>'.$pd_sno.'/'.$pd_id.'</i>"<br>
Applicant Name : "<i>'.$applicant_name.'</i>"</span>
</div>';
echo '<form id="form1" name="form1" method="post" action="downloadDigiLockerDocs">
<table class="scorecard_table"><tbody>
echo ' <table class="scorecard_table"><tbody>
<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>';
<th colspan="2" > Document Issuer</th>
<th colspan="1" > Action </th></tr>';
for($i=0;$i<count($list['items']);$i++){
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 '<tr><td colspan="1" ><div style="text-align:right;padding-right: 8px;">'.($i+1).'</div></td>'; //checkbox
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 '<td colspan="2"><div style="text-align:left;padding-left: 8px;">'.$list['items'][$i]['issuer'].'</td>';
echo '<td colspan="2"><div style="text-align:center;">
<form id="form1" name="form1" method="post" action="previewDigiLockerDocs" target="_blank">
<input type="hidden" id="token" name="token" value='.$token.'>
<input type="hidden" id="pd_id" name="pd_id" value='.$pd_id.'>
<input type="hidden" id="applicant_name" name="applicant_name" value='.$applicant_name.'>
<input type="hidden" id="applicant_id" name="applicant_id" value='.$applicant_id.'>
<input type="hidden" id="doc_name" name="doc_name" value='.$list['items'][$i]['name'].'>
<input type="hidden" id="doc_uri" name="doc_uri" value='.$list['items'][$i]['uri'].'>
<button class="buttoncss" data-toggle="tooltip" data-placement="right" type="submit"><i class="fa fa-download" title="Preview/Download PDF"></i></button></td>
</form>
</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_id" name="applicant_id" value='.$applicant_id.'>';
echo '</tbody></table>
<br>
<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>';
echo '</tbody></table>';
// <a class="link" href="previewDigiLockerDocs?doc='.$list['items'][$i]['uri'].'&token='.$token.'" target="_blank"><i class="fa fa-download" title="Download PDF"></i></a>
// <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>
}
else{
echo '<table class="scorecard_table"><tbody>
<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>
<th colspan="2" > Document Issuer</th>
<th colspan="2" > Action</th></tr>
<tr><td colspan="10"><div style="text-align:center">There is No Digi-Locker Docs</div></td></tr>
</tbody></table><br>';
}