pdf Merger fixes : ps
This commit is contained in:
parent
914a580bb1
commit
0468de1738
@ -10907,24 +10907,19 @@ class PD_Controller extends REST_Controller
|
||||
$bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id'];
|
||||
$main_applicant_name = $pd_master_details[0]['main_applicant'];
|
||||
$pdf_name = 'PD_Report_' . $main_applicant_name;
|
||||
|
||||
$key = 'pd' . $pdid . '/pd_reports/' . $main_applicant_name . '.pdf';
|
||||
$newkey = 'pd' . $pdid . '/pd_reports/' . $pdf_name . '.pdf';
|
||||
|
||||
$sample_report = $this->external_path . "/pd_reports/" . $pdid . "/sample.pdf";
|
||||
$new_report = $this->external_path . "/pd_reports/" . $pdid . "/mergeredReport.pdf";
|
||||
|
||||
if(file_exists($sample_report)){
|
||||
|
||||
// $key = 'pd' . $pdid . '/pd_reports/' . $main_applicant_name . '.pdf';
|
||||
$newkey = 'pd' . $pdid . '/pd_reports/' . $pdf_name . '.pdf';
|
||||
|
||||
// $records = $this->PD_Model->getDocsDetails($pdid);
|
||||
|
||||
$_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '30 minutes');
|
||||
|
||||
$headers = @get_headers($_uri);
|
||||
if ($headers && strpos($headers[0], '200')) {
|
||||
$is_writed = file_put_contents(XLPATH.'/tmp/existingReport.pdf',file_get_contents($_uri));
|
||||
} else {
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $newkey, '30 minutes');
|
||||
$is_writed = file_put_contents(XLPATH.'/tmp/existingReport.pdf',file_get_contents($singed_uri));
|
||||
}
|
||||
|
||||
|
||||
$is_writed = file_put_contents($new_report,file_get_contents($sample_report));
|
||||
|
||||
for($i=0;$i<count($records);$i++){
|
||||
$src_local_file = $this->external_path . "/pd_reports/" . $pdid . "/".$records[$i]['pd_document_name'];
|
||||
$is_writed = file_put_contents($src_local_file,file_get_contents($records[$i]['url']));
|
||||
$docsdetails[] = $records[$i]['pd_document_name'];
|
||||
$filtered_arr[] = $records[$i]['pd_document_id'];
|
||||
@ -10932,17 +10927,17 @@ class PD_Controller extends REST_Controller
|
||||
if(!empty($filtered_arr))$this->PD_Model->updpddocs($filtered_arr);
|
||||
if(!empty($docsdetails)){
|
||||
$pdf = new \Jurosh\PDFMerge\PDFMerger;
|
||||
$pdf->addPDF(XLPATH.'/tmp/existingReport.pdf', 'all');
|
||||
$pdf->addPDF($new_report, 'all');
|
||||
foreach($docsdetails as $doc)
|
||||
{
|
||||
$pdf->addPDF(XLPATH.'/tmp/'.$doc, 'all');
|
||||
$pdf->addPDF($this->external_path . "/pd_reports/" . $pdid . "/".$doc, 'all');
|
||||
}
|
||||
$pdf->merge('file', XLPATH.'/tmp/newReport.pdf');
|
||||
$pdf->merge('file',$new_report);
|
||||
}
|
||||
$sourcefile = XLPATH.'/tmp/newReport.pdf';
|
||||
$bucket_data = array('bucket_name' => $bucketname, 'key' => $newkey, 'sourcefile' => $sourcefile);
|
||||
|
||||
$bucket_data = array('bucket_name' => $bucketname, 'key' => $newkey, 'sourcefile' => $new_report);
|
||||
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
//print_r($s3result);
|
||||
|
||||
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
@ -10953,11 +10948,18 @@ class PD_Controller extends REST_Controller
|
||||
$data['msg'] = 'Something Went Wrong! Try Later';
|
||||
}
|
||||
foreach($docsdetails as $doc){
|
||||
$src_local_file = XLPATH.'/tmp/'.$doc;
|
||||
unlink($src_local_file);
|
||||
unlink($this->external_path . "/pd_reports/" . $pdid . "/".$doc);
|
||||
}
|
||||
unlink($sourcefile);
|
||||
unlink($new_report);
|
||||
$this->response($data, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Sample PDF is Not Available';
|
||||
$this->response($data, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user