PD REPORT NEW PDF FUNCTION
This commit is contained in:
parent
998bac985c
commit
65030cdc1a
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ api/application/logs/*
|
||||
api/application/syslogs/*
|
||||
api/application/request_logs/*
|
||||
api/application/pd_reports/*
|
||||
api/application/views/pd_reports/*
|
||||
api/application/docs/*
|
||||
!api/application/logs/index.html
|
||||
!api/application/logs/.htaccess
|
||||
|
||||
@ -3916,74 +3916,30 @@ class PD_Controller extends REST_Controller {
|
||||
/*********************************************************************************************
|
||||
*********************************************************************************************/
|
||||
|
||||
//Generate Report AS PDF, currenly not in use.
|
||||
//Generate Report AS PDF
|
||||
public function generatePDReportPDF_post()
|
||||
{
|
||||
$records = $this->post('records');
|
||||
$pdid = $records['pd_id'];
|
||||
$fk_createdby = $records['fk_createdby'];
|
||||
$original_template = "RAW";
|
||||
$is_regenerate = 0;
|
||||
if(isset($records['regenerate']))
|
||||
$is_qc_edited = 0;
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
|
||||
|
||||
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
|
||||
$main_applicant_name = $pd_master_details[0]['main_applicant'];
|
||||
$key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'.pdf';
|
||||
|
||||
if($pd_master_details[0]['is_qc_edited'])
|
||||
{
|
||||
$is_regenerate = 1;
|
||||
$is_qc_edited = 1;
|
||||
}
|
||||
|
||||
$data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid);
|
||||
$data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid);
|
||||
$data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid);
|
||||
$data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly($pdid);
|
||||
$data['pd_score'] = $this->calculateScore($pdid);
|
||||
$data['dsc_cards'] = $this->getDetailedScoreCardChart( $data['pd_score'] );
|
||||
$data['assessed_income_details'] = $this->getAssessedIncomeForPDReport($pdid);
|
||||
$score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],1) : 0;
|
||||
//echo $score_for_chart;
|
||||
|
||||
//GET phantom script from DB
|
||||
$phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => PHANTOMJSSCRIPT_LOCATION),SCRIPTS);
|
||||
|
||||
$exact_script = $phantom_script[0]['script_content'];
|
||||
//print_r($exact_script);
|
||||
$exact_script = str_replace('{{place_score_here}}',$score_for_chart,$exact_script);
|
||||
//print_r($exact_script);die();
|
||||
|
||||
|
||||
//GENERATE CHART PART
|
||||
file_put_contents(APPPATH.'/views/js/phantomchart.js',$exact_script,LOCK_EX);
|
||||
|
||||
$str = 'phantomjs '.APPPATH.'/views/js/phantomchart.js';
|
||||
exec($str,$ou);
|
||||
exec('phantom.exit();');
|
||||
|
||||
//print_r($ou);
|
||||
|
||||
$chart_img_path = APPPATH.'/views/report_templates/chart.png';
|
||||
$type = pathinfo($chart_img_path, PATHINFO_EXTENSION);
|
||||
$chart_img_content = file_get_contents($chart_img_path);
|
||||
$base64_pdscore_chart_url = 'data:image/' . $type . ';base64,' . base64_encode($chart_img_content);
|
||||
$data['base64_pdscore_chart_url'] = $base64_pdscore_chart_url;
|
||||
// echo $data['base64_pdscore_chart_url'];
|
||||
//die();
|
||||
//END OF GENERATE CHART PART
|
||||
|
||||
|
||||
|
||||
|
||||
//GET ALL PROCESSED JSON
|
||||
for($i = 1;$i<=25;$i++)
|
||||
{
|
||||
$fields = array('processed_json');
|
||||
$where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i);
|
||||
$data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC');
|
||||
|
||||
$fields2 = array('*');
|
||||
$data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i);
|
||||
}
|
||||
|
||||
|
||||
$temp = $this->load->view('report_templates/JSONTOREPORT',$data,true);
|
||||
//Save Report as HTML Version with timestamp
|
||||
|
||||
if($is_qc_edited)
|
||||
{
|
||||
//Get Latest PD Report Html file and convert it into PDF
|
||||
$latest_pd_report_html_file_name = $pd_master_details[0]['pd_report_html_filename'];
|
||||
$latest_pd_report_html_file_path = APPPATH.'views/pd_reports/'.$pdid.'/'.$latest_pd_report_html_file_name.'.html';
|
||||
$temp = file_get_contents($latest_pd_report_html_file_path);
|
||||
|
||||
//PDF Gen using DOM PDF
|
||||
$pdf_doc = $this->pdfgenerator->generate($temp, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
|
||||
@ -3991,23 +3947,10 @@ class PD_Controller extends REST_Controller {
|
||||
$output_file2 = APPPATH."/docs/sample.pdf";
|
||||
$bytes = file_put_contents($output_file2, $pdf_doc);
|
||||
|
||||
if(file_put_contents($output_file2, $pdf_doc))
|
||||
{
|
||||
$bucketname = LENDER_BUCKET_NAME_PREFIX.$data['pd_master_details'][0]['fk_lender_id'];
|
||||
$main_applicant_name = $data['pd_master_details'][0]['main_applicant'];
|
||||
$key = "";
|
||||
if($is_regenerate == 0)
|
||||
{
|
||||
$key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'._version0.pdf';
|
||||
}
|
||||
else
|
||||
{
|
||||
$latest_version = $data['pd_master_details'][0]['pd_report_latest_version'] + 1;
|
||||
$key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'.version'.$latest_version.'.pdf';
|
||||
}
|
||||
if(file_put_contents($output_file2, $pdf_doc))
|
||||
{
|
||||
|
||||
$sourcefile = $output_file2;
|
||||
// print_r($sourcefile);
|
||||
// die();
|
||||
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
|
||||
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
//print_r($s3result);
|
||||
@ -4015,37 +3958,20 @@ class PD_Controller extends REST_Controller {
|
||||
{
|
||||
//$result_array[0]['content']
|
||||
$where_condition_array = array("pd_id" => $pdid);
|
||||
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$temp,'pd_report_latest_version' => 0);
|
||||
|
||||
if($is_regenerate != 0)
|
||||
{
|
||||
//$result_array[0]['content']
|
||||
$temp_array = array('is_original_report_created'=>1,'pd_report_latest_version_blob'=>$temp,'pd_report_latest_version'=>$data['pd_master_details'][0]['pd_report_latest_version'] + 1);
|
||||
|
||||
|
||||
}
|
||||
$temp_array['pd_report_generated_date'] = date('Y-m-d h:m:s');
|
||||
$temp_array['is_qc_edited'] = 0;
|
||||
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
|
||||
|
||||
$latest_version = 0;
|
||||
if($is_regenerate != 0){ $latest_version = $data['pd_master_details'][0]['pd_report_latest_version'] + 1; }
|
||||
|
||||
//$result_array[0]['content']
|
||||
$blob_table_temp_array = array('version_no' => $latest_version,'content' => $temp,'fk_pd_id' => $pdid,'fk_createdby' => $fk_createdby);
|
||||
|
||||
$id = $this->PD_Model->saveRecords($blob_table_temp_array,PDREPORTSVERSIONBLOB);
|
||||
|
||||
|
||||
|
||||
//call all reports functionality and send it.
|
||||
$key = 'pd'.$pdid.'/pd_reports/';
|
||||
$urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid);
|
||||
|
||||
|
||||
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
|
||||
|
||||
if($id != null || $id != "" )
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $urls;
|
||||
$data['records'] = $singed_uri;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@ -4057,8 +3983,35 @@ class PD_Controller extends REST_Controller {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}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);
|
||||
}
|
||||
}
|
||||
else //If Qc not edited pull PDF uri from S3
|
||||
{
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
|
||||
|
||||
if($singed_uri != null || $singed_uri != "" )
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $singed_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);
|
||||
}
|
||||
}
|
||||
|
||||
}//funcion end
|
||||
|
||||
|
||||
//Generate Report as HTML File
|
||||
@ -6613,14 +6566,26 @@ class PD_Controller extends REST_Controller {
|
||||
$records = $this->post('records');
|
||||
$pdid = $records['pdid'];
|
||||
$content = $records['content'];
|
||||
$fk_createdby = $records['fk_createdby'];
|
||||
$pd_report_time = date('Y-m-d-h-m-s');
|
||||
$pd_report_store = APPPATH.'views/pd_reports/'.$pdid.'/'.$pd_report_time.'.html';
|
||||
file_put_contents($pd_report_store,$content);
|
||||
|
||||
$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time),PDTRIGGER,array('pd_id' => $pdid));
|
||||
//Update Latest File name and qc edited status into trigger table
|
||||
$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_qc_edited' => 1),PDTRIGGER,array('pd_id' => $pdid));
|
||||
|
||||
if(count($update))
|
||||
//Update previous latest as 0
|
||||
$update_reports_version_blob = $this->PD_Model->updateRecords(array('is_latest' => 0),PDREPORTSVERSIONBLOB,array('fk_pd_id' => $pdid,'is_latest' => 1));
|
||||
|
||||
//insert current PD report html file name as latest
|
||||
$pd_reports_version_blob_new = $this->PD_Model->saveRecords( array('html_file_name' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_latest' => 1,'fk_pd_id' => $pdid),PDREPORTSVERSIONBLOB );
|
||||
|
||||
|
||||
|
||||
if($update && $update_reports_version_blob && $pd_reports_version_blob_new)
|
||||
{
|
||||
$logger = MYLOG::logFunction();
|
||||
$logger->info('QC Edit Called',array('Edited by' => $fk_createdby,'DB Result' => $update .'-'. $update_reports_version_blob .'-'. $pd_reports_version_blob_new));
|
||||
$dat['dataStatus'] = true;
|
||||
$dat['status'] = REST_Controller::HTTP_OK;
|
||||
$dat['msg'] = 'Report Generated Sucessfully..!';
|
||||
|
||||
@ -744,7 +744,7 @@ class PD_Model extends SPARQ_Model {
|
||||
*/
|
||||
public function getPDMasterDetails($pdid)
|
||||
{
|
||||
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y") as pd_report_generated_date,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string');
|
||||
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y") as pd_report_generated_date,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited');
|
||||
$this->db->FROM(PDTRIGGER.' as PDTRIGGER');
|
||||
$this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT');
|
||||
$this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user