diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 4fba1808..443c694f 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -206,6 +206,7 @@ $route['saveHTMLReport'] = 'PD_Controller/saveHTMLReport'; $route['(getPDReportHTML/:any/:any)'] = 'PD_Controller/getPDReportHTML'; $route['convertBase64'] = 'PD_Controller/convertImgUrlToBase64'; $route['updateNotificationToken'] = 'PD_Controller/updateNotificationToken'; +$route['getPDScore'] = 'PD_Controller/getPDScoreForDisplay'; // $route['savePDFormDetailsJSON'] = 'PD_Controller/savePDFormDetailsJSON'; // $route['getPDFormDetailsJSON'] = 'PD_Controller/getPDFormDetailsJSON'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 92f30bb4..ec5bca2f 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -4193,9 +4193,9 @@ class PD_Controller extends REST_Controller { $temp_path = $main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; - $this->zip->archive(APPPATH.'docs/'.$temp_path); + $this->zip->archive(APPPATH.'docs/zip/'.$temp_path); - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>(APPPATH.'docs/'.$temp_path)); + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>(APPPATH.'docs/zip/'.$temp_path)); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); //print_r($s3result); @@ -4205,6 +4205,7 @@ class PD_Controller extends REST_Controller { $where_condition_array = array("pd_id" => $pdid); $temp_array['is_zip_created'] = 1; $id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + - unlink(APPPATH.'docs/zip/'.$temp_path); } @@ -6218,6 +6219,8 @@ class PD_Controller extends REST_Controller { public function calculateScore($pdid) { + + //echo $pdid;die(); //GET JSON FORM DATA $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); //print_r($pd_master_details); @@ -7713,4 +7716,20 @@ class PD_Controller extends REST_Controller { } } + + + public function getPDScoreForDisplay_post() + { + $pdid = $this->post('pd_id'); + + $score = $this->calculateScore($pdid); + //print_r($score);die(); + $score_questions_display = $this->PD_Model->getScoreableQuestionToDispaly($pdid); + $t = $this->load->view('report_templates/scorecard',array('pd_score' => $score,'score_questions_display' => $score_questions_display),true); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $t; + $this->response($data,REST_Controller::HTTP_OK); + } } \ No newline at end of file diff --git a/api/application/docs/sample.pdf b/api/application/docs/sample.pdf index 25f36d7c..2f4ede7d 100644 Binary files a/api/application/docs/sample.pdf and b/api/application/docs/sample.pdf differ diff --git a/api/application/helpers/InlinePhotoTransform_helper.php b/api/application/helpers/InlinePhotoTransform_helper.php deleted file mode 100644 index 8d73a2fc..00000000 --- a/api/application/helpers/InlinePhotoTransform_helper.php +++ /dev/null @@ -1,199 +0,0 @@ -PD_Model->getPDMasterDetails($records['pdid']); - - foreach ($records['individuals'] as $key => $value) { - if(isset($value['is_person_met_pic']) && $value['is_person_met_pic'] != "") - { - $base64 = self::addTimestampAndReturnBase64($CI,$value['is_person_met_pic'],$value['applicant_name'],$pd_details,18); - $records['individuals'][$key]['is_person_met_pic'] = $base64; - } - if(isset($value['is_person_met_id_proof']) && $value['is_person_met_id_proof'] != "") - { - $base64 = self::addTimestampAndReturnBase64($CI,$value['is_person_met_id_proof'],($value['applicant_name'].'-id_proof'),$pd_details,18); - $records['individuals'][$key]['is_person_met_id_proof'] = $base64; - } - - return $records; - - } - } - } - - - public static function retransformBusinessFormInlinePhotos($records) - { - - $CI =&get_instance(); - $pd_details =$CI->PD_Model->getPDMasterDetails($records['pdid']); - $busienss_info_location = (isset($records['business_info_location']) ? $records['business_info_location'] : null); - - if(isset($records['shop_eat_act_cert']) && $records['shop_eat_act_cert'] == 'yes' && isset($records['shop_eat_act_cert_pic']) && $records['shop_eat_act_cert_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['shop_eat_act_cert_pic'],'shop_eat_act_cert_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['shop_eat_act_cert_pic'] = $base64; - - } - - - if(isset($records['gst_Regn_cert']) && $records['gst_Regn_cert'] == 'yes' && isset($records['gst_Regn_cert_pic']) && $records['gst_Regn_cert_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['gst_Regn_cert_pic'],'gst_Regn_cert_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['gst_Regn_cert_pic'] = $base64; - - } - - if(isset($records['pf_regn']) && $records['pf_regn'] == 'yes' && isset($records['pf_regn_pic']) && $records['pf_regn_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['pf_regn_pic'],'pf_regn_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['pf_regn_pic'] = $base64; - - } - - - if(isset($records['esic_regn']) && $records['esic_regn'] == 'yes' && isset($records['esic_regn_pic']) && $records['esic_regn_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['esic_regn_pic'],'esic_regn_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['esic_regn_pic'] = $base64; - - } - - if(isset($records['export_import_cert']) && $records['export_import_cert'] == 'yes' && isset($records['export_import_cert_pic']) && $records['export_import_cert_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['export_import_cert_pic'],'export_import_cert_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['export_import_cert_pic'] = $base64; - - } - - - if(isset($records['factory_cert']) && $records['factory_cert'] == 'yes' && isset($records['factory_cert_pic']) && $records['factory_cert_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['factory_cert_pic'],'factory_cert_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['factory_cert_pic'] = $base64; - - } - - if(isset($records['practice_cert']) && $records['practice_cert'] == 'yes' && isset($records['practice_cert_pic']) && $records['practice_cert_pic'] != '') - { - - $base64 = self::addTimestampAndReturnBase64($CI,$records['practice_cert_pic'],'practice_cert_pic',$pd_details,13,$records['company_id'],$busienss_info_location); - $records['practice_cert_pic'] = $base64; - - } - - if(isset($records['documents']) && count($records['documents'])) - { - foreach ($records['documents'] as $key => $value) { - - if($value['document_pic'] != '') - { - $base64 = self::addTimestampAndReturnBase64($CI,$value['document_pic'],$value['document'],$pd_details,13,$records['company_id'],$busienss_info_location); - $records['documents'][$key]['document_pic'] = $base64; - } - - } - } - - - return $records; - } - - - - public static function addTimestampAndReturnBase64($CI,$base64,$doc_name,$pd_details,$form_id,$company_id = null,$location = '') - { - // ############################################## - - $temp_base64_string = $base64; - $title = $doc_name; - $output_file = APPPATH."/docs/temp_base64_image.png"; - - //Generate Random File Name - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - $temp_file_name = $randomString.date('Y-m-d-H:i:s').'.png'; - - - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); - //echo mime_content_type($output_file); - // ################### start img water marking with text - $imagetobewatermark=imagecreatefromstring(file_get_contents(($output_file))); - $location_watermarktext="Location: ".($location != null ? $location: $pd_details[0]['start_location']); - $font=APPPATH."docs/robold.ttf"; //metion font and it's location - $fontsize="12"; - $water_mark_text_color = imagecolorallocate($imagetobewatermark, 225, 0, 0); - $x = imagesy($imagetobewatermark); - $y = imagesy($imagetobewatermark); - - imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 30), $water_mark_text_color, $font, $location_watermarktext); - - imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 10), $water_mark_text_color, $font, 'DateB: '.date('Y-m-d h:i:s a')); - imagepng($imagetobewatermark,$output_file);//save as png file in ouputfile location - //################# end img water marking with text - - //###########image water marking with logo - $pd_logo = imagecreatefromstring(file_get_contents(APPPATH.'docs/icon.png')); - $curret_file = imagecreatefromstring(file_get_contents($output_file)); - $sx = imagesx($curret_file); - $sy = imagesy($curret_file); - // imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool - imagecopyresized ( $curret_file , $pd_logo , 5 , ($y - 54) , 0 , 0 , 50 , 50 , 50 , 54 ); - - imagepng($curret_file,$output_file);// save png image in specified location - - - //###########end of image water marking with logo - self::saveImagesInS3($CI,$pd_details,$output_file,$temp_file_name,$form_id,$title,$company_id); - //convert img to base64 - //$path = $output_file; - //$type = pathinfo($path, PATHINFO_EXTENSION); - $data = file_get_contents($output_file); - return 'data:image/png;base64,' . base64_encode($data); - - //ENd of convert img to base64 - - - } - - public static function saveImagesInS3($CI,$pd_details,$output_file,$temp_file_name,$form_id,$title,$company_id = null) - { - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; - $key = 'pd'.$pd_details[0]['pd_id'].'/'.$tempdocname; - - $sourcefile = $tempdoc; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data); - - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - $record_data = array('fk_pd_id' => $pd_details[0]['pd_id'],'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'company_id' => $company_id); - $id = $CI->PD_Model->saveRecords($record_data,PDDOCUMENTS); - //if($id != null || $id != "") { $count++;} - } - } -} diff --git a/api/application/helpers/assetsform_helper.php b/api/application/helpers/assetsform_helper.php index 9a34d3eb..41d04770 100644 --- a/api/application/helpers/assetsform_helper.php +++ b/api/application/helpers/assetsform_helper.php @@ -14,7 +14,7 @@ public static function getOthersAssetsDetails($values){ foreach ( $fetchVal['name_of_the_owner'] as $o_key => $owner) { if($owner['id'] == 0) { - $assest_owners_name .= $fetchVal['other_owner']; + $assest_owners_name .= $fetchVal['other_owner']. ','; } else { @@ -22,19 +22,13 @@ public static function getOthersAssetsDetails($values){ } } - //echo $assest_owners_name.'-'; - if(strrpos($assest_owners_name,',') && count($fetchVal['name_of_the_owner']) >=2) - { - $assest_owners_name = substr_replace($assest_owners_name, 'and', strrpos($assest_owners_name,','),1) ; - } - else if(strrpos($assest_owners_name,',')) - { + $assest_owners_name = substr_replace($assest_owners_name, '', strrpos($assest_owners_name,','),1) ; - } - //echo $assest_owners_name.'-'; - // if(!strcasecmp(substr($assest_owners_name, 0,3),'and')) {$assest_owners_name = substr_replace($assest_owners_name,'',0,'and',3);} - - // echo $assest_owners_name.'-';die(); + if(strrpos($assest_owners_name,',')) + { + $assest_owners_name = substr_replace($assest_owners_name, 'and', strrpos($assest_owners_name,','),1) ; + } + $storeValue['assets_mode'] = $fetchVal['assets_mode_master']; $storeValue['name_of_the_owner'] = $assest_owners_name; $storeValue['purchase_year'] = $fetchVal['vintage_personal']; diff --git a/api/application/views/report_templates/scorecard.php b/api/application/views/report_templates/scorecard.php new file mode 100644 index 00000000..dd3c221d --- /dev/null +++ b/api/application/views/report_templates/scorecard.php @@ -0,0 +1,576 @@ + + + + + + + + + + + + + + + + + '; + echo "

Detailed Score Card Section

" ; + // *** General Section Questions Score Table + echo ''; + echo ""; + foreach($pd_score['general'] as $key => $general) + { + + $question = MYUTIL::findQuestionByKey($score_questions_display,$key); + $span = '('.$general['l1_weightage'].'% * '. $general['l2_weightage'].'% * '.$general['score_band'].')'; + $max_span = '('.$general['l1_weightage'].'% * '. $general['l2_weightage'].'% * '.$general['max_score_band'].')'; + echo ''.''; + } + + echo ''; + echo '
General Questions L1(". $pd_score['general']['otp_done']['l1_weightage']."%) L2 Answer Score Attributed Score Max Score
'.$question.''.$general['l2_weightage'] .'%'.$general['answer']. + ''.$general['score_band'].''.$general['attributed_score'].'
'.$span.'
'.$general['max_score'].'
'.$max_span.'
General Section Sum of Attributed Score | Sum of Max Score '.number_format($pd_score['score_summary']['general']['actual_score'],2,'.',',').' '.number_format($pd_score['score_summary']['general']['max_score'],2,'.',',').'
'; + + echo '

'; + + + // *** Asset Caculation Score Table + echo ''; + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + + + echo '
Asset Value Calculaitons
Actual Value Of Assets (a)". number_format($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets'],2,'.',',')."
Loan Amount (b)". number_format($pd_score['score_summary']['asset_calculation_details']['loan_amount'],2,'.',',')."
Avg Expected Value Of Assets (c)". round($pd_score['score_summary']['asset_calculation_details']['avg_expected_value_of_assets'],2)."%
Expected Value Of Assets (d = c*b)". number_format($pd_score['score_summary']['asset_calculation_details']['expected_value_of_assets'],2,'.',',')."
Actual Value Of Assets Percentage (e = (a/b) * 100)". round($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets_percentage'],2)."%
Variance (f = ((e-c)/c) * 100)". round($pd_score['score_summary']['asset_calculation_details']['variance'],2)."%
Score As per Grid". round($pd_score['score_summary']['asset_calculation_details']['score'],2)."
'; + + echo '


'; + // *** Final Remarks Questions Score Table + echo ''; + echo ""; + foreach($pd_score['final_remarks'] as $key => $final_remark) + { + $question = MYUTIL::findQuestionByKey($score_questions_display,$key); + + $span = '('.$final_remark['l1_weightage'].'% * '. $final_remark['l2_weightage'].'% * '.$final_remark['score_band'].')'; + + $max_span = '('.$final_remark['l1_weightage'].'% * '. $final_remark['l2_weightage'].'% * '.$final_remark['max_score_band'].')'; + + echo ''.''; + } + + echo ''; + echo '
Final Remarks Questions L1(". $pd_score['final_remarks']['pd_officer_recommandations']['l1_weightage']."%) L2Answer ScoreAttributed Score Max Score
'.$question.''.$final_remark['l2_weightage'].'%'.$final_remark['answer'].''.$final_remark['score_band'].''.$final_remark['attributed_score'].'
'.$span.'
'.$final_remark['max_score'].'
'.$max_span.'
Final Remarks Section Sum of Attributed Score | Sum of Max Score '.number_format($pd_score['score_summary']['final_remarks']['actual_score'],2,'.',',').' '.number_format($pd_score['score_summary']['final_remarks']['max_score'],2,'.',',').'
'; + echo '


'; + + //print_r($pd_score['business']); + echo ''; + + // *** Business Section Questions Score Table + echo ""; + $certificates = array(); + foreach($pd_score['business'] as $key => $business) + { + + $question = MYUTIL::findQuestionByKey($score_questions_display,$key); + $span = '('.$business['l1_weightage'].'% * '. $business['l2_weightage'].'% * '.$business['score_band'].')'; + $max_span = '('.$business['l1_weightage'].'% * '. $business['l2_weightage'].'% * '.$business['max_score_band'].')'; + + if(($key != 'cerificates') && ($key != 'location_suited_for_busienss')) + { + echo ''.''; + } + + if($key == 'location_suited_for_busienss') + { + echo ''.''; + } + + if($key == 'cerificates') + { + $certificates = $business; + + echo ''.''; + } + + } + + echo ''; + echo '
Business Questions L1(". $pd_score['business']['no_of_years_business_run']['l1_weightage']."%) L2Answer Score Attributed ScoreMax Score
'.$question.''.$business['l2_weightage'].'%'.$business['answer'].''.$business['score_band'].''.$business['attributed_score'].'
'.$span.'
'.$business['max_score'].'
'.$max_span.'
'.$question.''.$business['l2_weightage'].'%'.$address_type_remarks_caption[ $business['answer'] ].''.$business['score_band'].''.$business['attributed_score'].'
'.$span.'
'.$business['max_score'].'
'.$max_span.'
Certificates '.round($business['l2_weightage'],2).'%'.'Refer Cert Table'.''.$business['score_band'].''.$business['attributed_score'].''.$business['max_score'].'
Business Section Sum of Attributed Score | Sum of Max Score '.number_format($pd_score['score_summary']['business']['actual_score'],2,'.',',').' '.number_format($pd_score['score_summary']['business']['max_score'],2,'.',',').'
'; + + + // *** Business Certificates Score Table + + + echo '

'; + + echo ""; + echo ""; + $index = 0; + // print_r($certificates); + foreach($certificates as $key => $cerificate) + { + $index++; + if($index <=7) + { + $question = MYUTIL::findQuestionByKey($score_questions_display,$key); + $span = '('.$cerificate['l1_weightage'].'% * '. $cerificate['l2_weightage'].'% * '.$cerificate['score_band'].')'; + + $max_span = '('.$cerificate['l1_weightage'].'% * '. $cerificate['l2_weightage'].'% * '.$cerificate['max_score_band'].')'; + + echo ''.''; + } + } + echo "
Business Certificates Answer Score Attributed Score Max Score
'.$question.''.$cerificate['answer'].''.$cerificate['score_band'].''.round($cerificate['attributed_score'],3).'
'.$span.'
'.round($cerificate['max_score'],3).'
'.$max_span.'
"; + } +// ########################### End Of Score Card Section ######################################### + ?> + + + + + \ No newline at end of file