From 865c29d5ac577964e44726bfd6b02dac94bf6795 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 3 Aug 2022 21:26:53 +0530 Subject: [PATCH] FInal Digilocker : ps --- api/application/config/constants.php | 3 +- api/application/config/routes.php | 2 + .../controllers/Flyhi_Controller.php | 137 ++++++++++++++++-- api/application/controllers/PD_Controller.php | 12 +- .../helpers/digital_locker_helper.php | 44 +++--- api/application/views/digital_locker.php | 66 ++++++--- 6 files changed, 205 insertions(+), 59 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 078f3ba8..664634bc 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -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'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 0c3ce829..7784bdfc 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -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'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index adf0c7f7..600138fd 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -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 ''; + } + 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 diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 83a18022..5a62c77e 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -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; diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index beff351f..ce69f087 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -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){ + } } diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index e7a20a78..fc80b677 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -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; } - + + .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; + } + <?php echo $page_title; ?> @@ -124,49 +142,53 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Digital Documents
+ PD Number : "'.$pd_sno.'/'.$pd_id.'"
Applicant Name : "'.$applicant_name.'"
'; - echo '
- + echo '
- - '; + + '; for($i=0;$i - '; //checkbox + echo ''; //checkbox echo ''; echo ''; echo ''; - echo ''; + echo ''; + echo ' + + '; } - echo ''; - echo ''; - echo ''; - echo ''; - echo '
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
Document Issuer Action
'.($i+1).' -
-
'.($i+1).'
'.$list['items'][$i]['name'].'
'.$list['items'][$i]['date'].'
'.$list['items'][$i]['description'].'
'.$list['items'][$i]['issuer'].'
'.$list['items'][$i]['issuer'].'
+ + + + + + + +
-
-
- -
'; + echo ''; + // + //
+ // + //
} else{ echo ' - - + +
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
Document Issuer Action
There is No Digi-Locker Docs

'; }