SCORE RELEATED

This commit is contained in:
velz 2019-03-15 16:41:19 +05:30
parent 5094f49a18
commit 8fab77c56c
7 changed files with 110 additions and 1385 deletions

View File

@ -530,6 +530,9 @@ defined('PDADDRESSID') OR define('PDADDRESSID','pd_address_id');
defined('PDCOMPANY') OR define('PDCOMPANY','t_pd_company');
defined('PDCOMPANYID') OR define('PDCOMPANYID','pd_company_id');
defined('SCRIPTS') OR define('SCRIPTS','m_scripts');
defined('SCRIPTSID') OR define('SCRIPTSID','script_id');

View File

@ -3552,7 +3552,41 @@ 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'] = $this->calculateScore($pdid);
$data['pd_score'] = $this->calculateScore($pdid);
$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;
//GET phantom script from DB
$phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomjs_dev'),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++)
{
@ -4133,7 +4167,7 @@ class PD_Controller extends REST_Controller {
}
//Get Latest Version from PD Master Table
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
//$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
//Get Blob from blob table
$fields = array('content');
@ -4180,7 +4214,7 @@ class PD_Controller extends REST_Controller {
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$urls = $this->getALLPDReportsSingedURLs($bucketname,$key);
$urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid);
if($id != null || $id != "" )
{
$data['dataStatus'] = true;
@ -4292,21 +4326,31 @@ class PD_Controller extends REST_Controller {
{
$is_regenerate = 1;
}
//print_r($records);die();
//print_r($records);
$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['pd_score'] = $this->calculateScore($pdid);
//print_r($data['pd_score']);
//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;
//echo $score_for_chart;
//GET phantom script from DB
$phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomjs_local'),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
$jsdata = file_get_contents(APPPATH.'/views/js/phantomchart.js');
$jsdata = substr_replace($jsdata,$score_for_chart,(strpos($jsdata,"score")+8),5);
//echo $jsdata;
file_put_contents(APPPATH.'/views/js/phantomchart.js',$jsdata,LOCK_EX);
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';
@ -5346,7 +5390,8 @@ class PD_Controller extends REST_Controller {
//seperate PD Scorable quesitons from JSON
$score_questions = $this->seperateScoreQuestions($form_data,$pd_master_details[0]['is_otp_done']);
//print_r($score_questions);die();
// print_r($score_questions);
// echo "###################################";
//Get Pesrsonal Assets Grid Masters Details
$this->db->SELECT('*');
$this->db->FROM(PERSONALASSETGRID);
@ -5360,7 +5405,8 @@ class PD_Controller extends REST_Controller {
$this->db->WHERE('isactive',1);
$personal_asset_grid['variance_grid'] = $this->db->GET()->result_array();
//print_r($personal_asset_grid);die();
// echo "calculateScore";
// print_r($personal_asset_grid);die();
// Call PD score functions
$combination = $pd_master_details[0]['fk_lender_id'].$pd_master_details[0]['fk_product_id'].$pd_master_details[0]['fk_customer_segment'];
@ -5394,7 +5440,8 @@ class PD_Controller extends REST_Controller {
#####General Form Questions########
$general_form = (json_decode($form_data[18][0]['processed_json'],true));
//print_r($form_data);
// echo "seperateScoreQuestions";
// print_r($general_form);die();
// - QNO (1.7) OTP AUTHENDICATION DONE
@ -5408,6 +5455,10 @@ class PD_Controller extends REST_Controller {
{
$score_questions['general']['person_met_is_applicant'] = 'yes';
}
else
{
$score_questions['general']['person_met_is_applicant'] = 'no';
}
}
$min = count($qualification_temp_array) ? min($qualification_temp_array) : 6;
@ -5425,11 +5476,11 @@ class PD_Controller extends REST_Controller {
#####Address Form Questions########
$address_form = (json_decode($form_data[5][0]['processed_json'],true));
//print_r($address_form);die();
// 4 - QNO(1.2) - Comment on locality
$score_questions['general']['comment_locality'] = $address_form['comment_locality_master'];
$score_questions['general']['comment_locality'] = $address_form['addresses'][0]['comment_locality_master'];
// 5 - QNO(1.3) - pd location approach
$score_questions['general']['pd_location_approach'] = $address_form['pd_location_master'];
$score_questions['general']['pd_location_approach'] = $address_form['addresses'][0]['pd_location_master'];
#####ENd Of Address Form Questions########
@ -5460,7 +5511,7 @@ class PD_Controller extends REST_Controller {
#####Business Form Questions########
$business_form = (json_decode($form_data[13][0]['processed_json'],true));
//print_r($business_form);
//print_r($business_form);die();
// 10 - QNO(1.6) - was_the_company_name_board_sighted
$score_questions['general']['was_the_company_name_board_sighted'] = isset($business_form['was_the_company_name_board_sighted']) ? $business_form['was_the_company_name_board_sighted'] : 'No';
@ -5474,12 +5525,12 @@ class PD_Controller extends REST_Controller {
// 13 - QNO(2.4) - all business certificate
$temp = array();
$temp['shop_eat_act_cert'] = $business_form['shop_eat_act_cert'];
$temp['gst_Regn_cert'] = $business_form['gst_Regn_cert'];
$temp['pf_regn'] = $business_form['pf_regn'];
$temp['esic_regn'] = $business_form['esic_regn'];
$temp['export_import_cert'] = $business_form['export_import_cert'];
$temp['factory_cert'] = $business_form['factory_cert'];
$temp['shop_eat_act_cert'] = isset($business_form['shop_eat_act_cert'])?$business_form['shop_eat_act_cert']:'not applicable';
$temp['gst_Regn_cert'] = isset($business_form['gst_Regn_cert'])?$business_form['gst_Regn_cert']:'not applicable';
$temp['pf_regn'] = isset($business_form['pf_regn'])?$business_form['pf_regn']:'not applicable';
$temp['esic_regn'] = isset($business_form['esic_regn'])?$business_form['esic_regn']:'not applicable';
$temp['export_import_cert'] = isset($business_form['export_import_cert'])?$business_form['export_import_cert']:'not applicable';
$temp['factory_cert'] = isset($business_form['factory_cert'])?$business_form['factory_cert']:'not applicable';
$temp['cert_of_practice'] = isset($business_form['cert_of_practice']) ? $business_form['cert_of_practice']: 'not applicable';
$score_questions['business']['cerificates'] = $temp;
#####End of Business Form Questions########

Binary file not shown.

View File

@ -10,7 +10,7 @@ class PDSCORE
public static function genericDI($score_questions,$pd_master_details,$personal_asset_grid)
{
//print_r($score_questions);
//print_r($score_questions);echo "###################";
############ GENERIC SE-DI CASES #######################
############ SCROE VARIABLES DECLERATIONS ##############
@ -53,7 +53,7 @@ class PDSCORE
//LEVEL3 SCORES - ANSWER SCORES
/*-------- GENERAL --------------*/
$person_met_is_applicant = array('yes' => 10, 'no' => 0);
$pd_location_approach = array('Very Easy to Locate & Reach' => 10,'Easy to locate & Reach' => 7,'Difficult to locate & Reach' => 4,'Very Difficult to locate & Reach' => 2);
$pd_location_approach = array('Very Easy to locate & Reach' => 10,'Easy to locate & Reach' => 7,'Difficult to locate & Reach' => 4,'Very Difficult to locate & Reach' => 2);
$comment_locality = array('Excellent' => 10,'Good' => 7,'Poor' => 5,'Very Poor' => 2);
$customer_behaviour = array('Rude' => 0,'Polite' => 10,'Others' => 0);
$neibourhood_check_as_per_pd_officer = array( 'Positive' => 10, 'Negative' => 0);
@ -96,6 +96,7 @@ class PDSCORE
$score_questions['general']['person_met_is_applicant'] = array('l1_weightage' => $l1_general,'l2_weightage' => $person_met_is_applicant_L2,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['person_met_is_applicant'],'actual_score' => $person_met_is_applicant_actual_score, 'max_score' => $person_met_is_applicant_max_score);
//######1.2 pd_location_approach
$pd_location_approach_actual_score = ($l1_general/100) * ($pd_location_approach_L2/100) * $pd_location_approach[$score_questions['general']['pd_location_approach']];
$pd_location_approach_max_score = ($l1_general/100) * ($pd_location_approach_L2/100) * max($pd_location_approach);
@ -117,7 +118,8 @@ class PDSCORE
$score_questions['general']['customer_behaviour'] = array('l1_weightage' => $l1_general,'l2_weightage' => $customer_behaviour_L2,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['customer_behaviour'],'actual_score' => $customer_behaviour_actual_score, 'max_score' => $customer_behaviour_max_score);
//######1.5 neibourhood_check_as_per_pd_officer
$neibourhood_check_as_per_pd_officer_actual_score = ($l1_general/100) * ($neibourhood_check_as_per_pd_officer_L2/100) * $neibourhood_check_as_per_pd_officer[$score_questions['general']['neibourhood_check_as_per_pd_officer']];
$neibourhood_check_as_per_pd_officer_actual_score = ($l1_general/100) * ($neibourhood_check_as_per_pd_officer_L2/100) * $neibourhood_check_as_per_pd_officer[$score_questions['general']['neibourhood_check_as_per_pd_officer'] != "" || $score_questions['general']['neibourhood_check_as_per_pd_officer'] != null ?$score_questions['general']['neibourhood_check_as_per_pd_officer']: "Negative" ];
$neibourhood_check_as_per_pd_officer_max_score = ($l1_general/100) * ($neibourhood_check_as_per_pd_officer_L2/100) * max($neibourhood_check_as_per_pd_officer);
@ -240,7 +242,7 @@ class PDSCORE
//######2.10 stock_finished_goods_enough
$stock_finished_goods_enough_L2 = $business_distribute_level_weightage ? ($stock_finished_goods_enough_L2 + ($stock_finished_goods_enough_L2 / (100 - $business_distribute_level_weightage ))) : $stock_finished_goods_enough_L2 ;
$stock_finished_goods_enough_actual_score = ($l1_business/100) * ($stock_finished_goods_enough_L2/100) * $stock_answer_scores [ $score_questions['business']['stock_finished_goods_enough'] ];
$stock_finished_goods_enough_actual_score = ($l1_business/100) * ($stock_finished_goods_enough_L2/100) * $stock_answer_scores [ $score_questions['business']['stock_finished_goods_enough'] != "" || $score_questions['business']['stock_finished_goods_enough'] != null ? $score_questions['business']['stock_finished_goods_enough'] : "no" ];
$stock_finished_goods_enough_max_score = strcasecmp($score_questions['business']['stock_finished_goods_enough'],'Not Applicable') ? ($l1_business/100) * ($stock_finished_goods_enough_L2/100) * max($stock_answer_scores) : 0;

View File

@ -1,12 +1 @@
var page = require('webpage').create();
page.viewportSize = { width: 600, height: 350 };
page.clipRect = { top: 0, left: 0, width: 600, height: 350 };
var score = 69.08 ;
console.log('score card chart');
var url = 'http://localhost:9999/AWSEC2/sparqapi/api?'+score;
page.open(url, function() {
setTimeout(function() {
page.render('C:/5.6/xampp/htdocs/AWSEC2/sparqapi/api/application/views/report_templates/chart.png');
phantom.exit();
}, 500);
});
var page = require('webpage').create();page.viewportSize = { width: 600, height: 350 };page.clipRect = { top: 0, left: 0, width: 600, height: 350 };var score = 51;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);});

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 18 KiB