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/application/docs/sample.pdf b/api/application/docs/sample.pdf index a6dd6594..2178e9b6 100644 Binary files a/api/application/docs/sample.pdf and b/api/application/docs/sample.pdf differ diff --git a/api/application/docs/temp.html b/api/application/docs/temp.html index bbf6ef0d..f570edbb 100644 --- a/api/application/docs/temp.html +++ b/api/application/docs/temp.html @@ -4,7 +4,7 @@

Hope 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;