SAVE LATEST VERSION OF PD REPORT
This commit is contained in:
parent
bb46cb91ba
commit
dd18441437
@ -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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
<p>Hope will get reply soon!!</p>
|
||||
<p><strong>Regards,</strong></p>
|
||||
<p onclick='alert()'>Sriram,</p>
|
||||
<p style='font-weight: bold;'>Main Raw Materials are Listed Below</p>
|
||||
<p style='font-weight: bold;'>Main Raw Materials are Listed Below Edietd</p>
|
||||
<p>check checkcheck</p>
|
||||
|
||||
<p style='font-weight: bold;'>Suppliers are Listed Below</p>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user