diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index c3f33342..9829fcec 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -4754,11 +4754,10 @@ class PD_Controller extends REST_Controller { function getDetailedScoreCardChart($score) { - $business_score['business'] = $score['business']; - //$general_score['general'] = array_merge($score['general'],$score['final_remarks']); + $general_score['general'] = $score['general']; - + $logger = MYLOG::logFunction(); // print_r($general_score['general']);die(); $data = array(); @@ -4772,36 +4771,49 @@ class PD_Controller extends REST_Controller { $dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => DETAILED_SCORE_CARD_IMAGE_LOCATION),SCRIPTS); - $dsc_script_from_db = $dsc_script_from_db[0]['script_content']; - //print_r($dsc_script_from_db); + if(count($dsc_script_from_db)) + { + + + $dsc_script_from_db = $dsc_script_from_db[0]['script_content']; + //print_r($dsc_script_from_db); + + $html_content = ""; + if($i == 1){ $html_content = $this->load->view('business_scorecard',$business_score,true); } + + else if($i == 2) { $html_content = $this->load->view('general_scorecard',$general_score,true);} + //print_r($html_content); + $dsc_script_from_db = str_replace('{{html_content}}',$html_content,$dsc_script_from_db); + $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}','dsc_business',$dsc_script_from_db) : str_replace('{{img_name}}','dsc_general',$dsc_script_from_db); + + + $logger->info('Score Card Graphical Representation called',array('card_type' => $i,'script' => $dsc_script_from_db)); + //echo $dsc_script_from_db; + //echo "*************"; + file_put_contents(APPPATH.'/views/js/phantomdsc.js',$dsc_script_from_db); + + //call& execute phantom script + $str = 'phantomjs '.APPPATH.'/views/js/phantomdsc.js'; + exec($str,$ou); + exec('phantom.exit();'); + + + // //convert as base 64 image. + $dsc_image_png_path = $i == 1 ? APPPATH.'/views/report_templates/dsc_business.png' : APPPATH.'/views/report_templates/dsc_general.png'; + $type = pathinfo($dsc_image_png_path, PATHINFO_EXTENSION); + $dsc_img_content = file_get_contents($dsc_image_png_path); + $base64_dsc_url = 'data:image/' . $type . ';base64,' . base64_encode($dsc_img_content); + if($i == 1){ $data['base64_dsc_business'] = $base64_dsc_url; } + else if($i == 2){ $data['base64_dsc_general'] = $base64_dsc_url; } - $html_content = ""; - if($i == 1){ $html_content = $this->load->view('business_scorecard',$business_score,true); } - - else if($i == 2) { $html_content = $this->load->view('general_scorecard',$general_score,true);} - //print_r($html_content); - $dsc_script_from_db = str_replace('{{html_content}}',$html_content,$dsc_script_from_db); - $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}','dsc_business',$dsc_script_from_db) : str_replace('{{img_name}}','dsc_general',$dsc_script_from_db); - //echo $dsc_script_from_db; - //echo "*************"; - file_put_contents(APPPATH.'/views/js/phantomdsc.js',$dsc_script_from_db); - - //call& execute phantom script - $str = 'phantomjs '.APPPATH.'/views/js/phantomdsc.js'; - exec($str,$ou); - exec('phantom.exit();'); - - - // //convert as base 64 image. - $dsc_image_png_path = $i == 1 ? APPPATH.'/views/report_templates/dsc_business.png' : APPPATH.'/views/report_templates/dsc_general.png'; - $type = pathinfo($dsc_image_png_path, PATHINFO_EXTENSION); - $dsc_img_content = file_get_contents($dsc_image_png_path); - $base64_dsc_url = 'data:image/' . $type . ';base64,' . base64_encode($dsc_img_content); - if($i == 1){ $data['base64_dsc_business'] = $base64_dsc_url; } - else if($i == 2){ $data['base64_dsc_general'] = $base64_dsc_url; } - + } } - + else + { + $logger->error('SCORE CARD SCRIPT NOT FOUND'); + } + // print_r($data); + // die(); return $data; @@ -4853,9 +4865,9 @@ class PD_Controller extends REST_Controller { // echo "**************************"; $data['dsc_cards'] = $this->getDetailedScoreCardChart( $data['pd_score'] ); - //$score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],2) : 0; + $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],2) : 0; //echo $score_for_chart; - $chart = null; + $chart = 1; if($chart) { //GET phantom script from DB @@ -4880,10 +4892,11 @@ class PD_Controller extends REST_Controller { $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']; + //echo $data['base64_pdscore_chart_url']; //GENERATE CHART PART } + //die(); //GET ALL PROCESSED JSON for($i = 1;$i<=25;$i++) { @@ -5815,7 +5828,7 @@ class PD_Controller extends REST_Controller { { $records = $this->post('records'); - $company_id = $records['company_id'] ? $records['company_id'] : null; + $company_id = isset($records['company_id']) && $records['company_id']? $records['company_id'] : null; $res = $this->saveBase64Images($records['pd_id'],$records['formid'],$company_id,$records['images']); if(count($res)) diff --git a/api/application/docs/sample.pdf b/api/application/docs/sample.pdf index 57de9d00..00761ba1 100644 Binary files a/api/application/docs/sample.pdf and b/api/application/docs/sample.pdf differ diff --git a/api/application/views/business_scorecard.php b/api/application/views/business_scorecard.php index e99747d4..aae91c18 100644 --- a/api/application/views/business_scorecard.php +++ b/api/application/views/business_scorecard.php @@ -1,3 +1,3 @@ "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>","owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Shared >>", "minimum_client_info" => "Client Information Shared >>","stock_raw_material_enough" => "Sufficiency of RM Stock Observed >>", "stock_finished_goods_enough" => "Sufficiency of Finished / Traded Stock Observed >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>");$descriptions = '';$score = '';if(isset($business) && count($business)){;foreach($business as $key => $d){$descriptions .= '"'.$business_captions [$key].'",'; $score .= ($d['attributed_score'] * 100).',';}} -?>
\ No newline at end of file +$business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>","owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Shared >>", "minimum_client_info" => "Client Information Shared >>","stock_raw_material_enough" => "Sufficiency of Raw Materials Stock Observed >>", "stock_finished_goods_enough" => "Sufficiency of Finished/Traded Stock Observed >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>");$descriptions = '';$score = '';if(isset($business) && count($business)){foreach($business as $key => $d){$descriptions .= '"'.$business_captions [$key].'",'; $score .= $d['attributed_score'] != 0 && $d['max_score'] != 0 ? (($d['attributed_score']/$d['max_score']) * 100).',' : '0'.',';}} +?> \ No newline at end of file diff --git a/api/application/views/general_scorecard.php b/api/application/views/general_scorecard.php index e81f739f..b40bb974 100644 --- a/api/application/views/general_scorecard.php +++ b/api/application/views/general_scorecard.php @@ -1,3 +1,3 @@ "OTP authentication done >>","person_met_is_applicant" => "Is person Met, one of the loan applicants? >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Name Board of the Business Seen >>","value_of_other_assets" => "Value of Assets as a % of Loan Amount >>");$descriptions = '';$score = '';if(isset($general) && count($general)){;foreach($general as $key => $d){$descriptions .= '"'.$general_captions [$key].'",'; $score .= ($d['attributed_score'] * 100).',';}} -?> \ No newline at end of file +$general_captions = array("otp_done" => "OTP authentication done >>","person_met_is_applicant" => "Is person Met, one of the loan applicants? >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Name Board of the Business Seen >>","value_of_other_assets" => "Value of Assets as a % of Loan Amount >>");$descriptions = '';$score = '';if(isset($general) && count($general)){foreach($general as $key => $d){$descriptions .= '"'.$general_captions [$key].'",'; $score .= $d['attributed_score'] != 0 && $d['max_score'] != 0 ? (($d['attributed_score']/$d['max_score']) * 100).',' : '0'.',';}} +?> \ No newline at end of file diff --git a/api/application/views/js/phantomchart.js b/api/application/views/js/phantomchart.js index 2c0759cc..9c68059e 100644 --- a/api/application/views/js/phantomchart.js +++ b/api/application/views/js/phantomchart.js @@ -1 +1 @@ -var page = require('webpage').create();page.viewportSize = { width: 600, height: 350 };page.clipRect = { top: 0, left: 0, width: 600, height: 350 };var score = ;var url = 'http://localhost:9999/AWSEC2/sparqapi/api?'+score;var image_url = 'C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/chart.png' ;page.open(url,function() {setTimeout(function() {page.render(image_url);phantom.exit();}, 500);}); \ No newline at end of file +var page = require('webpage').create();page.viewportSize = { width: 600, height: 350 };page.clipRect = { top: 0, left: 0, width: 600, height: 350 };var score = 50.94;var url = 'http://localhost:9999/AWSEC2/sparqapi/api?'+score;var image_url = 'C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/chart.png' ;page.open(url,function() {setTimeout(function() {page.render(image_url);phantom.exit();}, 500);}); \ No newline at end of file diff --git a/api/application/views/js/phantomdsc.js b/api/application/views/js/phantomdsc.js index 3e77f23f..8cbcab6f 100644 --- a/api/application/views/js/phantomdsc.js +++ b/api/application/views/js/phantomdsc.js @@ -1 +1 @@ -var wpage = require('webpage').create();var Content = ' ';var pageurl = 'C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/dsc.html'; wpage.viewportSize = { width: 810, height: 250 };wpage.setContent(Content, pageurl); wpage.onLoadFinished = function(status){wpage.render('C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/dsc_general.png'); phantom.exit();}; \ No newline at end of file +var wpage = require('webpage').create();var Content = ' ';var pageurl = 'C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/dsc.html'; wpage.viewportSize = { width: 810, height: 250 };wpage.setContent(Content, pageurl); wpage.onLoadFinished = function(status){wpage.render('C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/dsc_general.png'); phantom.exit();}; \ No newline at end of file diff --git a/api/application/views/report_templates/dsc_business.png b/api/application/views/report_templates/dsc_business.png index 35f2e7ca..0c5441fe 100644 Binary files a/api/application/views/report_templates/dsc_business.png and b/api/application/views/report_templates/dsc_business.png differ diff --git a/api/application/views/report_templates/dsc_general.png b/api/application/views/report_templates/dsc_general.png index 9ec8a11f..9fcefa2a 100644 Binary files a/api/application/views/report_templates/dsc_general.png and b/api/application/views/report_templates/dsc_general.png differ