PD REPORTS3
This commit is contained in:
parent
bcb68afe22
commit
e3295a980f
@ -71,7 +71,7 @@ class Entity_Management_Controller extends REST_Controller {
|
|||||||
$bucket_status = $this->aws_s3->createNewBucket($bucket_name);
|
$bucket_status = $this->aws_s3->createNewBucket($bucket_name);
|
||||||
if($bucket_status['Location'])
|
if($bucket_status['Location'])
|
||||||
{
|
{
|
||||||
$cors_status = $this->aws_s3->setCors($bucket_name)
|
$cors_status = $this->aws_s3->setCors($bucket_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
|
|
||||||
|
|
||||||
require_once APPPATH . '/libraries/REST_Controller.php';
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||||
|
require_once APPPATH . '/libraries/Smartie.php';
|
||||||
|
|
||||||
|
|
||||||
class PD_Controller extends REST_Controller {
|
class PD_Controller extends REST_Controller {
|
||||||
@ -22,6 +23,7 @@ class PD_Controller extends REST_Controller {
|
|||||||
$this->load->library('AWS_SNS');
|
$this->load->library('AWS_SNS');
|
||||||
$this->load->helper('GETPDFORMDETAILS');
|
$this->load->helper('GETPDFORMDETAILS');
|
||||||
$this->load->library('pdfgenerator');
|
$this->load->library('pdfgenerator');
|
||||||
|
//$this->load->library('smarty');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2674,7 +2676,7 @@ class PD_Controller extends REST_Controller {
|
|||||||
$key = "";
|
$key = "";
|
||||||
if($is_regenerate == 0)
|
if($is_regenerate == 0)
|
||||||
{
|
{
|
||||||
$key = 'pd'.$pdid.'/pd_reports/pd_report_original_version.pdf';
|
$key = 'pd'.$pdid.'/pd_reports/version0.pdf';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2690,16 +2692,18 @@ class PD_Controller extends REST_Controller {
|
|||||||
{
|
{
|
||||||
|
|
||||||
$where_condition_array = array("pd_id" => $pdid);
|
$where_condition_array = array("pd_id" => $pdid);
|
||||||
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$result_array[0]['content']);
|
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$result_array[0]['content'],'pd_report_latest_version' => 0);
|
||||||
|
|
||||||
if($is_regenerate != 0)
|
if($is_regenerate != 0)
|
||||||
{
|
{
|
||||||
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$result_array[0]['content'],'pd_report_latest_version'=>$latest_version);
|
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$result_array[0]['content'],'pd_report_latest_version'=>$pd_master_details[0]['pd_report_latest_version'] + 1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
|
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
|
||||||
|
|
||||||
|
$latest_version = 0;
|
||||||
|
if($is_regenerate != 0){ $latest_version = $pd_master_details[0]['pd_report_latest_version'] + 1; }
|
||||||
$blob_table_temp_array = array('version_no' => $latest_version,'content' => $result_array[0]['content'],'fk_pd_id' => $pdid,'fk_createdby' => $fk_createdby);
|
$blob_table_temp_array = array('version_no' => $latest_version,'content' => $result_array[0]['content'],'fk_pd_id' => $pdid,'fk_createdby' => $fk_createdby);
|
||||||
|
|
||||||
$id = $this->PD_Model->saveRecords($blob_table_temp_array,PDREPORTSVERSIONBLOB);
|
$id = $this->PD_Model->saveRecords($blob_table_temp_array,PDREPORTSVERSIONBLOB);
|
||||||
@ -2821,6 +2825,7 @@ class PD_Controller extends REST_Controller {
|
|||||||
|
|
||||||
$pdid = $records['pd_id'];
|
$pdid = $records['pd_id'];
|
||||||
|
|
||||||
|
|
||||||
//Get PD Master Details
|
//Get PD Master Details
|
||||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
|
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
|
||||||
|
|
||||||
@ -2829,7 +2834,7 @@ class PD_Controller extends REST_Controller {
|
|||||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id;
|
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id;
|
||||||
$key = 'pd'.$pdid.'/pd_reports';
|
$key = 'pd'.$pdid.'/pd_reports';
|
||||||
//$key = 'pd'.$pdid;
|
//$key = 'pd'.$pdid;
|
||||||
$urls = $this->getALLPDReportsSingedURLs($bucket_name,$key);
|
$urls = $this->getALLPDReportsSingedURLs($bucket_name,$key,$pdid);
|
||||||
|
|
||||||
if(count($urls))
|
if(count($urls))
|
||||||
{
|
{
|
||||||
@ -2855,8 +2860,25 @@ class PD_Controller extends REST_Controller {
|
|||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
*********************************************************************************************/
|
*********************************************************************************************/
|
||||||
public function getALLPDReportsSingedURLs($bucket_name,$key)
|
public function getALLPDReportsSingedURLs($bucket_name,$key,$pdid)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Get Blob version
|
||||||
|
$fields = array('version_no','concat(USERPROFILE.first_name,USERPROFILE.last_name) as createdby','DATE_FORMAT(PDREPORTSVERSIONBLOB.createdon,"%d %b %Y at %h:%i:%s %p") as createdon','PDREPORTSVERSIONBLOB.fk_createdby');
|
||||||
|
$where_condition_array = array('fk_pd_id'=>$pdid);
|
||||||
|
$table = PDREPORTSVERSIONBLOB.' as PDREPORTSVERSIONBLOB';
|
||||||
|
$joins = array( array('table' => USERPROFILE. ' as USERPROFILE',
|
||||||
|
'condition' =>'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid',
|
||||||
|
'jointype' => 'INNER')
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
//Get Max No of blob version
|
||||||
|
$max_version = $this->db->SELECT('MAX(version_no) as max_version')->FROM(PDREPORTSVERSIONBLOB)->WHERE('fk_pd_id',$pdid)->GET()->result_array();
|
||||||
|
|
||||||
|
$blob_versions = $this->PD_Model->getJoinRecords($fields,$table,$joins,$where_condition_array);
|
||||||
|
|
||||||
|
//print_r($max_version);
|
||||||
$all_objects = $this->aws_s3->getAllObjectsInaBucket($bucket_name,$key);
|
$all_objects = $this->aws_s3->getAllObjectsInaBucket($bucket_name,$key);
|
||||||
$uri = array();
|
$uri = array();
|
||||||
foreach($all_objects as $obj)
|
foreach($all_objects as $obj)
|
||||||
@ -2867,18 +2889,55 @@ class PD_Controller extends REST_Controller {
|
|||||||
//print_r($uri);
|
//print_r($uri);
|
||||||
if(count($uri))
|
if(count($uri))
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach($uri as $uri_key => $url)
|
foreach($uri as $uri_key => $url)
|
||||||
{
|
{
|
||||||
$uri[$uri_key]['doc_uri'] = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$url['doc_name'],$time = '3600 seconds');
|
$uri[$uri_key]['doc_uri'] = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$url['doc_name'],$time = '3600 seconds');
|
||||||
//echo $key;
|
//echo $key;
|
||||||
$uri[$uri_key]['doc_name'] = str_replace($key.'/',"",$uri[$uri_key]['doc_name']);
|
$uri[$uri_key]['doc_name'] = str_replace($key.'/',"",$uri[$uri_key]['doc_name']);
|
||||||
if($uri_key == (count($uri)-1))
|
|
||||||
{
|
//find version no from file
|
||||||
$uri[$uri_key]['is_latest'] = 1;
|
$version_no = 0;
|
||||||
}else
|
|
||||||
{
|
if(is_numeric(substr($uri[$uri_key]['doc_name'],-7,3)))
|
||||||
$uri[$uri_key]['is_latest'] = 0;
|
{
|
||||||
}
|
$version_no = substr($uri[$uri_key]['doc_name'],-7,3);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(is_numeric(substr($uri[$uri_key]['doc_name'],-6,2)))
|
||||||
|
{
|
||||||
|
$version_no = substr($uri[$uri_key]['doc_name'],-6,2);
|
||||||
|
|
||||||
|
}else if(is_numeric(substr($uri[$uri_key]['doc_name'],-5,1)))
|
||||||
|
{
|
||||||
|
$version_no = substr($uri[$uri_key]['doc_name'],-5,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uri[$uri_key]['version'] = (int)$version_no;
|
||||||
|
|
||||||
|
if(count($blob_versions))
|
||||||
|
{
|
||||||
|
foreach($blob_versions as $blob_key => $blob)
|
||||||
|
{
|
||||||
|
if($blob['version_no'] == $version_no)
|
||||||
|
{
|
||||||
|
$uri[$uri_key]['createdby'] = $blob['createdby'];
|
||||||
|
$uri[$uri_key]['createdon'] = $blob['createdon'];
|
||||||
|
}
|
||||||
|
$uri[$uri_key]['is_latest'] = 0;
|
||||||
|
if(($blob['version_no'] == $max_version[0]['max_version']) &&($version_no == $max_version[0]['max_version']))
|
||||||
|
{
|
||||||
|
$uri[$uri_key]['is_latest'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if($uri_key == (count($uri)-1))
|
||||||
|
// {
|
||||||
|
// $uri[$uri_key]['is_latest'] = 1;
|
||||||
|
// }else
|
||||||
|
// {
|
||||||
|
// $uri[$uri_key]['is_latest'] = 0;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2979,7 +3038,7 @@ class PD_Controller extends REST_Controller {
|
|||||||
$temp_array = array('pd_report_latest_version_blob' => $result[0]['content'],'pd_report_latest_version' => ($pd_master_details[0]['pd_report_latest_version'] + 1));
|
$temp_array = array('pd_report_latest_version_blob' => $result[0]['content'],'pd_report_latest_version' => ($pd_master_details[0]['pd_report_latest_version'] + 1));
|
||||||
|
|
||||||
$where_condition_array = array('pd_id'=>$pdid);
|
$where_condition_array = array('pd_id'=>$pdid);
|
||||||
$master_result = $this->PD_Model->updateRecords($temp_array,$where_condition_array,PDTRIGGER);
|
$master_result = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
|
||||||
|
|
||||||
if($master_result != null || $master_result != "")
|
if($master_result != null || $master_result != "")
|
||||||
{
|
{
|
||||||
@ -3062,4 +3121,21 @@ class PD_Controller extends REST_Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************
|
||||||
|
*********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
public function smartyTestFunction_post()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$this->smarty->assign('title','Test Title');
|
||||||
|
$this->smarty->assign('description', 'Test Description');
|
||||||
|
//$this->smarty->display('index.tpl');
|
||||||
|
$data['Name'] = 'test namenkenk';
|
||||||
|
$fin = $this->smarty->view('index.tpl' , $data);
|
||||||
|
echo "dsds";
|
||||||
|
print_r($fin);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user