From dd18441437216e674456856a42d2967b50e42646 Mon Sep 17 00:00:00 2001
From: velz
Date: Mon, 10 Dec 2018 14:40:41 +0530
Subject: [PATCH] SAVE LATEST VERSION OF PD REPORT
---
api/application/config/constants.php | 5 +-
api/application/config/routes.php | 1 +
api/application/controllers/PD_Controller.php | 72 +++++++++++++++++-
api/application/docs/sample.pdf | Bin 2331 -> 2337 bytes
api/application/docs/temp.html | 2 +-
api/application/libraries/AWS_S3.php | 53 ++++++++++++-
api/application/models/PD_Model.php | 2 +-
7 files changed, 130 insertions(+), 5 deletions(-)
diff --git a/api/application/config/constants.php b/api/application/config/constants.php
index 099a3631..ea743199 100644
--- a/api/application/config/constants.php
+++ b/api/application/config/constants.php
@@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto
// define login route name for token verification
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors
-defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getLatestPDReportBlob'); // no errors
+defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'saveNewVersionOfPDReport'); // no errors
/*********************AWS resources Constants*************************************************/
defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic');
@@ -436,6 +436,9 @@ defined('PDADDTIONALREQUIREMENTSID') OR define('PDADDTIONALREQUIREMENTSID','add_
defined('NONINDIVIDUALENTITIES') OR define('NONINDIVIDUALENTITIES','m_non_individual_entities');
defined('NONINDIVIDUALENTITIESID') OR define('NONINDIVIDUALENTITIESID','non_individual_entity_id');
+defined('COMPANYRELATIONSHIPS') OR define('COMPANYRELATIONSHIPS','m_company_relationships');
+defined('COMPANYRELATIONSHIPSID') OR define('COMPANYRELATIONSHIPSID','company_relationship_id');
+
diff --git a/api/application/config/routes.php b/api/application/config/routes.php
index 94ba4314..d367ef9e 100644
--- a/api/application/config/routes.php
+++ b/api/application/config/routes.php
@@ -167,6 +167,7 @@ $route['saveAssessedIncomeCalculateMode'] = 'PD_Controller/saveAssessedIncomeCal
$route['savePDAdditionalRequiremets'] = 'PD_Controller/savePDAdditionalRequiremets';
$route['generatePDReport'] = 'PD_Controller/generatePDReport';
$route['getLatestPDReportBlob'] = 'PD_Controller/getLatestPDReportBlob';
+$route['saveNewVersionOfPDReport'] = 'PD_Controller/saveNewVersionOfPDReport';
//PD Form Related
$route['getPDFormDetails'] = 'PD_Controller/getPDFormDetails';
diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php
index 6efa26f2..8c2ef23d 100644
--- a/api/application/controllers/PD_Controller.php
+++ b/api/application/controllers/PD_Controller.php
@@ -2575,7 +2575,8 @@ class PD_Controller extends REST_Controller {
$records = $this->post('records');
$pdid = $records['pd_id'];
$original_template = "RAW";
-
+ // echo "RE called";
+ // die();
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
//getSingleObjectInaBucketAsSignedURI($bucket_name,$folder_name,$time = '+5 minutes')
@@ -2673,7 +2674,9 @@ class PD_Controller extends REST_Controller {
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
+ //$bucketname = LENDER_BUCKET_NAME_PREFIX.'8';
$key = 'pd'.$pdid.'/'.'pd_report_original_version.pdf';
+ //$key = 'pd'.'4'.'/'.'11.pdf';
if($flag == 1)
{
$key = 'pd'.$pdid.'/'.'version'.$pd_master_details[0]['pd_report_latest_version'].'.pdf';
@@ -2692,5 +2695,72 @@ class PD_Controller extends REST_Controller {
}
+ public function saveNewVersionOfPDReport_post()
+ {
+
+
+ $records = $this->post('records');
+ $pdid = $records['pd_id'];
+ $blob = $records['content'];
+
+ //Get PD Master Details
+ $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
+ //print_r($pd_master_details);
+ //store BLOB in pd trigger Table
+ $latest_version = $pd_master_details[0]['pd_report_latest_version'] + 1;
+ $where_condition_array = array('pd_id' => $pdid);
+ $temp_array = array('pd_report_latest_version' => $latest_version,'pd_report_latest_version_blob' => $blob);
+
+ $id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
+
+ //convert BLOB as html then pdf then store it s3.
+ $output_file = APPPATH."/docs/temp.html";
+ $ifp = fopen( $output_file, 'wb' );
+ //fwrite( $ifp, $original_template );
+ fwrite( $ifp, $blob );
+ fclose( $ifp );
+ //print_r($output_file);
+ $file= file_get_contents($output_file);
+ $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
+ //print_r($pdf_doc);
+
+
+ $output_file2 = APPPATH."/docs/sample.pdf";
+ if(file_put_contents($output_file2, $pdf_doc))
+ {
+ $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
+ $key = 'pd'.$pdid.'/'.'version'.$latest_version.'.pdf';
+ $sourcefile = $output_file2;
+
+ $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
+ $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
+ //print_r($s3result);
+ if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
+ {
+
+ $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '3600 seconds');
+ if($id != null || $id != "" )
+ {
+ $data['dataStatus'] = true;
+ $data['status'] = REST_Controller::HTTP_OK;
+ $data['records'] = array('pd_report_uri' => $uri);
+ $this->response($data,REST_Controller::HTTP_OK);
+ }
+ else
+ {
+ $data['dataStatus'] = false;
+ $data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
+ $data['msg'] = 'Something Went Wrong..!Try later';
+ $this->response($data,REST_Controller::HTTP_OK);
+ }
+ }
+
+
+ //End of convert BLOB as html then pdf then store it s3.
+
+
+ }
+}
+
}
\ No newline at end of file
diff --git a/api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@Q~*fWSe90Gdt#we=EO00}aXv6G?=|CaWw6
z9LhXvbNHDz#r6eG#c|hRm-Qwq;i1W@&5lGOYm~qk7K!}1KI9mvEa53XLX#iL7ijCc
zdiO3CMy5n_)rH}Hn7jNbYaZKJR+o43@5n7DmFz{
zwvaVB{8hAAe^mICm-Q(YFTpNS(aP@f%?~)Q=OyMWCDD{c$lO044rP%yGaPW-v>mt0
zik&w#-u-?vpz)L>iozb}MG%uRXDQDXCOeC5;?hz~wDt_J#po=taWCr`GBkRSG$AsT
zK4fq4AgLi-N)OT*5Hh5?EYdWcGy69eEJ!CpHD0dBf8H=PT0l+s**hVMT0n+7T9-g)
zDbX^dq)j6JN
z;^WiaKJor%>EwU2MHope will get reply soon!!
Regards,
Sriram,
- Main Raw Materials are Listed Below
+ Main Raw Materials are Listed Below Edietd
check checkcheck
Suppliers are Listed Below
diff --git a/api/application/libraries/AWS_S3.php b/api/application/libraries/AWS_S3.php
index 2441339c..03571871 100644
--- a/api/application/libraries/AWS_S3.php
+++ b/api/application/libraries/AWS_S3.php
@@ -21,7 +21,8 @@ class AWS_S3
//echo "listAllBuckets";
$this->S3 = S3Client::factory($this->s3_properties);
- $this->getAllObjectsInaBucket('lender1','pd1');
+ // echo "Called";
+ //$this->setCors();
}
@@ -143,8 +144,58 @@ class AWS_S3
return $result;
}
+ public function setCors()
+ {
+
+ $result = $this->S3->putBucketCors([
+ 'Bucket' => 'lender8',
+ 'CORSConfiguration' => [
+ 'CORSRules' => [
+ [
+ 'AllowedHeaders' => [
+ '*',
+ ],
+ 'AllowedMethods' => [
+ 'PUT',
+ 'POST',
+ 'DELETE',
+ ],
+ 'AllowedOrigins' => [
+ '*',
+ ],
+ 'ExposeHeaders' => [
+ 'x-amz-server-side-encryption',
+ ],
+ 'MaxAgeSeconds' => 3000,
+ ],
+ [
+ 'AllowedHeaders' => [
+ 'Authorization',
+ ],
+ 'AllowedMethods' => [
+ 'GET',
+ ],
+ 'AllowedOrigins' => [
+ '*',
+ ],
+ 'MaxAgeSeconds' => 3000,
+ ],
+ ],
+ ]
+
+]);
+
+print_r($result);
+ }
+
+ public function getCORES()
+ {
+ $result = $this->S3->getBucketCors([
+ 'Bucket' => 'lender8']);
+ print_r($result);
+ }
}
?>
\ No newline at end of file
diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php
index f0de1c52..481a9f8d 100644
--- a/api/application/models/PD_Model.php
+++ b/api/application/models/PD_Model.php
@@ -252,7 +252,7 @@ class PD_Model extends SPARQ_Model {
if($log_key == 0)
{
- $log_string = 'PD Ctreated with '.$log['old_value'].'" status "';
+ $log_string = 'PD Created with '.$log['old_value'].'" status "';
$user = $log['createdby'];
$time = $log['createdon'];
$actual_logs[$log_key]['log'] = $log_string;