89 lines
2.9 KiB
PHP
89 lines
2.9 KiB
PHP
<?php
|
|
|
|
class photo_pdf_converter
|
|
{
|
|
protected $CI = '';
|
|
function __construct()
|
|
{
|
|
//$CI =&get_instance();
|
|
}
|
|
|
|
public function covertImgs2PDF($pdid,$random_string,$pd_master_details = array(),$regenerate = 0)
|
|
{
|
|
//echo 'this is from daiu';
|
|
$CI =&get_instance();
|
|
$CI->load->model('PD_Model');
|
|
$CI->load->library('pdfgenerator');
|
|
|
|
if(!count($pd_master_details))
|
|
{
|
|
$pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string);
|
|
}
|
|
set_time_limit(60);
|
|
if(!file_exists($CI->external_path.'/pd_reports/'.$pdid))
|
|
{
|
|
mkdir($CI->external_path.'/pd_reports/'.$pdid,0777);
|
|
}
|
|
|
|
|
|
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
|
|
$main_applicant_name = $pd_master_details[0]['main_applicant'];
|
|
|
|
//get zip url from s3 if any
|
|
|
|
$key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.pdf';
|
|
|
|
//$singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
|
|
if($pd_master_details[0]['is_img_pdf_created'] && ($regenerate == 0))
|
|
{
|
|
return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days');
|
|
|
|
// $response_data['dataStatus'] = true;
|
|
// $response_data['status'] = REST_Controller::HTTP_OK;
|
|
// $response_data['records'] = $singed_uri;
|
|
// $CI->response($response_data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
$all_pd_images = $CI->PD_Model->getSignedPDDocsURL($pdid,null,null,null,null,'report');
|
|
//print_r(count($all_pd_images));die();
|
|
// $all_form_names = $CI->PD_Model->selectCustomRecords(array('pd_form_id','pd_form_name'),array(),PDFORMS);
|
|
// $form_name = array();
|
|
// foreach($all_form_names as $form)
|
|
// {
|
|
// $form_name[ $form['pd_form_id'] ] = $form['pd_form_name'];
|
|
// }
|
|
$data_to_view['all_pd_images'] = $all_pd_images;
|
|
$img_pdf_data = $CI->load->view('report_templates/PDIMG_PDF',$data_to_view,true);
|
|
//print_r($img_pdf_data);die();
|
|
$pdf_doc = $CI->pdfgenerator->generate($img_pdf_data, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
|
|
//End of PDF Gen using DOM PDF
|
|
$output_file2 = $CI->external_path ."/pd_reports/" . $pdid . "/pd_images_pdf.pdf";
|
|
$ti = file_put_contents($output_file2, $pdf_doc);
|
|
//echo $ti;die();
|
|
|
|
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($output_file2));
|
|
|
|
$s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data);
|
|
//print_r($s3result);
|
|
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
|
|
{
|
|
//$result_array[0]['content']
|
|
$where_condition_array = array("pd_id" => $pdid);
|
|
$temp_array['is_img_pdf_created'] = 1;
|
|
$id = $CI->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
|
|
unlink($output_file2);
|
|
}
|
|
|
|
|
|
|
|
return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days');
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
?>
|