diff --git a/api/application/config/constants.php b/api/application/config/constants.php index edce70e2..91802b17 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -132,7 +132,7 @@ else if(ENVIRONMENT == 'production') 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','pdgenie-lender'); - defined('PHANTOMJSSCRIPT_LOCATION') OR define('PHANTOMJSSCRIPT_LOCATION','phantomjs_test'); + defined('PHANTOMJSSCRIPT_LOCATION') OR define('PHANTOMJSSCRIPT_LOCATION','phantomjs_prod'); defined('LOGTOBOT') OR define('LOGTOBOT',0); defined('GOOGLE_STATIC_MAP_API_KEY') OR define('GOOGLE_STATIC_MAP_API_KEY','AIzaSyA3lYDYxwtn5vLSl45SOKbtK7G6cEyXGr0'); defined('FIREBASE_PUSH_NOTIFICATION_SERVER_API_KEY') OR define('FIREBASE_PUSH_NOTIFICATION_SERVER_API_KEY','AAAA0yTIWHY:APA91bGuBHAEn1NcX95Uudm847Ez2AIbqqmi5698trFPx0cIs0OTXWUNu7c5DKDJlbxPBILytBGC5cEHqEy08AQZGu_rpCE4hyvoHyCDkOjuwhA3DFNMQDpMU6XxDDJXCI1zjhHRuEQr'); diff --git a/api/application/controllers/Common_Masters_Controller.php b/api/application/controllers/Common_Masters_Controller.php index f56d556a..5e096ef2 100644 --- a/api/application/controllers/Common_Masters_Controller.php +++ b/api/application/controllers/Common_Masters_Controller.php @@ -1173,7 +1173,19 @@ class Common_Masters_Controller extends REST_Controller { public function checkAppVersion_get() { $client = $this->get('client'); - $version_data = $this->Common_Masters_Model-> getAppVersion($client); + $headersData = getallheaders(); + $td = jwt::decode($headersData['Token']); + $version_data = array(); + //print_r($d);die(); + $td = (array)($td); + if($td['aud'] == '5dvpr90r2na4te5k0qrint0m5i' || $td['aud'] == '5kv697clegac0bcmd49o9di2t2' && ($td['custom:role_id'] == 21 || $td['custom:role_id'] == 22)) + { + $version_data = array("version_info_id" => "1","version" => "0.0.4","release_notes" => "Filed Visit"); + } + else + { + $version_data = $this->Common_Masters_Model-> getAppVersion($client); + } if($version_data) { diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index fd7a5a54..feec1168 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -6762,6 +6762,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() // print_r($company_list);die(); if(count($company_list)) { + if($pd_master_details[0]['fk_pd_type'] == 2) + { + $vendor_form_status = $this->PD_Model->getVendorFormStatus($pd_id); + $company_list[0]['vendor_form_status'] = $vendor_form_status; + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $company_list; diff --git a/api/application/helpers/pdcompletenesscheck_helper.php b/api/application/helpers/pdcompletenesscheck_helper.php index 1a643054..9c8925d3 100644 --- a/api/application/helpers/pdcompletenesscheck_helper.php +++ b/api/application/helpers/pdcompletenesscheck_helper.php @@ -93,23 +93,23 @@ class pdcompletenesscheck } //check that all pd genie forms get fetched with vendor answers - // if($vendor_done_status == 0) - // { - // $smart_pd_forms = array('18' => 'General Information','5' => 'Address Details','13' => 'Business Information' ,'19' => 'Neighbourhood / Reference','20' => 'Final Remarks Form','24' => 'Credit Manager Queries','22' => 'Business Assets','12' => 'Employment Information','11' => 'Stock Details'); - // $unfetched_forms = ''; - // $vendor_form_status = $CI->PD_Model->getVendorFormStatus($pdid); - // //print_r($vendor_form_status);die(); - // foreach ($vendor_form_status as $key => $value) - // { - // if(!$value['form_status']){ $unfetched_forms .= $smart_pd_forms [ $value['fk_form_id'] ].', ' ; } - // } - // if($unfetched_forms) - // { - // $unfetched_forms = substr_replace($unfetched_forms,'', -2) ; - // $incomplete_details[] = 'The following vendor section answers not fetched with PG Genie Form - '.$unfetched_forms; - // }; - // //echo $unfetched_forms; - // } + if($vendor_done_status == 1) + { + $smart_pd_forms = array('18' => 'General Information','5' => 'Address Details','13' => 'Business Information' ,'19' => 'Neighbourhood / Reference','20' => 'Final Remarks Form','24' => 'Credit Manager Queries','22' => 'Business Assets','12' => 'Employment Information','11' => 'Stock Details'); + $unfetched_forms = ''; + $vendor_form_status = $CI->PD_Model->getVendorFormStatus($pdid); + //print_r($vendor_form_status);die(); + foreach ($vendor_form_status as $key => $value) + { + if(!$value['form_status']){ $unfetched_forms .= $smart_pd_forms [ $value['fk_form_id'] ].', ' ; } + } + if($unfetched_forms) + { + $unfetched_forms = substr_replace($unfetched_forms,'', -2) ; + $incomplete_details[] = 'The following vendor section answers not fetched with PG Genie Form - '.$unfetched_forms; + } + //echo $unfetched_forms; + } //die(); @@ -312,14 +312,16 @@ class pdcompletenesscheck } #####End of Finance Form Questions######## - + // $business_assest_form = (json_decode($form_data[22][0]['json'],true)); + // $businees_assest_images_count = isset($pd_images[22]) ? count($pd_images[22]) : 0; + // print_r($business_assest_form);//die(); #####Business Assets Form Questions######## + $business_assest_form = (json_decode($form_data[22][0]['json'],true)); + $businees_assest_images_count = isset($pd_images[22]) ? count($pd_images[22]) : 0; if( $client != 'WEB')// if API came from web then ignore this check { - $business_assest_form = (json_decode($form_data[22][0]['json'],true)); - $businees_assest_images_count = isset($pd_images[22]) ? count($pd_images[22]) : 0; - //print_r($business_assest_form);die(); + if(array_key_exists('business_assets_details',$business_assest_form)) { @@ -333,6 +335,34 @@ class pdcompletenesscheck } } } + + if( $client == 'WEB')// if API came from web then ignore this check + { + if(array_key_exists('business_assets_for_address',$business_assest_form)) + { + if(count($business_assest_form['business_assets_for_address'])) + { + $overall_not_filled_questions = ''; + if($business_assest_form['business_assets_for_address'][0]['business_years']) + { + $overall_not_filled_questions .= 'Business Operating Duration'; + } + if(!$business_assest_form['business_assets_for_address'][0]['business_ownership_type']) + { + $overall_not_filled_questions .= ' Onwership Type'; + } + + if($overall_not_filled_questions) + { + $incomplete_details[] = 'Business Assets Section - '.$overall_not_filled_questions; + } + } + else + { + $incomplete_details[] = 'Business Assets Section - Business Operating Duration and ownership type'; + } + } + } #####End of Business Assets Form Questions######## $business_bank_form = isset($form_data[21][0]['json'])?(json_decode($form_data[21][0]['json'],true)):array(); diff --git a/api/application/helpers/pdscore_helper.php b/api/application/helpers/pdscore_helper.php index b20fad47..60afcaba 100644 --- a/api/application/helpers/pdscore_helper.php +++ b/api/application/helpers/pdscore_helper.php @@ -142,6 +142,595 @@ class PDSCORE + //echo $general_distribute_level_weightage = round($general_distribute_level_weightage,2);die(); + + //echo $general_distribute_level_weightage; + + + + //#######1.1 person_met_is_applicant + + $person_met_is_applicant_L2 = $general_distribute_level_weightage ? ($person_met_is_applicant_L2 + ($person_met_is_applicant_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $person_met_is_applicant_L2 ; + + + $person_met_is_applicant_actual_score = ($l1_general/100) * ($person_met_is_applicant_L2/100) * $person_met_is_applicant[$score_questions['general']['person_met_is_applicant']]; + + $person_met_is_applicant_max_score = ($l1_general/100) * ($person_met_is_applicant_L2/100) * max($person_met_is_applicant); + //echo $person_met_is_applicant_L2; + //echo $person_met_is_applicant_max_score; + + $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'],'attributed_score' => ($person_met_is_applicant_actual_score), 'max_score' => ($person_met_is_applicant_max_score),'score_band'=>($person_met_is_applicant[$score_questions['general']['person_met_is_applicant']]),'max_score_band' => max($person_met_is_applicant)); + + //######1.2 pd_location_approach + + $pd_location_approach_L2 = $general_distribute_level_weightage ? ($pd_location_approach_L2 + ($pd_location_approach_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $pd_location_approach_L2 ; + + $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); + + $score_questions['general']['pd_location_approach'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($pd_location_approach_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['pd_location_approach'],'attributed_score' => ($pd_location_approach_actual_score), 'max_score' => ($pd_location_approach_max_score),'score_band'=>$pd_location_approach[$score_questions['general']['pd_location_approach']],'max_score_band' => max($pd_location_approach)); + + //######1.3 comment_locality + + $comment_locality_L2 = $general_distribute_level_weightage ? ($comment_locality_L2 + ($comment_locality_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $comment_locality_L2; + + $comment_locality_actual_score = ($l1_general/100) * ($comment_locality_L2/100) * $comment_locality[$score_questions['general']['comment_locality']]; + + $comment_locality_max_score = ($l1_general/100) * ($comment_locality_L2/100) * max($comment_locality); + + $score_questions['general']['comment_locality'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($comment_locality_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['comment_locality'],'attributed_score' => ($comment_locality_actual_score), 'max_score' => ($comment_locality_max_score),'score_band'=>$comment_locality[$score_questions['general']['comment_locality']],'max_score_band' => max($comment_locality)); + + //######1.4 customer_behaviour + + $customer_behaviour_L2 = $general_distribute_level_weightage ? ($customer_behaviour_L2 + ($customer_behaviour_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $customer_behaviour_L2; + + $customer_behaviour_actual_score = ($l1_general/100) * ($customer_behaviour_L2/100) * $customer_behaviour[$score_questions['general']['customer_behaviour']]; + + $customer_behaviour_max_score = ($l1_general/100) * ($customer_behaviour_L2/100) * max($customer_behaviour); + + $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'],'attributed_score' => ($customer_behaviour_actual_score), 'max_score' => ($customer_behaviour_max_score),'score_band'=>$customer_behaviour[$score_questions['general']['customer_behaviour']],'max_score_band' => max($customer_behaviour)); + + //######1.6 was_the_company_name_board_sighted + + $was_the_company_name_board_sighted_L2 = $general_distribute_level_weightage ? ($was_the_company_name_board_sighted_L2 + ($was_the_company_name_board_sighted_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $was_the_company_name_board_sighted_L2; + + $was_the_company_name_board_sighted_actual_score = ($l1_general/100) * ($was_the_company_name_board_sighted_L2/100) * $was_the_company_name_board_sighted[$score_questions['general']['was_the_company_name_board_sighted']]; + + $was_the_company_name_board_sighted_max_score = ($l1_general/100) * ($was_the_company_name_board_sighted_L2/100) * max($was_the_company_name_board_sighted); + + $score_questions['general']['was_the_company_name_board_sighted'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($was_the_company_name_board_sighted_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['was_the_company_name_board_sighted'],'attributed_score' => ($was_the_company_name_board_sighted_actual_score), 'max_score' => ($was_the_company_name_board_sighted_max_score),'score_band'=>$was_the_company_name_board_sighted[$score_questions['general']['was_the_company_name_board_sighted']],'max_score_band' => max($was_the_company_name_board_sighted)); + + + + //######1.8 qualification + + $qualification_L2 = $general_distribute_level_weightage ? ($qualification_L2 + ($qualification_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $qualification_L2; + + $qualification_actual_score = ($l1_general/100) * ($qualification_L2/100) * $qualification['id_score'][$score_questions['general']['qualification']]; + + $qualification_max_score = ($l1_general/100) * ($qualification_L2/100) * max($qualification['id_score']); + $keys = array_keys($qualification['name_score']); + + $score_questions['general']['qualification'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($qualification_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $keys[($score_questions['general']['qualification']-1)],'attributed_score' => ($qualification_actual_score), 'max_score' => ($qualification_max_score),'score_band'=>$qualification['id_score'][$score_questions['general']['qualification']],'max_score_band' => max($qualification['id_score'])); + + //######1.9 value of assets as a % of Loan Amount + //print_r($personal_asset_grid); + + $value_of_other_assets_L2 = $general_distribute_level_weightage ? ($value_of_other_assets_L2 + ($value_of_other_assets_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $value_of_other_assets_L2; + + $asset_calculation_details = array(); + + $actual_value_of_assets = $score_questions['general']['value_of_other_assets']; + $asset_calculation_details['actual_value_of_assets'] = round($actual_value_of_assets,2); + //echo 'actual_value_of_assets -'.$actual_value_of_assets;die(); + //print_r($loan_amt_from_loam_form);die(); + $loan_amount = (int)$loan_amt_from_loam_form; + $asset_calculation_details['loan_amount'] = $loan_amount; + //echo 'loan_amount - '.$loan_amount; + + $avg_expected_value_of_assets = $personal_asset_grid['master_grid'][0]['avg_expected_value_assets']; + //print_r($personal_asset_grid); + //echo $avg_expected_value_of_assets; + $asset_calculation_details['avg_expected_value_of_assets'] = round($avg_expected_value_of_assets,2); + //echo "avg_expected_value_of_assets - ".$avg_expected_value_of_assets; + //$expected_value_of_assets = ($avg_expected_value_of_assets / 100 ) * $personal_asset_grid['master_grid'][0]['loan_amount_to']; + + $expected_value_of_assets = ($avg_expected_value_of_assets / 100 ) * $loan_amount; + $asset_calculation_details['expected_value_of_assets'] = round($expected_value_of_assets,2); + //echo 'expected_value_of_assets--'.$expected_value_of_assets; + + + + $actual_value_of_assets_percentage = $actual_value_of_assets ? ($actual_value_of_assets / $loan_amount) * 100 : 0; + $asset_calculation_details['actual_value_of_assets_percentage'] = + round($actual_value_of_assets_percentage,2); + //echo 'actual_value_of_assets_percentage--'.$actual_value_of_assets_percentage; + + $variance = (($actual_value_of_assets_percentage - $avg_expected_value_of_assets)/$avg_expected_value_of_assets )* 100 ; + + + //echo 'varience--'.$variance; + //die(); + $asset_calculation_details['variance'] = round($variance,2); + + $final_asset_attributed_score = 0; + $final_asset_score = 0; + if($actual_value_of_assets > 0 ) + { + foreach($personal_asset_grid['variance_grid'] as $grid) + { + //print_r($grid['score']); + if($grid['variance_ ratio_from'] <= $variance && $grid['variance_ration_to'] > $variance) + { + $final_asset_score = $grid['score']; + $final_asset_attributed_score = ($l1_general/100 ) * ($value_of_other_assets_L2/100)* $final_asset_score; + + } + } + } + $asset_calculation_details['score'] = $final_asset_score; + // echo "final_asset_score--".$final_asset_score; + // die(); + $score_questions['general']['value_of_other_assets'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($value_of_other_assets_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['value_of_other_assets'],'attributed_score' => ($final_asset_attributed_score), 'max_score' => ((($l1_general/100 ) * ($value_of_other_assets_L2/100) * 10)),'score_band'=> $final_asset_score,'max_score_band' => 10); + + + /*-----------END OF GENERAL SECTION -----------*/ + + /*-----------FINAL REMARKS SECTION -----------*/ + //###### 3.1 PD Officer Recommandation + + $pd_officer_recommandations_actual_score = ($l1_final/100) * ($pd_officer_recommadations_L2/100) * $pd_officer_recommandations[ $score_questions['final_remarks']['pd_officer_recommandations'] ]; + + $pd_officer_recommandations_max_score = ($l1_final/100) * ($pd_officer_recommadations_L2/100) * max($pd_officer_recommandations); + + $score_questions['final_remarks']['pd_officer_recommandations'] = array('l1_weightage' => $l1_final,'l2_weightage' => $pd_officer_recommadations_L2,'distributed_weightage' => 0,'answer' => $score_questions['final_remarks']['pd_officer_recommandations'],'attributed_score' => round($pd_officer_recommandations_actual_score,2), 'max_score' => $pd_officer_recommandations_max_score,'score_band'=>$pd_officer_recommandations[ $score_questions['final_remarks']['pd_officer_recommandations'] ],'max_score_band' => max($pd_officer_recommandations)); + /*-----------END OF FINAL REMARKS SECTION -----------*/ + + + /*-----------BUSINESS SECTION -----------*/ + + + /* First Calculate Shortfall Type Questions to get distribute level + From 2.7 to 2.10 Questions are shortfall type questions (REF :- SSA_ScoreCard_Ver_090219(2)) + */ + + $business_distribute_level_weightage = 0; + + //echo $score_questions['business']['minimum_supplier_info'];die(); + if(!strcasecmp($score_questions['business']['minimum_supplier_info'],'Not Applicable')) + { + $business_distribute_level_weightage += $minimum_supplier_info_L2; + $minimum_supplier_info_L2 = 0; + } + if(!strcasecmp($score_questions['business']['minimum_client_info'],'Not Applicable')) + { + $business_distribute_level_weightage += $minimum_client_info_L2; + $minimum_client_info_L2 = 0; + } + if(!strcasecmp($score_questions['business']['stock_raw_material_enough'],'Not Applicable')) + { + $business_distribute_level_weightage += $stock_raw_material_enough_L2; + $stock_raw_material_enough_L2 = 0; + } + if(!strcasecmp($score_questions['business']['stock_finished_goods_enough'],'Not Applicable')) + { + $business_distribute_level_weightage += $stock_finished_goods_enough_L2;$stock_finished_goods_enough_L2 = 0; + } + //echo $business_distribute_level_weightage; + + //######2.7 atleast one supplier info provided + $minimum_supplier_info_L2 = $business_distribute_level_weightage ? ($minimum_supplier_info_L2 + ($minimum_supplier_info_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $minimum_supplier_info_L2 ; + + $minimum_supplier_info_actual_score = ($l1_business/100) * ($minimum_supplier_info_L2/100) * $minimum_supplier_info [ $score_questions['business']['minimum_supplier_info'] ]; + + $minimum_supplier_info_max_score = strcasecmp($score_questions['business']['minimum_supplier_info'],'Not Applicable') ? ($l1_business/100) * ($minimum_supplier_info_L2/100) * max($minimum_supplier_info) : 0; + + $score_questions['business']['minimum_supplier_info'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($minimum_supplier_info_L2),'answer' => $score_questions['business']['minimum_supplier_info'],'attributed_score' => ($minimum_supplier_info_actual_score), 'max_score' => ($minimum_supplier_info_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band'=>$minimum_supplier_info [ $score_questions['business']['minimum_supplier_info'] ],'max_score_band' => max($minimum_supplier_info)); + + //######2.8 atleast one client info provided + $minimum_client_info_L2 = $business_distribute_level_weightage ? ($minimum_client_info_L2 + ($minimum_client_info_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $minimum_client_info_L2 ; + + $minimum_client_info_actual_score = ($l1_business/100) * ($minimum_client_info_L2/100) * $minimum_client_info [ $score_questions['business']['minimum_client_info'] ]; + + $minimum_client_info_max_score = strcasecmp($score_questions['business']['minimum_client_info'],'Not Applicable') ? ($l1_business/100) * ($minimum_client_info_L2/100) * max($minimum_client_info) : 0; + + $score_questions['business']['minimum_client_info'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($minimum_client_info_L2),'answer' => $score_questions['business']['minimum_client_info'],'attributed_score' => ($minimum_client_info_actual_score), 'max_score' => ($minimum_client_info_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band'=>$minimum_client_info [ $score_questions['business']['minimum_client_info'] ],'max_score_band' => max($minimum_client_info)); + + //######2.9 stock of raw material + $stock_raw_material_enough_L2 = $business_distribute_level_weightage ? ($stock_raw_material_enough_L2 + ($stock_raw_material_enough_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $stock_raw_material_enough_L2 ; + + $stock_raw_material_enough_actual_score = ($l1_business/100) * ($stock_raw_material_enough_L2/100) * $stock_answer_scores [ strtolower($score_questions['business']['stock_raw_material_enough']) ]; + + $stock_raw_material_enough_max_score = strcasecmp($score_questions['business']['stock_raw_material_enough'],'Not Applicable') ? ($l1_business/100) * ($stock_raw_material_enough_L2/100) * max($stock_answer_scores) : 0; + + $score_questions['business']['stock_raw_material_enough'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($stock_raw_material_enough_L2),'answer' => $score_questions['business']['stock_raw_material_enough'],'attributed_score' => ($stock_raw_material_enough_actual_score), 'max_score' => ($stock_raw_material_enough_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $stock_answer_scores [ strtolower($score_questions['business']['stock_raw_material_enough']) ],'max_score_band' =>max($stock_answer_scores) ); + + //######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 )) * $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'] != "" || $score_questions['business']['stock_finished_goods_enough'] != null ? strtolower($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; + + + $temp_stock_finished_goods_enough = strtolower($score_questions['business']['stock_finished_goods_enough']); + $score_questions['business']['stock_finished_goods_enough'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($stock_finished_goods_enough_L2),'answer' => $score_questions['business']['stock_finished_goods_enough'],'attributed_score' => ($stock_finished_goods_enough_actual_score), 'max_score' => ($stock_finished_goods_enough_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $stock_answer_scores [ $temp_stock_finished_goods_enough != "" || $temp_stock_finished_goods_enough != null ? $temp_stock_finished_goods_enough : "no" ],'max_score_band' => max($stock_answer_scores)); + + + + //######2.1 Business Certificates + + $cerificates_L2 = $business_distribute_level_weightage ? ($cerificates_L2 + ($cerificates_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $cerificates_L2; + + //find out no of not applicable cases + $business_certificates_distribution_count = 0; + + foreach($score_questions['business']['cerificates'] as $value) + { + + if(strcasecmp($value,'not applicable')) + { + $business_certificates_distribution_count++; + //echo $value; + } + } + $business_certificates_distribution_count; + $business_certificates_distribution = $business_certificates_distribution_count ? $cerificates_L2 / $business_certificates_distribution_count : 0; + + + + // echo $cerificates_L2.'---';echo $business_certificates_distribution_count; + // echo $business_certificates_distribution;die(); + $certificate_actual_score = 0; + $certificate_max_score = 0; + //print_r($score_questions['business']['cerificates']); + foreach($score_questions['business']['cerificates'] as $certificate_key => $certificate) + { + //print_r($certificate); + $acutal_score = 0; + $max_score = 0; + if(strcasecmp($certificate,'not applicable')) + { + $acutal_score = ($l1_business/100) * ($business_certificates_distribution/100) * $cerificates[$certificate]; + $max_score = ($l1_business/100) * ($business_certificates_distribution/100) * max($cerificates); + + } + $score_questions['business']['cerificates'][$certificate_key] = array('answer' => $certificate,'attributed_score' => ($acutal_score), 'max_score' => ($max_score),'score_band' => $cerificates[$certificate],'max_score_band'=> max($cerificates),'l1_weightage' =>($l1_business),'l2_weightage'=> ($business_certificates_distribution)); + + $certificate_actual_score += $acutal_score; + $certificate_max_score += $max_score; + } + + $score_questions['business']['cerificates']['l1_weightage'] = $l1_business; + $score_questions['business']['cerificates']['l2_weightage'] = (($business_certificates_distribution * $business_certificates_distribution_count)); + $score_questions['business']['cerificates']['distributed_weightage'] = $business_distribute_level_weightage; + $score_questions['business']['cerificates']['max_score'] = ($certificate_max_score); + $score_questions['business']['cerificates']['attributed_score'] = ($certificate_actual_score); + $score_questions['business']['cerificates']['score_band'] = 'Derived'; + $score_questions['business']['cerificates']['max_score_band'] = 'Derived'; + + //print_r($score_questions['business']['cerificates']);die(); + //######2.1 no_of_years_business_run + + $no_of_years_business_run_actual_score = 0; + $score_band = 0; + + if($score_questions['business']['no_of_years_business_run']) + { + foreach($no_of_years_business_run as $key => $value) + { + $exp = explode('to',$key); + //print_r($exp); + $left = $exp[0].$score_questions['business']['no_of_years_business_run']; + $right = $score_questions['business']['no_of_years_business_run'].$exp[1]; + + + //echo $left.'````'.$right;echo "\n";die(); + eval( '$left_exp = ' . $left . ';'); + eval( '$right_exp = ' . $right . ';'); + if($left_exp && $right_exp) + { + + $no_of_years_business_run_L2 = $business_distribute_level_weightage ? ($no_of_years_business_run_L2 + ($no_of_years_business_run_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $no_of_years_business_run_L2 ; + + $no_of_years_business_run_actual_score = ($l1_business/100) * ($no_of_years_business_run_L2/100) * $value; + $score_band = $value; + } + + } + } + + + + $no_of_years_business_run_max_score = ($l1_business/100) * ($no_of_years_business_run_L2/100) * max($no_of_years_business_run); + + $score_questions['business']['no_of_years_business_run'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($no_of_years_business_run_L2),'answer' => $score_questions['business']['no_of_years_business_run'],'attributed_score' => ($no_of_years_business_run_actual_score), 'max_score' => ($no_of_years_business_run_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $score_band,'max_score_band' => max($no_of_years_business_run)); + + + //######2.2 business seasonal + + + $business_seasonality_L2 = $business_distribute_level_weightage ? ($business_seasonality_L2 + ($business_seasonality_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $business_seasonality_L2 ; + + $business_seasonality_actual_score = ($l1_business/100) * ($business_seasonality_L2/100) * $business_seasonality[ $score_questions['business']['business_seasonality'] ]; + + $business_seasonality_max_score = ($l1_business/100) * ($business_seasonality_L2/100) * max($business_seasonality); + + $score_questions['business']['business_seasonality'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($business_seasonality_L2),'answer' => $score_questions['business']['business_seasonality'],'attributed_score' => ($business_seasonality_actual_score), 'max_score' =>($business_seasonality_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $business_seasonality[ $score_questions['business']['business_seasonality'] ],'max_score_band' => max($business_seasonality)); + + //######2.3 employees_total + $employees_total_actual_score = 0; + + $employees_total_L2 = $business_distribute_level_weightage ? ($employees_total_L2 + ($employees_total_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $employees_total_L2 ; + $score_band = 0; + if($score_questions['business']['employees_total']) + { + foreach($employees_total as $key => $value) + { + $exp = explode('to',$key); + //print_r($exp); + $left = $exp[0].$score_questions['business']['employees_total']; + $right = $score_questions['business']['employees_total'].$exp[1]; + //echo $left.'````'.$right;echo "\n"; + eval( '$left_exp = ' . $left . ';'); + eval( '$right_exp = ' . $right . ';'); + if($left_exp && $right_exp) + { + $employees_total_actual_score = ($l1_business/100) * ($employees_total_L2/100) * $value; + $score_band = $value; + } + + } + } + // echo $score_band; + // die(); + + + $employees_total_max_score = ($l1_business/100) * ($employees_total_L2/100) * max($employees_total); + + $score_questions['business']['employees_total'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($employees_total_L2),'answer' => $score_questions['business']['employees_total'],'attributed_score' => ($employees_total_actual_score), 'max_score' => ($employees_total_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' =>$score_band,'max_score_band' => max($employees_total)); + + + //######2.5 owned_property + + $owned_property_L2 = $business_distribute_level_weightage ? ($owned_property_L2 + ($owned_property_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $owned_property_L2 ; + + $owned_property_actual_score = ($l1_business/100) * ($owned_property_L2/100) * $owned_property[ $score_questions['business']['owned_property'] ]; + $owned_property_max_score = ($l1_business/100) * ($owned_property_L2/100) * max($owned_property); + + $score_questions['business']['owned_property'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($owned_property_L2),'answer' => $score_questions['business']['owned_property'],'attributed_score' => ($owned_property_actual_score), 'max_score' => ($owned_property_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $owned_property[ $score_questions['business']['owned_property'] ],'max_score_band' => max($owned_property)); + + //######2.6 owned_vechile + $owned_vechile_L2 = $business_distribute_level_weightage ? ($owned_vechile_L2 + ($owned_vechile_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $owned_vechile_L2 ; + + $owned_vechile_actual_score = ($l1_business/100) * ($owned_vechile_L2/100) * $owned_vechile[ $score_questions['business']['owned_vechile'] ]; + $owned_vechile_max_score = ($l1_business/100) * ($owned_vechile_L2/100) * max($owned_vechile); + + $score_questions['business']['owned_vechile'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($owned_vechile_L2),'answer' => $score_questions['business']['owned_vechile'],'attributed_score' => ($owned_vechile_actual_score), 'max_score' => ($owned_vechile_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $owned_vechile[ $score_questions['business']['owned_vechile'] ],'max_score_band' => max($owned_vechile)); + + //######2.11 location_suited_for_busienss + + $location_suited_for_busienss_L2 = $business_distribute_level_weightage ? ($location_suited_for_busienss_L2 + ($location_suited_for_busienss_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $location_suited_for_busienss_L2 ; + + $location_suited_for_busienss_actual_score = ($l1_business/100) * ($location_suited_for_busienss_L2/100) * $location_suited_for_busienss[ $score_questions['business']['location_suited_for_busienss'] ]; + $location_suited_for_busienss_max_score = ($l1_business/100) * ($location_suited_for_busienss_L2/100) * max($location_suited_for_busienss); + + $score_questions['business']['location_suited_for_busienss'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($location_suited_for_busienss_L2),'answer' => $score_questions['business']['location_suited_for_busienss'],'attributed_score' => ($location_suited_for_busienss_actual_score), 'max_score' => ($location_suited_for_busienss_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $location_suited_for_busienss[ $score_questions['business']['location_suited_for_busienss'] ],'max_score_band' => max($location_suited_for_busienss)); + + //######2.11 business_activity_has_seen + + $business_activity_has_seen_L2 = $business_distribute_level_weightage ? ($business_activity_has_seen_L2 + ($business_activity_has_seen_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $business_activity_has_seen_L2 ; + + $business_activity_has_seen_actual_score = ($l1_business/100) * ($business_activity_has_seen_L2/100) * $business_activity_has_seen[ $score_questions['business']['business_activity_has_seen'] ]; + $business_activity_has_seen_max_score = ($l1_business/100) * ($business_activity_has_seen_L2/100) * max($business_activity_has_seen); + + $score_questions['business']['business_activity_has_seen'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($business_activity_has_seen_L2),'answer' => $score_questions['business']['business_activity_has_seen'],'attributed_score' => ($business_activity_has_seen_actual_score), 'max_score' => ($business_activity_has_seen_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $business_activity_has_seen[ $score_questions['business']['business_activity_has_seen'] ], 'max_score_band' => max($business_activity_has_seen)); + + //######2.13 vintage business banking + + $vintage_of_business_account_L2 = $business_distribute_level_weightage ? ($vintage_of_business_account_L2 + ($vintage_of_business_account_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $vintage_of_business_account_L2 ; + + $vintage_of_business_account_actual_score = 0; + $score_band = 0; + foreach($vintage_of_business_account as $key => $value) + { + $exp = explode('to',$key); + //print_r($exp); + $left = $exp[0].$score_questions['business']['vintage_of_business_account']; + $right = $score_questions['business']['vintage_of_business_account'].$exp[1]; + //echo $left.'````'.$right;echo "\n"; + eval( '$left_exp = ' . $left . ';'); + eval( '$right_exp = ' . $right . ';'); + if($left_exp && $right_exp) + { + $vintage_of_business_account_actual_score = ($l1_business/100) * ($vintage_of_business_account_L2/100) * $value; + $score_band = $value; + } + + } + + + + $vintage_of_business_account_max_score = ($l1_business/100) * ($vintage_of_business_account_L2/100) * max($vintage_of_business_account); + + + $vintage_of_business_account_for_display = explode('.',($score_questions['business']['vintage_of_business_account'])); + $vintage_of_business_account_for_display = ($vintage_of_business_account_for_display[0] != 0 ? $vintage_of_business_account_for_display[0].' Yrs ' : '') . (isset($vintage_of_business_account_for_display[1]) && $vintage_of_business_account_for_display[1] != 0 ? $vintage_of_business_account_for_display[1].' Mns ' : ''); + + $score_questions['business']['vintage_of_business_account'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($vintage_of_business_account_L2),'answer' => $vintage_of_business_account_for_display,'attributed_score' => ($vintage_of_business_account_actual_score), 'max_score' => ($vintage_of_business_account_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $score_band,'max_score_band' => max($vintage_of_business_account)); + /*-----------END OF BUSINESS SECTION -----------*/ + + + + /* Calculate Overall Total*/ + $overall_max_score = 0; + $overall_actual_score = 0; + foreach($score_questions as $key => $value) + { + + $current_max_score = 0; + $current_actual_score = 0; + foreach($value as $v_key => $f_value) + { + $overall_max_score += $f_value['max_score']; + $overall_actual_score += $f_value['attributed_score']; + + $current_max_score += $f_value['max_score']; + $current_actual_score += $f_value['attributed_score']; + + } + $score_questions['score_summary'][$key] = array('actual_score' => $current_actual_score,'max_score' => $current_max_score,'score_per' => (($current_actual_score/$current_max_score) * 100)); + + } + $score_questions['score_summary']['overall_score'] = array('overall_actual_score' => $overall_actual_score, 'overall_max_score' => $overall_max_score,'final_score' => (($overall_actual_score/$overall_max_score) * 100)); + + $score_questions['score_summary']['asset_calculation_details'] = $asset_calculation_details; + //print_r($score_questions);die(); + return ($score_questions); + + + + + } + + + //SMART PD SCORE CALCULATIONS + public static function genericDISmartPDScoreCalculate($score_questions,$loan_amt_from_loam_form,$personal_asset_grid,$pd_master_details) + { + //echo 'RRRRR';die(); + //print_r($personal_asset_grid);die();echo "###################"; + ############ GENERIC SE-DI CASES ####################### + ############ SCROE VARIABLES DECLERATIONS ############## + + // LEVEL 1 WEIGHTAGES + $l1_general = 25; + $l1_business = 50; + $l1_final = 25; + + // LEVEL2 WEIGHTAGES - Questions Weightages + + /*-------- GENERAL --------------*/ + $person_met_is_applicant_L2 = 15; + $pd_location_approach_L2 = 10; + $comment_locality_L2 = 10; + $customer_behaviour_L2 = 10; + $neibourhood_check_as_per_pd_officer_L2 = 10; + $was_the_company_name_board_sighted_L2 = 10; + $otp_done_L2 = 10; + $qualification_L2 = 10; + $value_of_other_assets_L2 = 15; + + /*-------- BUSNIESS --------------*/ + + $no_of_years_business_run_L2 = 10; + $business_seasonality_L2 = 10; + $employees_total_L2 = 10; + $cerificates_L2 = 10; + $owned_property_L2 = 7; + $owned_vechile_L2 = 3; + $minimum_supplier_info_L2 = 5; + $minimum_client_info_L2 = 5; + $stock_raw_material_enough_L2 = 5; + $stock_finished_goods_enough_L2 = 5; + $location_suited_for_busienss_L2 = 10; + $business_activity_has_seen_L2 = 10; + $vintage_of_business_account_L2 = 10; + + /*-------- FINAL --------------*/ + $pd_officer_recommadations_L2 = 100; + + //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); + $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,'Could not verify' => 0); + $was_the_company_name_board_sighted = array('yes' => 10, 'no' => 0); + $supplir_client_answer_scores = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); + + $otp_done = array('Yes' => 10, 'No' => 0); + $qualification = array( 'name_score' => array('Completed Professional Course' => 10,'Completed Post Graduation' => 8, 'Completed Graduation' => 6,'Completed Schooling' => 4,'Not Completed Schooling' => 2,'No Formal Education' => 0), + 'id_score' => array('1' => 10,'2' => 8,'3' => 6,'4' => 4,'5' => 2,'6' => 0)); + + /*-------- BUSNIESS --------------*/ + $no_of_years_business_run = array('100> to >=10' => 10,'5<= to <10' => 8,'3<= to <5' => 6,'1<= to <3' => 4,' 1> to >0' => 2); + $business_seasonality = array('yes' => 5, 'no major changes in sales' => 10); + $employees_total = array('1000> to >50' => 10,'21<= to <=50' => 8, '11<= to <=20' => 6, '6<= to <10' =>4,'5>= to >0' => 2) ; + $cerificates = array('yes' => 10,'no' => 0, 'not applicable' => 0); + $owned_property = array('yes' => 10, 'no' => 0); + $owned_vechile = array('yes' => 10, 'no' => 0); + $minimum_supplier_info = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); + $minimum_client_info = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); + $stock_answer_scores = array('yes' => 10, 'no' => 0,'not applicable' => 0); + $stock_raw_material_enough = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); + $stock_finished_goods_enough = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); + $location_suited_for_busienss = array('well_suited' => 10 ,'fairly_suited' => 6,'not_suited' => 0); + $business_activity_has_seen = array('yes' => 10, 'no' => 0); + $vintage_of_business_account = array('100> to >=10' => 10,'7<= to <10' => 8,'5<= to <7' => 6,'3<= to <5' => 4,'3> to >0' => 2); + /*-------- FINAL --------------*/ + $pd_officer_recommandations = array('Positive' => 10,'Negative' => 0,'Refer to Credit' => 5,'Others' => 0); + + + /*-----------CALCULATION PART -----------*/ + /*-----------GENERAL SECTION -----------*/ + //echo "##################################################"; + + $over_all_general_l2 = 0; + $over_all_general_round_l2 = 0; + $general_distribute_level_weightage = 0; + + //General Section L2 Weightage Distribution section + if($pd_master_details[0]['is_otp_enabled'] != 1) + { + $general_distribute_level_weightage += $otp_done_L2; + } + + if(!strcmp($score_questions['general']['neibourhood_check_as_per_pd_officer'],'Could not verify')) + { + //echo "Yes could not"; + $general_distribute_level_weightage += $neibourhood_check_as_per_pd_officer_L2; + } + + //End of General Section L2 Weightage Distribution section + + + //######1.7 otp_done + if($pd_master_details[0]['is_otp_enabled'] == 1) + { + $otp_done_L2 = $general_distribute_level_weightage ? ($otp_done_L2 + ($otp_done_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $otp_done_L2; + + $otp_done_actual_score = ($l1_general/100) * ($otp_done_L2/100) * $otp_done[$score_questions['general']['otp_done']]; + + $otp_done_max_score = ($l1_general/100) * ($otp_done_L2/100) * max($otp_done); + + $score_questions['general']['otp_done'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($otp_done_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['otp_done'],'attributed_score' => ($otp_done_actual_score), 'max_score' => ($otp_done_max_score),'score_band'=>$otp_done[$score_questions['general']['otp_done']],'max_score_band' => max($otp_done)); + } + else + { + $score_questions['general']['otp_done'] = array('l1_weightage' => $l1_general,'l2_weightage' => 0,'distributed_weightage' => $general_distribute_level_weightage,'answer' => 'Not Applicable','attributed_score' => 0.00, 'max_score' => 0.00,'score_band'=>$otp_done[ $score_questions['general']['otp_done'] != "" || $score_questions['general']['otp_done'] != null ?$score_questions['general']['otp_done']: "No" ],'max_score_band' => 0); + } + + //######1.5 neibourhood_check_as_per_pd_officer + if(!strcmp($score_questions['general']['neibourhood_check_as_per_pd_officer'],'Could not verify')) + { + $score_questions['general']['neibourhood_check_as_per_pd_officer'] = array('l1_weightage' => $l1_general,'l2_weightage' => 0,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['neibourhood_check_as_per_pd_officer'],'attributed_score' => 0.00, 'max_score' => 0.00,'score_band'=>$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" ],'max_score_band' => 0); + } + else + { + $neibourhood_check_as_per_pd_officer_L2 = $general_distribute_level_weightage ? ($neibourhood_check_as_per_pd_officer_L2 + ($neibourhood_check_as_per_pd_officer_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $neibourhood_check_as_per_pd_officer_L2; + + $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); + + $score_questions['general']['neibourhood_check_as_per_pd_officer'] = array('l1_weightage' => $l1_general,'l2_weightage' => $neibourhood_check_as_per_pd_officer_L2,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['neibourhood_check_as_per_pd_officer'],'attributed_score' => ($neibourhood_check_as_per_pd_officer_actual_score), 'max_score' => ($neibourhood_check_as_per_pd_officer_max_score),'score_band'=>$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" ],'max_score_band' => max($neibourhood_check_as_per_pd_officer)); + } + + + + //echo $general_distribute_level_weightage = round($general_distribute_level_weightage,2);die(); //echo $general_distribute_level_weightage; @@ -583,588 +1172,6 @@ class PDSCORE - } - - - //SMART PD SCORE CALCULATIONS - public static function genericDISmartPDScoreCalculate($score_questions,$loan_amt_from_loam_form,$personal_asset_grid,$pd_master_details) - { - //echo 'RRRRR';die(); - //print_r($personal_asset_grid);die();echo "###################"; - ############ GENERIC SE-DI CASES ####################### - ############ SCROE VARIABLES DECLERATIONS ############## - - // LEVEL 1 WEIGHTAGES - $l1_general = 25; - $l1_business = 50; - $l1_final = 25; - - // LEVEL2 WEIGHTAGES - Questions Weightages - - /*-------- GENERAL --------------*/ - $person_met_is_applicant_L2 = 15; - $pd_location_approach_L2 = 10; - $comment_locality_L2 = 10; - $customer_behaviour_L2 = 10; - $neibourhood_check_as_per_pd_officer_L2 = 10; - $was_the_company_name_board_sighted_L2 = 10; - $otp_done_L2 = 10; - $qualification_L2 = 10; - $value_of_other_assets_L2 = 15; - - /*-------- BUSNIESS --------------*/ - - // $location_suited_for_busienss_L2 = 10; not for smart pd - - $no_of_years_business_run_L2 = 11.1111111; - $business_seasonality_L2 = 11.1111111; - $employees_total_L2 = 11.1111111; - $cerificates_L2 = 11.1111111; - $owned_property_L2 = 7.777777; - $owned_vechile_L2 = 3.3333333; - $minimum_supplier_info_L2 = 5.555555; - $minimum_client_info_L2 = 5.555555; - $stock_raw_material_enough_L2 = 5.555555; - $stock_finished_goods_enough_L2 = 5.555555; - - $business_activity_has_seen_L2 = 11.1111111; - $vintage_of_business_account_L2 = 11.1111111; - - /*-------- FINAL --------------*/ - $pd_officer_recommadations_L2 = 100; - - //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); - $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,'Could not verify' => 0); - $was_the_company_name_board_sighted = array('yes' => 10, 'no' => 0); - $supplir_client_answer_scores = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); - - $otp_done = array('Yes' => 10, 'No' => 0); - $qualification = array( 'name_score' => array('Completed Professional Course' => 10,'Completed Post Graduation' => 8, 'Completed Graduation' => 6,'Completed Schooling' => 4,'Not Completed Schooling' => 2,'No Formal Education' => 0), - 'id_score' => array('1' => 10,'2' => 8,'3' => 6,'4' => 4,'5' => 2,'6' => 0)); - - /*-------- BUSNIESS --------------*/ - $no_of_years_business_run = array('100> to >=10' => 10,'5<= to <10' => 8,'3<= to <5' => 6,'1<= to <3' => 4,' 1> to >0' => 2); - $business_seasonality = array('yes' => 5, 'no major changes in sales' => 10); - $employees_total = array('1000> to >50' => 10,'21<= to <=50' => 8, '11<= to <=20' => 6, '6<= to <10' =>4,'5>= to >0' => 2) ; - $cerificates = array('yes' => 10,'no' => 0, 'not applicable' => 0); - $owned_property = array('yes' => 10, 'no' => 0); - $owned_vechile = array('yes' => 10, 'no' => 0); - $minimum_supplier_info = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); - $minimum_client_info = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); - $stock_answer_scores = array('yes' => 10, 'no' => 0,'not applicable' => 0); - $stock_raw_material_enough = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); - $stock_finished_goods_enough = array('Provided' => 10, 'Not Provided' => 0,'Not Applicable' => 0); - $location_suited_for_busienss = array('well_suited' => 10 ,'fairly_suited' => 6,'not_suited' => 0); - $business_activity_has_seen = array('yes' => 10, 'no' => 0); - $vintage_of_business_account = array('100> to >=10' => 10,'7<= to <10' => 8,'5<= to <7' => 6,'3<= to <5' => 4,'3> to >0' => 2); - /*-------- FINAL --------------*/ - $pd_officer_recommandations = array('Positive' => 10,'Negative' => 0,'Refer to Credit' => 5,'Others' => 0); - - - /*-----------CALCULATION PART -----------*/ - /*-----------GENERAL SECTION -----------*/ - //echo "##################################################"; - - $over_all_general_l2 = 0; - $over_all_general_round_l2 = 0; - $general_distribute_level_weightage = 0; - - //General Section L2 Weightage Distribution section - if($pd_master_details[0]['is_otp_enabled'] != 1) - { - $general_distribute_level_weightage += $otp_done_L2; - } - - if(!strcmp($score_questions['general']['neibourhood_check_as_per_pd_officer'],'Could not verify')) - { - //echo "Yes could not"; - $general_distribute_level_weightage += $neibourhood_check_as_per_pd_officer_L2; - } - - //End of General Section L2 Weightage Distribution section - - - //######1.7 otp_done - if($pd_master_details[0]['is_otp_enabled'] == 1) - { - $otp_done_L2 = $general_distribute_level_weightage ? ($otp_done_L2 + ($otp_done_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $otp_done_L2; - - $otp_done_actual_score = ($l1_general/100) * ($otp_done_L2/100) * $otp_done[$score_questions['general']['otp_done']]; - - $otp_done_max_score = ($l1_general/100) * ($otp_done_L2/100) * max($otp_done); - - $score_questions['general']['otp_done'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($otp_done_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['otp_done'],'attributed_score' => ($otp_done_actual_score), 'max_score' => ($otp_done_max_score),'score_band'=>$otp_done[$score_questions['general']['otp_done']],'max_score_band' => max($otp_done)); - } - else - { - $score_questions['general']['otp_done'] = array('l1_weightage' => $l1_general,'l2_weightage' => 0,'distributed_weightage' => $general_distribute_level_weightage,'answer' => 'Not Applicable','attributed_score' => 0.00, 'max_score' => 0.00,'score_band'=>$otp_done[ $score_questions['general']['otp_done'] != "" || $score_questions['general']['otp_done'] != null ?$score_questions['general']['otp_done']: "No" ],'max_score_band' => 0); - } - - //######1.5 neibourhood_check_as_per_pd_officer - if(!strcmp($score_questions['general']['neibourhood_check_as_per_pd_officer'],'Could not verify')) - { - $score_questions['general']['neibourhood_check_as_per_pd_officer'] = array('l1_weightage' => $l1_general,'l2_weightage' => 0,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['neibourhood_check_as_per_pd_officer'],'attributed_score' => 0.00, 'max_score' => 0.00,'score_band'=>$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" ],'max_score_band' => 0); - } - else - { - $neibourhood_check_as_per_pd_officer_L2 = $general_distribute_level_weightage ? ($neibourhood_check_as_per_pd_officer_L2 + ($neibourhood_check_as_per_pd_officer_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $neibourhood_check_as_per_pd_officer_L2; - - $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); - - $score_questions['general']['neibourhood_check_as_per_pd_officer'] = array('l1_weightage' => $l1_general,'l2_weightage' => $neibourhood_check_as_per_pd_officer_L2,'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['neibourhood_check_as_per_pd_officer'],'attributed_score' => ($neibourhood_check_as_per_pd_officer_actual_score), 'max_score' => ($neibourhood_check_as_per_pd_officer_max_score),'score_band'=>$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" ],'max_score_band' => max($neibourhood_check_as_per_pd_officer)); - } - - - - - //echo $general_distribute_level_weightage = round($general_distribute_level_weightage,2);die(); - - //echo $general_distribute_level_weightage; - - - - //#######1.1 person_met_is_applicant - - $person_met_is_applicant_L2 = $general_distribute_level_weightage ? ($person_met_is_applicant_L2 + ($person_met_is_applicant_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $person_met_is_applicant_L2 ; - - - $person_met_is_applicant_actual_score = ($l1_general/100) * ($person_met_is_applicant_L2/100) * $person_met_is_applicant[$score_questions['general']['person_met_is_applicant']]; - - $person_met_is_applicant_max_score = ($l1_general/100) * ($person_met_is_applicant_L2/100) * max($person_met_is_applicant); - //echo $person_met_is_applicant_L2; - //echo $person_met_is_applicant_max_score; - - $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'],'attributed_score' => ($person_met_is_applicant_actual_score), 'max_score' => ($person_met_is_applicant_max_score),'score_band'=>($person_met_is_applicant[$score_questions['general']['person_met_is_applicant']]),'max_score_band' => max($person_met_is_applicant)); - - //######1.2 pd_location_approach - - $pd_location_approach_L2 = $general_distribute_level_weightage ? ($pd_location_approach_L2 + ($pd_location_approach_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $pd_location_approach_L2 ; - - $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); - - $score_questions['general']['pd_location_approach'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($pd_location_approach_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['pd_location_approach'],'attributed_score' => ($pd_location_approach_actual_score), 'max_score' => ($pd_location_approach_max_score),'score_band'=>$pd_location_approach[$score_questions['general']['pd_location_approach']],'max_score_band' => max($pd_location_approach)); - - //######1.3 comment_locality - - $comment_locality_L2 = $general_distribute_level_weightage ? ($comment_locality_L2 + ($comment_locality_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $comment_locality_L2; - - $comment_locality_actual_score = ($l1_general/100) * ($comment_locality_L2/100) * $comment_locality[$score_questions['general']['comment_locality']]; - - $comment_locality_max_score = ($l1_general/100) * ($comment_locality_L2/100) * max($comment_locality); - - $score_questions['general']['comment_locality'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($comment_locality_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['comment_locality'],'attributed_score' => ($comment_locality_actual_score), 'max_score' => ($comment_locality_max_score),'score_band'=>$comment_locality[$score_questions['general']['comment_locality']],'max_score_band' => max($comment_locality)); - - //######1.4 customer_behaviour - - $customer_behaviour_L2 = $general_distribute_level_weightage ? ($customer_behaviour_L2 + ($customer_behaviour_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $customer_behaviour_L2; - - $customer_behaviour_actual_score = ($l1_general/100) * ($customer_behaviour_L2/100) * $customer_behaviour[$score_questions['general']['customer_behaviour']]; - - $customer_behaviour_max_score = ($l1_general/100) * ($customer_behaviour_L2/100) * max($customer_behaviour); - - $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'],'attributed_score' => ($customer_behaviour_actual_score), 'max_score' => ($customer_behaviour_max_score),'score_band'=>$customer_behaviour[$score_questions['general']['customer_behaviour']],'max_score_band' => max($customer_behaviour)); - - //######1.6 was_the_company_name_board_sighted - - $was_the_company_name_board_sighted_L2 = $general_distribute_level_weightage ? ($was_the_company_name_board_sighted_L2 + ($was_the_company_name_board_sighted_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $was_the_company_name_board_sighted_L2; - - $was_the_company_name_board_sighted_actual_score = ($l1_general/100) * ($was_the_company_name_board_sighted_L2/100) * $was_the_company_name_board_sighted[$score_questions['general']['was_the_company_name_board_sighted']]; - - $was_the_company_name_board_sighted_max_score = ($l1_general/100) * ($was_the_company_name_board_sighted_L2/100) * max($was_the_company_name_board_sighted); - - $score_questions['general']['was_the_company_name_board_sighted'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($was_the_company_name_board_sighted_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['was_the_company_name_board_sighted'],'attributed_score' => ($was_the_company_name_board_sighted_actual_score), 'max_score' => ($was_the_company_name_board_sighted_max_score),'score_band'=>$was_the_company_name_board_sighted[$score_questions['general']['was_the_company_name_board_sighted']],'max_score_band' => max($was_the_company_name_board_sighted)); - - - - //######1.8 qualification - - $qualification_L2 = $general_distribute_level_weightage ? ($qualification_L2 + ($qualification_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $qualification_L2; - - $qualification_actual_score = ($l1_general/100) * ($qualification_L2/100) * $qualification['id_score'][$score_questions['general']['qualification']]; - - $qualification_max_score = ($l1_general/100) * ($qualification_L2/100) * max($qualification['id_score']); - $keys = array_keys($qualification['name_score']); - - $score_questions['general']['qualification'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($qualification_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $keys[($score_questions['general']['qualification']-1)],'attributed_score' => ($qualification_actual_score), 'max_score' => ($qualification_max_score),'score_band'=>$qualification['id_score'][$score_questions['general']['qualification']],'max_score_band' => max($qualification['id_score'])); - - //######1.9 value of assets as a % of Loan Amount - //print_r($personal_asset_grid); - - $value_of_other_assets_L2 = $general_distribute_level_weightage ? ($value_of_other_assets_L2 + ($value_of_other_assets_L2 / (100 - $general_distribute_level_weightage )) * $general_distribute_level_weightage) : $value_of_other_assets_L2; - - $asset_calculation_details = array(); - - $actual_value_of_assets = $score_questions['general']['value_of_other_assets']; - $asset_calculation_details['actual_value_of_assets'] = round($actual_value_of_assets,2); - //echo 'actual_value_of_assets -'.$actual_value_of_assets;die(); - //print_r($loan_amt_from_loam_form);die(); - $loan_amount = (int)$loan_amt_from_loam_form; - $asset_calculation_details['loan_amount'] = $loan_amount; - //echo 'loan_amount - '.$loan_amount; - - $avg_expected_value_of_assets = $personal_asset_grid['master_grid'][0]['avg_expected_value_assets']; - //print_r($personal_asset_grid); - //echo $avg_expected_value_of_assets; - $asset_calculation_details['avg_expected_value_of_assets'] = round($avg_expected_value_of_assets,2); - //echo "avg_expected_value_of_assets - ".$avg_expected_value_of_assets; - //$expected_value_of_assets = ($avg_expected_value_of_assets / 100 ) * $personal_asset_grid['master_grid'][0]['loan_amount_to']; - - $expected_value_of_assets = ($avg_expected_value_of_assets / 100 ) * $loan_amount; - $asset_calculation_details['expected_value_of_assets'] = round($expected_value_of_assets,2); - //echo 'expected_value_of_assets--'.$expected_value_of_assets; - - - - $actual_value_of_assets_percentage = ($actual_value_of_assets / $loan_amount) * 100; - $asset_calculation_details['actual_value_of_assets_percentage'] = - round($actual_value_of_assets_percentage,2); - //echo 'actual_value_of_assets_percentage--'.$actual_value_of_assets_percentage; - - $variance = (($actual_value_of_assets_percentage - $avg_expected_value_of_assets)/$avg_expected_value_of_assets )* 100 ; - - - //echo 'varience--'.$variance; - //die(); - $asset_calculation_details['variance'] = round($variance,2); - - $final_asset_attributed_score = 0; - $final_asset_score = 0; - if($actual_value_of_assets > 0 ) - { - foreach($personal_asset_grid['variance_grid'] as $grid) - { - //print_r($grid['score']); - if($grid['variance_ ratio_from'] <= $variance && $grid['variance_ration_to'] > $variance) - { - $final_asset_score = $grid['score']; - $final_asset_attributed_score = ($l1_general/100 ) * ($value_of_other_assets_L2/100)* $final_asset_score; - - } - } - } - $asset_calculation_details['score'] = $final_asset_score; - // echo "final_asset_score--".$final_asset_score; - // die(); - $score_questions['general']['value_of_other_assets'] = array('l1_weightage' => $l1_general,'l2_weightage' => ($value_of_other_assets_L2),'distributed_weightage' => $general_distribute_level_weightage,'answer' => $score_questions['general']['value_of_other_assets'],'attributed_score' => ($final_asset_attributed_score), 'max_score' => ((($l1_general/100 ) * ($value_of_other_assets_L2/100) * 10)),'score_band'=> $final_asset_score,'max_score_band' => 10); - - - /*-----------END OF GENERAL SECTION -----------*/ - - /*-----------FINAL REMARKS SECTION -----------*/ - //###### 3.1 PD Officer Recommandation - - $pd_officer_recommandations_actual_score = ($l1_final/100) * ($pd_officer_recommadations_L2/100) * $pd_officer_recommandations[ $score_questions['final_remarks']['pd_officer_recommandations'] ]; - - $pd_officer_recommandations_max_score = ($l1_final/100) * ($pd_officer_recommadations_L2/100) * max($pd_officer_recommandations); - - $score_questions['final_remarks']['pd_officer_recommandations'] = array('l1_weightage' => $l1_final,'l2_weightage' => $pd_officer_recommadations_L2,'distributed_weightage' => 0,'answer' => $score_questions['final_remarks']['pd_officer_recommandations'],'attributed_score' => round($pd_officer_recommandations_actual_score,2), 'max_score' => $pd_officer_recommandations_max_score,'score_band'=>$pd_officer_recommandations[ $score_questions['final_remarks']['pd_officer_recommandations'] ],'max_score_band' => max($pd_officer_recommandations)); - /*-----------END OF FINAL REMARKS SECTION -----------*/ - - - /*-----------BUSINESS SECTION -----------*/ - - - /* First Calculate Shortfall Type Questions to get distribute level - From 2.7 to 2.10 Questions are shortfall type questions (REF :- SSA_ScoreCard_Ver_090219(2)) - */ - - $business_distribute_level_weightage = 0; - - //echo $score_questions['business']['minimum_supplier_info'];die(); - if(!strcasecmp($score_questions['business']['minimum_supplier_info'],'Not Applicable')) - { - $business_distribute_level_weightage += $minimum_supplier_info_L2; - $minimum_supplier_info_L2 = 0; - } - if(!strcasecmp($score_questions['business']['minimum_client_info'],'Not Applicable')) - { - $business_distribute_level_weightage += $minimum_client_info_L2; - $minimum_client_info_L2 = 0; - } - if(!strcasecmp($score_questions['business']['stock_raw_material_enough'],'Not Applicable')) - { - $business_distribute_level_weightage += $stock_raw_material_enough_L2; - $stock_raw_material_enough_L2 = 0; - } - if(!strcasecmp($score_questions['business']['stock_finished_goods_enough'],'Not Applicable')) - { - $business_distribute_level_weightage += $stock_finished_goods_enough_L2;$stock_finished_goods_enough_L2 = 0; - } - //echo $business_distribute_level_weightage; - - //######2.7 atleast one supplier info provided - $minimum_supplier_info_L2 = $business_distribute_level_weightage ? ($minimum_supplier_info_L2 + ($minimum_supplier_info_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $minimum_supplier_info_L2 ; - - $minimum_supplier_info_actual_score = ($l1_business/100) * ($minimum_supplier_info_L2/100) * $minimum_supplier_info [ $score_questions['business']['minimum_supplier_info'] ]; - - $minimum_supplier_info_max_score = strcasecmp($score_questions['business']['minimum_supplier_info'],'Not Applicable') ? ($l1_business/100) * ($minimum_supplier_info_L2/100) * max($minimum_supplier_info) : 0; - - $score_questions['business']['minimum_supplier_info'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($minimum_supplier_info_L2),'answer' => $score_questions['business']['minimum_supplier_info'],'attributed_score' => ($minimum_supplier_info_actual_score), 'max_score' => ($minimum_supplier_info_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band'=>$minimum_supplier_info [ $score_questions['business']['minimum_supplier_info'] ],'max_score_band' => max($minimum_supplier_info)); - - //######2.8 atleast one client info provided - $minimum_client_info_L2 = $business_distribute_level_weightage ? ($minimum_client_info_L2 + ($minimum_client_info_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $minimum_client_info_L2 ; - - $minimum_client_info_actual_score = ($l1_business/100) * ($minimum_client_info_L2/100) * $minimum_client_info [ $score_questions['business']['minimum_client_info'] ]; - - $minimum_client_info_max_score = strcasecmp($score_questions['business']['minimum_client_info'],'Not Applicable') ? ($l1_business/100) * ($minimum_client_info_L2/100) * max($minimum_client_info) : 0; - - $score_questions['business']['minimum_client_info'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($minimum_client_info_L2),'answer' => $score_questions['business']['minimum_client_info'],'attributed_score' => ($minimum_client_info_actual_score), 'max_score' => ($minimum_client_info_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band'=>$minimum_client_info [ $score_questions['business']['minimum_client_info'] ],'max_score_band' => max($minimum_client_info)); - - //######2.9 stock of raw material - $stock_raw_material_enough_L2 = $business_distribute_level_weightage ? ($stock_raw_material_enough_L2 + ($stock_raw_material_enough_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $stock_raw_material_enough_L2 ; - - $stock_raw_material_enough_actual_score = ($l1_business/100) * ($stock_raw_material_enough_L2/100) * $stock_answer_scores [ strtolower($score_questions['business']['stock_raw_material_enough']) ]; - - $stock_raw_material_enough_max_score = strcasecmp($score_questions['business']['stock_raw_material_enough'],'Not Applicable') ? ($l1_business/100) * ($stock_raw_material_enough_L2/100) * max($stock_answer_scores) : 0; - - $score_questions['business']['stock_raw_material_enough'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($stock_raw_material_enough_L2),'answer' => $score_questions['business']['stock_raw_material_enough'],'attributed_score' => ($stock_raw_material_enough_actual_score), 'max_score' => ($stock_raw_material_enough_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $stock_answer_scores [ strtolower($score_questions['business']['stock_raw_material_enough']) ],'max_score_band' =>max($stock_answer_scores) ); - - //######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 )) * $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'] != "" || $score_questions['business']['stock_finished_goods_enough'] != null ? strtolower($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; - - - $temp_stock_finished_goods_enough = strtolower($score_questions['business']['stock_finished_goods_enough']); - $score_questions['business']['stock_finished_goods_enough'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($stock_finished_goods_enough_L2),'answer' => $score_questions['business']['stock_finished_goods_enough'],'attributed_score' => ($stock_finished_goods_enough_actual_score), 'max_score' => ($stock_finished_goods_enough_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $stock_answer_scores [ $temp_stock_finished_goods_enough != "" || $temp_stock_finished_goods_enough != null ? $temp_stock_finished_goods_enough : "no" ],'max_score_band' => max($stock_answer_scores)); - - - - //######2.1 Business Certificates - - $cerificates_L2 = $business_distribute_level_weightage ? ($cerificates_L2 + ($cerificates_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $cerificates_L2; - - //find out no of not applicable cases - $business_certificates_distribution_count = 0; - - foreach($score_questions['business']['cerificates'] as $value) - { - - if(strcasecmp($value,'not applicable')) - { - $business_certificates_distribution_count++; - //echo $value; - } - } - $business_certificates_distribution_count; - $business_certificates_distribution = $cerificates_L2 / $business_certificates_distribution_count; - - - - // echo $cerificates_L2.'---';echo $business_certificates_distribution_count; - // echo $business_certificates_distribution;die(); - $certificate_actual_score = 0; - $certificate_max_score = 0; - //print_r($score_questions['business']['cerificates']); - foreach($score_questions['business']['cerificates'] as $certificate_key => $certificate) - { - //print_r($certificate); - $acutal_score = 0; - $max_score = 0; - if(strcasecmp($certificate,'not applicable')) - { - $acutal_score = ($l1_business/100) * ($business_certificates_distribution/100) * $cerificates[$certificate]; - $max_score = ($l1_business/100) * ($business_certificates_distribution/100) * max($cerificates); - - } - $score_questions['business']['cerificates'][$certificate_key] = array('answer' => $certificate,'attributed_score' => ($acutal_score), 'max_score' => ($max_score),'score_band' => $cerificates[$certificate],'max_score_band'=> max($cerificates),'l1_weightage' =>($l1_business),'l2_weightage'=> ($business_certificates_distribution)); - - $certificate_actual_score += $acutal_score; - $certificate_max_score += $max_score; - } - - $score_questions['business']['cerificates']['l1_weightage'] = $l1_business; - $score_questions['business']['cerificates']['l2_weightage'] = (($business_certificates_distribution * $business_certificates_distribution_count)); - $score_questions['business']['cerificates']['distributed_weightage'] = $business_distribute_level_weightage; - $score_questions['business']['cerificates']['max_score'] = ($certificate_max_score); - $score_questions['business']['cerificates']['attributed_score'] = ($certificate_actual_score); - $score_questions['business']['cerificates']['score_band'] = 'Derived'; - $score_questions['business']['cerificates']['max_score_band'] = 'Derived'; - - //print_r($score_questions['business']['cerificates']);die(); - //######2.1 no_of_years_business_run - - $no_of_years_business_run_actual_score = 0; - $score_band = 0; - foreach($no_of_years_business_run as $key => $value) - { - $exp = explode('to',$key); - //print_r($exp); - $left = $exp[0].$score_questions['business']['no_of_years_business_run']; - $right = $score_questions['business']['no_of_years_business_run'].$exp[1]; - //echo $left.'````'.$right;echo "\n"; - eval( '$left_exp = ' . $left . ';'); - eval( '$right_exp = ' . $right . ';'); - if($left_exp && $right_exp) - { - - $no_of_years_business_run_L2 = $business_distribute_level_weightage ? ($no_of_years_business_run_L2 + ($no_of_years_business_run_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $no_of_years_business_run_L2 ; - - $no_of_years_business_run_actual_score = ($l1_business/100) * ($no_of_years_business_run_L2/100) * $value; - $score_band = $value; - } - - } - - - - $no_of_years_business_run_max_score = ($l1_business/100) * ($no_of_years_business_run_L2/100) * max($no_of_years_business_run); - - $score_questions['business']['no_of_years_business_run'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($no_of_years_business_run_L2),'answer' => $score_questions['business']['no_of_years_business_run'],'attributed_score' => ($no_of_years_business_run_actual_score), 'max_score' => ($no_of_years_business_run_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $score_band,'max_score_band' => max($no_of_years_business_run)); - - - //######2.2 business seasonal - - - $business_seasonality_L2 = $business_distribute_level_weightage ? ($business_seasonality_L2 + ($business_seasonality_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $business_seasonality_L2 ; - - $business_seasonality_actual_score = ($l1_business/100) * ($business_seasonality_L2/100) * $business_seasonality[ $score_questions['business']['business_seasonality'] ]; - - $business_seasonality_max_score = ($l1_business/100) * ($business_seasonality_L2/100) * max($business_seasonality); - - $score_questions['business']['business_seasonality'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($business_seasonality_L2),'answer' => $score_questions['business']['business_seasonality'],'attributed_score' => ($business_seasonality_actual_score), 'max_score' =>($business_seasonality_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $business_seasonality[ $score_questions['business']['business_seasonality'] ],'max_score_band' => max($business_seasonality)); - - //######2.3 employees_total - $employees_total_actual_score = 0; - - $employees_total_L2 = $business_distribute_level_weightage ? ($employees_total_L2 + ($employees_total_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $employees_total_L2 ; - $score_band = 0; - foreach($employees_total as $key => $value) - { - $exp = explode('to',$key); - //print_r($exp); - $left = $exp[0].$score_questions['business']['employees_total']; - $right = $score_questions['business']['employees_total'].$exp[1]; - //echo $left.'````'.$right;echo "\n"; - eval( '$left_exp = ' . $left . ';'); - eval( '$right_exp = ' . $right . ';'); - if($left_exp && $right_exp) - { - $employees_total_actual_score = ($l1_business/100) * ($employees_total_L2/100) * $value; - $score_band = $value; - } - - } - // echo $score_band; - // die(); - - - $employees_total_max_score = ($l1_business/100) * ($employees_total_L2/100) * max($employees_total); - - $score_questions['business']['employees_total'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($employees_total_L2),'answer' => $score_questions['business']['employees_total'],'attributed_score' => ($employees_total_actual_score), 'max_score' => ($employees_total_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' =>$score_band,'max_score_band' => max($employees_total)); - - - //######2.5 owned_property - - $owned_property_L2 = $business_distribute_level_weightage ? ($owned_property_L2 + ($owned_property_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $owned_property_L2 ; - - $owned_property_actual_score = ($l1_business/100) * ($owned_property_L2/100) * $owned_property[ $score_questions['business']['owned_property'] ]; - $owned_property_max_score = ($l1_business/100) * ($owned_property_L2/100) * max($owned_property); - - $score_questions['business']['owned_property'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($owned_property_L2),'answer' => $score_questions['business']['owned_property'],'attributed_score' => ($owned_property_actual_score), 'max_score' => ($owned_property_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $owned_property[ $score_questions['business']['owned_property'] ],'max_score_band' => max($owned_property)); - - //######2.6 owned_vechile - $owned_vechile_L2 = $business_distribute_level_weightage ? ($owned_vechile_L2 + ($owned_vechile_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $owned_vechile_L2 ; - - $owned_vechile_actual_score = ($l1_business/100) * ($owned_vechile_L2/100) * $owned_vechile[ $score_questions['business']['owned_vechile'] ]; - $owned_vechile_max_score = ($l1_business/100) * ($owned_vechile_L2/100) * max($owned_vechile); - - $score_questions['business']['owned_vechile'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($owned_vechile_L2),'answer' => $score_questions['business']['owned_vechile'],'attributed_score' => ($owned_vechile_actual_score), 'max_score' => ($owned_vechile_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $owned_vechile[ $score_questions['business']['owned_vechile'] ],'max_score_band' => max($owned_vechile)); - - //######2.11 location_suited_for_busienss - - // $location_suited_for_busienss_L2 = $business_distribute_level_weightage ? ($location_suited_for_busienss_L2 + ($location_suited_for_busienss_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $location_suited_for_busienss_L2 ; - - // $location_suited_for_busienss_actual_score = ($l1_business/100) * ($location_suited_for_busienss_L2/100) * $location_suited_for_busienss[ $score_questions['business']['location_suited_for_busienss'] ]; - // $location_suited_for_busienss_max_score = ($l1_business/100) * ($location_suited_for_busienss_L2/100) * max($location_suited_for_busienss); - - // $score_questions['business']['location_suited_for_busienss'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($location_suited_for_busienss_L2),'answer' => $score_questions['business']['location_suited_for_busienss'],'attributed_score' => ($location_suited_for_busienss_actual_score), 'max_score' => ($location_suited_for_busienss_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $location_suited_for_busienss[ $score_questions['business']['location_suited_for_busienss'] ],'max_score_band' => max($location_suited_for_busienss)); - - //######2.11 business_activity_has_seen - - $business_activity_has_seen_L2 = $business_distribute_level_weightage ? ($business_activity_has_seen_L2 + ($business_activity_has_seen_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $business_activity_has_seen_L2 ; - - $business_activity_has_seen_actual_score = ($l1_business/100) * ($business_activity_has_seen_L2/100) * $business_activity_has_seen[ $score_questions['business']['business_activity_has_seen'] ]; - $business_activity_has_seen_max_score = ($l1_business/100) * ($business_activity_has_seen_L2/100) * max($business_activity_has_seen); - - $score_questions['business']['business_activity_has_seen'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($business_activity_has_seen_L2),'answer' => $score_questions['business']['business_activity_has_seen'],'attributed_score' => ($business_activity_has_seen_actual_score), 'max_score' => ($business_activity_has_seen_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $business_activity_has_seen[ $score_questions['business']['business_activity_has_seen'] ], 'max_score_band' => max($business_activity_has_seen)); - - //######2.13 vintage business banking - - $vintage_of_business_account_L2 = $business_distribute_level_weightage ? ($vintage_of_business_account_L2 + ($vintage_of_business_account_L2 / (100 - $business_distribute_level_weightage )) * $business_distribute_level_weightage) : $vintage_of_business_account_L2 ; - - $vintage_of_business_account_actual_score = 0; - $score_band = 0; - foreach($vintage_of_business_account as $key => $value) - { - $exp = explode('to',$key); - //print_r($exp); - $left = $exp[0].$score_questions['business']['vintage_of_business_account']; - $right = $score_questions['business']['vintage_of_business_account'].$exp[1]; - //echo $left.'````'.$right;echo "\n"; - eval( '$left_exp = ' . $left . ';'); - eval( '$right_exp = ' . $right . ';'); - if($left_exp && $right_exp) - { - $vintage_of_business_account_actual_score = ($l1_business/100) * ($vintage_of_business_account_L2/100) * $value; - $score_band = $value; - } - - } - - - - $vintage_of_business_account_max_score = ($l1_business/100) * ($vintage_of_business_account_L2/100) * max($vintage_of_business_account); - - - $vintage_of_business_account_for_display = explode('.',($score_questions['business']['vintage_of_business_account'])); - $vintage_of_business_account_for_display = ($vintage_of_business_account_for_display[0] != 0 ? $vintage_of_business_account_for_display[0].' Yrs ' : '') . (isset($vintage_of_business_account_for_display[1]) && $vintage_of_business_account_for_display[1] != 0 ? $vintage_of_business_account_for_display[1].' Mns ' : ''); - - $score_questions['business']['vintage_of_business_account'] = array('l1_weightage' => $l1_business,'l2_weightage' => ($vintage_of_business_account_L2),'answer' => $vintage_of_business_account_for_display,'attributed_score' => ($vintage_of_business_account_actual_score), 'max_score' => ($vintage_of_business_account_max_score),'distributed_weightage' => $business_distribute_level_weightage,'score_band' => $score_band,'max_score_band' => max($vintage_of_business_account)); - /*-----------END OF BUSINESS SECTION -----------*/ - - - - /* Calculate Overall Total*/ - $overall_max_score = 0; - $overall_actual_score = 0; - foreach($score_questions as $key => $value) - { - - $current_max_score = 0; - $current_actual_score = 0; - foreach($value as $v_key => $f_value) - { - $overall_max_score += $f_value['max_score']; - $overall_actual_score += $f_value['attributed_score']; - - $current_max_score += $f_value['max_score']; - $current_actual_score += $f_value['attributed_score']; - - } - $score_questions['score_summary'][$key] = array('actual_score' => $current_actual_score,'max_score' => $current_max_score,'score_per' => (($current_actual_score/$current_max_score) * 100)); - - } - $score_questions['score_summary']['overall_score'] = array('overall_actual_score' => $overall_actual_score, 'overall_max_score' => $overall_max_score,'final_score' => (($overall_actual_score/$overall_max_score) * 100)); - - $score_questions['score_summary']['asset_calculation_details'] = $asset_calculation_details; - //print_r($score_questions);die(); - return ($score_questions); - - - - } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 872a825a..50540eaa 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -100,7 +100,7 @@ class PD_Model extends SPARQ_Model { { $this->db->WHERE('PDTRIGGER.pd_agency_id',$pdagencyid); //$this->db->WHERE('PDTRIGGER.vendor_status',TRIGGERED); - $this->db->WHERE("if(vendor_status = 'TRIGGERED', if( pd_status in ('SCHEDULED','ALLOCATED','INPROGRESS','COMPLETED'),1,0),0)=0"); + $this->db->WHERE("if(vendor_status = 'TRIGGERED', if( pd_status in ('ALLOCATED'),1,0),0)=0"); } if($status != "" || $status != null) { @@ -270,7 +270,7 @@ class PD_Model extends SPARQ_Model { if($pd_agency_id != "" || $pd_agency_id != null ) { $this->db->LIKE('PDTRIGGER.pd_agency_id',$pd_agency_id); - $this->db->WHERE("if(vendor_status = 'TRIGGERED', if( pd_status in ('SCHEDULED','ALLOCATED','INPROGRESS','COMPLETED'),1,0),0)=0"); + $this->db->WHERE("if(vendor_status = 'TRIGGERED', if( pd_status in ('ALLOCATED'),1,0),0)=0"); } if($pd_officer_id != "" || $pd_officer_id != null ) { @@ -744,7 +744,7 @@ class PD_Model extends SPARQ_Model { break; case 'pincode': - //echo "pincode"; + //echo "pincode_ide"; if($log['old_pincode'] != null || $log['old_pincode'] != "") { if(is_numeric($log['new_pincode']) && is_numeric($log['old_pincode'])) diff --git a/api/application/views/report_templates/JSONTOREPORT_SAL_SMARTPD.php b/api/application/views/report_templates/JSONTOREPORT_SAL_SMARTPD.php index ce29908c..c41700e2 100644 --- a/api/application/views/report_templates/JSONTOREPORT_SAL_SMARTPD.php +++ b/api/application/views/report_templates/JSONTOREPORT_SAL_SMARTPD.php @@ -2078,7 +2078,7 @@ font-weight: bolder;; if(isset($vendor_employer_info['docs_sighted'])) { //print_r($vendor_employer_info['docs_sighted']['sal_reg_seen'] == 'yes' ? 'Salary Register': '');die(); - echo '

Documents Sighted of applicant employment During Field:

'; + echo '

Documents Sighted of applicant employment During Field:

'; $document_name = ''; $document_name .= ($vendor_employer_info['docs_sighted']['sal_reg_seen'] == 'yes' ? 'Salary Register, ': ''); $document_name .= ($vendor_employer_info['docs_sighted']['attendance_seen'] == 'yes' ? 'Attendance Register, ' : '');