diff --git a/api/application/config/constants.php b/api/application/config/constants.php index ed1c5e4f..6f06b0a9 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -94,6 +94,7 @@ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME',' if(ENVIRONMENT == 'development') { defined('SATELLITE_IMAGE_LOCATION') OR define('SATELLITE_IMAGE_LOCATION','phantomsatellite_dev'); +defined('DETAILED_SCORE_CARD_IMAGE_LOCATION') OR define('DETAILED_SCORE_CARD_IMAGE_LOCATION','phantom_dsc_dev'); defined('LENDER_BUCKET_NAME_PREFIX') OR define('LENDER_BUCKET_NAME_PREFIX','lender'); defined('PHANTOMJSSCRIPT_LOCATION') OR define('PHANTOMJSSCRIPT_LOCATION','phantomjs_dev'); defined('LOGTOBOT') OR define('LOGTOBOT',0); @@ -102,6 +103,7 @@ defined('GOOGLE_STATIC_MAP_API_KEY') OR define('GOOGLE_STATIC_MAP_API_KEY','AIza else if(ENVIRONMENT == 'testing') { defined('SATELLITE_IMAGE_LOCATION') OR define('SATELLITE_IMAGE_LOCATION','phantomsatellite_test'); + defined('DETAILED_SCORE_CARD_IMAGE_LOCATION') OR define('DETAILED_SCORE_CARD_IMAGE_LOCATION','phantom_dsc_test'); defined('LENDER_BUCKET_NAME_PREFIX') OR define('LENDER_BUCKET_NAME_PREFIX','len'); defined('PHANTOMJSSCRIPT_LOCATION') OR define('PHANTOMJSSCRIPT_LOCATION','phantomjs_test'); defined('LOGTOBOT') OR define('LOGTOBOT',0); diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 5c96369a..b86ee58b 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -785,9 +785,9 @@ class PD_Controller extends REST_Controller { } - + print_r($pd_details); } - + die(); if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == TRIGGERED || $pd_details['pd_status'] == INITIATED)) { @@ -3931,7 +3931,7 @@ class PD_Controller extends REST_Controller { $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'] ); $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; @@ -4698,18 +4698,26 @@ class PD_Controller extends REST_Controller { function getSatelliteImage($pd_id) { $pdid = $pd_id; - $pdmas = $this->PD_Model->getPDMasterDetails($pdid); + $pdmas = $this->PD_Model->getPDMasterDetails($pdid); + print_r($pdmas); //load satellite script from db - //$satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomsatellite_local'),SCRIPTS); - $satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => SATELLITE_IMAGE_LOCATION),SCRIPTS); + $satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomsatellite_local'),SCRIPTS); + //$satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => SATELLITE_IMAGE_LOCATION),SCRIPTS); $satellite_script = $satellite_script_from_db[0]['script_content']; + //Get Address Data - $address =$pdmas[0]['addressline1'].','.$pdmas[0]['city_name'].','.$pdmas[0]['state_name']; + echo $pdmas[0]['addressline1']; + $address = $pdmas[0]['addressline1'].','.$pdmas[0]['city_name'].','.$pdmas[0]['state_name']; + echo $address; + //Replacing space with + symbol + $address =str_replace(' ','+',$address); + $address =str_replace('\n','+',$address); $geo_location = $pdmas[0]['start_location']; $google_map_static_api_key = GOOGLE_STATIC_MAP_API_KEY; - + echo "*****"; + echo $address; //Replacing Place holders @@ -4717,6 +4725,7 @@ class PD_Controller extends REST_Controller { $satellite_script = str_replace('{{GEOLOCATION}}',$geo_location,$satellite_script); $satellite_script = str_replace('{{API_KEY}}',$google_map_static_api_key,$satellite_script); + echo $satellite_script;die(); file_put_contents(APPPATH.'/views/js/phantomsatellite.js',$satellite_script); //call& execute phantom script @@ -4734,11 +4743,65 @@ class PD_Controller extends REST_Controller { return $base64_pdscore_chart_url; } + + function getDetailedScoreCardChart($score) + { + + $business_score['business'] = $score['business']; + //$general_score['general'] = array_merge($score['general'],$score['final_remarks']); + $general_score['general'] = $score['general']; + + // print_r($general_score['general']);die(); + + $data = array(); + $img_name = ''; + + for($i = 1;$i < 3;$i++) + { + + // Incase running from local windows (Velz sys) + //$dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantom_dsc_local'),SCRIPTS); + + $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); + + $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; } + + } + + return $data; + + + } + public function codeigniterViewTest_post() { - - - + $records = $this->post('records'); $pdid = $records['pd_id']; $is_regenerate = 0; @@ -4750,21 +4813,14 @@ class PD_Controller extends REST_Controller { $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(); - $data['pd_score'] = $this->calculateScore($pdid); + $data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly(); + $data['pd_score'] = $this->calculateScore($pdid); - $remp = array(); - foreach($data['pd_score']['general'] as $key => $da) - { - //$remp = array_merge($remp,array($key => (string)($da['attributed_score'] * 100))); - $remp = array_merge($remp,array($key)); - } - print_r($remp); - //die(); - print_r(json_encode($remp,true));die(); - // $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],2) : 0; + $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; //echo $score_for_chart; - $chart = null; + $chart = 1; if($chart) { //GET phantom script from DB diff --git a/api/application/docs/sample.pdf b/api/application/docs/sample.pdf index 5c5dbe32..d718fe47 100644 Binary files a/api/application/docs/sample.pdf and b/api/application/docs/sample.pdf differ diff --git a/api/application/views/businees_scorecard.php b/api/application/views/businees_scorecard.php deleted file mode 100644 index 6ceead5f..00000000 --- a/api/application/views/businees_scorecard.php +++ /dev/null @@ -1,114 +0,0 @@ - - - - -
- - - - - - - - - - - - \ No newline at end of file diff --git a/api/application/views/business_scorecard.php b/api/application/views/business_scorecard.php new file mode 100644 index 00000000..e3e8f565 --- /dev/null +++ b/api/application/views/business_scorecard.php @@ -0,0 +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 diff --git a/api/application/views/general_scorecard.php b/api/application/views/general_scorecard.php new file mode 100644 index 00000000..c8fd95e7 --- /dev/null +++ b/api/application/views/general_scorecard.php @@ -0,0 +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 diff --git a/api/application/views/js/phantomchart.js b/api/application/views/js/phantomchart.js index 962ab575..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 = 52.6;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 new file mode 100644 index 00000000..bb1b39a8 --- /dev/null +++ b/api/application/views/js/phantomdsc.js @@ -0,0 +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 diff --git a/api/application/views/js/phantomsatellite.js b/api/application/views/js/phantomsatellite.js index cdeeebd8..34c1e172 100644 --- a/api/application/views/js/phantomsatellite.js +++ b/api/application/views/js/phantomsatellite.js @@ -1 +1,2 @@ -var page = require('webpage').create();page.viewportSize = { width: 650, height: 250 };page.clipRect = { top: 0, left: 0, width: 500, height: 250 };var score = 78;var url = 'https://maps.googleapis.com/maps/api/staticmap?center=CORGO INDIA ENTERPRISES B 19 8 FIRST FLOOR,JOSHI COLONY PATPARGANJ,New Delhi,Delhi,IND&zoom=14&markers=color:red|28.6282898,77.3025616&size=800x300&maptype=roadmap&key=AIzaSyCXsHTus6hyIB8jYvt9ZEIbZve-2vWeQRg';var image_url ='C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/satellite.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: 650, height: 250 };page.clipRect = { top: 0, left: 0, width: 500, height: 250 };var score = 78;var url = 'https://maps.googleapis.com/maps/api/staticmap?center=25,+NORTH+STREET, +MAMBALAM,Erode,Tamil+Nadu,IND&zoom=14&markers=color:red|12.9202935,80.1685205&size=800x300&maptype=roadmap&key=AIzaSyCXsHTus6hyIB8jYvt9ZEIbZve-2vWeQRg';var image_url ='C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/satellite.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/report_templates/JSONTOREPORT.php b/api/application/views/report_templates/JSONTOREPORT.php index f4f557be..88716960 100644 --- a/api/application/views/report_templates/JSONTOREPORT.php +++ b/api/application/views/report_templates/JSONTOREPORT.php @@ -365,6 +365,31 @@ defined('BASEPATH') OR exit('No direct script access allowed'); { echo "Score Chart Not Generated"; } + + //######################### CHART ########################### + + + if(isset($dsc_cards['base64_dsc_business'])) + { + echo "