From ccff530c892fe09e7087a28c6966c2b4e1e7d6a4 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Wed, 18 Nov 2020 02:15:02 +0530 Subject: [PATCH] SMC CREDIT PD REPORT --- .../controllers/SMC_Credit_PD_Controller.php | 46 +- .../helpers/smc_creditpd_helper.php | 138 +++++ .../views/smc_creditpd_reports/MWISE.php | 560 ++++++++++++++++++ 3 files changed, 740 insertions(+), 4 deletions(-) create mode 100644 api/application/helpers/smc_creditpd_helper.php create mode 100644 api/application/views/smc_creditpd_reports/MWISE.php diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index af679d14..75f3aedd 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1431,11 +1431,49 @@ public function filterSalesPDList_post() { public function smcCreditPDReport_post() { $records = $this->post('records'); - print_r($records); + $this->load->helper('smc_creditpd'); + // print_r($records); - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); - $pd_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,'fk_pd_id' => $records['pd_id']),SMC_CREDIT_PD_SECTION_DATA); - echo count($pd_section_data); + $view_data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($records['pd_id']); + $view_data['applicant_details'] = $this->PD_Model->getApplicantsDetails($records['pd_id']); + $pd_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,'fk_pd_id' => $records['pd_id']),SMC_CREDIT_PD_SECTION_DATA,array(),'','fk_form_id','ASC'); + // print_r ($view_data['pd_master_details']);die(); + + if(count($pd_section_data)) + { + foreach ($pd_section_data as $key => $value) + { + $value['json'] = smc_creditpd::getSMCCreditPDReportContent($value); + $view_data['pd_section_data'][$value['fk_form_id']] = $value['json']; + //die(); + } + } + // print_r($view_data['pd_section_data'][11]);die(); + + $html_content = $this->load->view('smc_creditpd_reports/MWISE',$view_data,true); + // echo $html_content;die(); + $pdf_name = $view_data['pd_master_details'][0]['main_applicant']; + $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file = $this->external_path ."/pd_reports/" . $records['pd_id'] . "/temp.pdf"; + $bytes = file_put_contents($output_file, $pdf_doc); + + $bucket_name = LENDER_BUCKET_NAME_PREFIX.(ENVIRONMENT == 'production' ? 7 : 35); + $key = 'pd'.$records['pd_id'].'/pd_reports/'.$pdf_name.'.pdf'; + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$output_file); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + + // $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $singed_uri; + $this->response($data,REST_Controller::HTTP_OK); + + } } } diff --git a/api/application/helpers/smc_creditpd_helper.php b/api/application/helpers/smc_creditpd_helper.php new file mode 100644 index 00000000..1fcbf0f1 --- /dev/null +++ b/api/application/helpers/smc_creditpd_helper.php @@ -0,0 +1,138 @@ +load->model('PD_Model'); + $return_data =array(); + switch($section['fk_form_id']) + { + case 1://borrower + $return_data = SELF::getBorrowerSectionData($section); + break; + + case 2://address + case 3://fund + case 4://General Business + case 5://Key Stakeholders + case 6://bbusiness brief + case 7://emp strength + case 10://finance + + case 12://client + case 16://other family + $return_data = json_decode($section['json'],true); + break; + case 8://assest + $return_data = SELF::getAssestSectionData($section); + break; + + // case 11://supplier + // $return_data = SELF::getSupplierSectionData($section); + // break; + + } + return $return_data; + } + + + static function getBorrowerSectionData($section) + { + $json = json_decode($section['json'],true); + foreach ($json['borrower_details'] as $key => $value) + { + if(!strcasecmp($value['borrower_met'],'yes')) + { + $json['person_met'] = $value['borrower_name']; + break; + } + } + if(!isset($json['person_met'])) + { + $json['person_met'] = 'No One Met'; + } + return $json; + } + + static function getAssestSectionData($section) + { + $json = json_decode($section['json'],true); + // $CI =&get_instance(); + // $CI->load->model('PD_Model'); + + $applicant_details = applicantname_grabber::getLatestApplicantsName($section['fk_pd_id']); + $asset_type = array('2' => 'Property','3' => 'Vehicle','4' => 'Equipments and machinery','5' => 'Jewellery','6' => 'Life Insurance Policy','7' => 'Investments','1' => 'Others'); + // print_r($applicant_details);die(); + + $header_row = ''.' Particulars '; + $first_row = ''.' Asset Type '; + $second_row = ''.' Asset Description '; + $third_row = ''.' Asset Ownership (Owned / Rented) '; + $fourth_row = ''.' If Owned then Owner Name '; + $five_row = ''.' If Owned then Market Value '; + $siz_row = ''.' Age of the Asset (Years) '; + $seven_row = ''.' Is there a Loan Against the Asset? (Yes / No) '; + foreach ($json['business_assets_details'] as $key => $value) + { + $header_row .= ' Assest '. ( $key + 1 ).''; + $first_row .= ''. $asset_type [ $value['business_assets_mode'] ].''; + $second_row .= ''. $value['other_asset_description'] .''; + $third_row .= ' '. $value['business_ownership_type'] .' '; + $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); + $fourth_row .= ' '. $business_name_of_the_owner .' '; + $five_row .= ' '. (isset($value['business_approximate_market_value']) ? $value['business_approximate_market_value'] : 'NA') .' '; + $siz_row .= ' '. (isset($value['business_purchase_year']) ? $value['business_purchase_year'] : 'NA') .' '; + $seven_row .= ' '. (isset($value['business_emi']) ? $value['business_emi'] : 'NA') .' '; + } + $header_row .= ''; + $first_row .= ''; + $second_row .= ''; + $third_row .= ''; + $fourth_row .= ''; + $five_row .= ''; + $siz_row .= ''; + + $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row); + return $json; + } + + static function getSupplierSectionData($section) + { + $json = json_decode($section['json'],true); + $header_row = ''.' Particulars '; + $first_row = ''.' Item Purchased '; + $second_row = ''.' Contact Person '; + $third_row = ''.' Mobile Number '; + $fourth_row = ''.' Landline No '; + $five_row = ''.' Payment Terms '; + $siz_row = ''.' Payment Mode '; + $seven_row = ''.' No of days credit '; + foreach ($json['business_assets_details'] as $key => $value) + { + $header_row .= ''.$value['supplier_name'].''; + $first_row .= ''. $value['provider_name'] .''; + $second_row .= ''. $value['contact_person_name'] .''; + $third_row .= ' '. $value['business_ownership_type'] .' '; + $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); + $fourth_row .= ' '. $value['contact_person_mobile_no'] .' '; + $five_row .= ' '. (isset($value['person_landline']) ? $value['person_landline'] : 'NA') .' '; + $siz_row .= ' '. (isset($value['payment_type']) ? $value['payment_type'] : 'NA') .' '; + $seven_row .= ' '. (isset($value['payment_mode']) ? $value['payment_mode'] : 'NA') .' '; + } + $header_row .= ''; + $first_row .= ''; + $second_row .= ''; + $third_row .= ''; + $fourth_row .= ''; + $five_row .= ''; + $siz_row .= ''; + + $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row); + } + + +} +?> \ No newline at end of file diff --git a/api/application/views/smc_creditpd_reports/MWISE.php b/api/application/views/smc_creditpd_reports/MWISE.php new file mode 100644 index 00000000..4d4455d4 --- /dev/null +++ b/api/application/views/smc_creditpd_reports/MWISE.php @@ -0,0 +1,560 @@ +↑'; + $downarrow = ''; + $dash = ' '; + // $product_name = $master[0]['abbr']; + $rupee_symbol = ""; + //print_r($master[0]['abbr']);die(); +?> + + + + + + + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Personal Discussion Sheet - Business Loans
Application ID
Name of the Company/Firm
Name of Person Met During Visit
CityStatePIN
+ +
+ + + + + + + + + + + + + + + + + + +
Fund Requirement
Loan Amount Applied for (Rs)Total Fund Requirement (Rs)
Loan Tenure (Months)Loan Purpose (End-Use)
+
+ + + + + + + + + + + + + + + $section5_value) + { + echo ''. + ''. + ''. + ''. + + ''. + ''. + ''; + } + + } + + ?> +
Details of Key Stakeholders in the Business
NameShare HoldingYear(s) in Current BusinessTotal Work Exp(Yrs)Previous Experience DetailsStarted Business
'.$section5_value['stakeholder_name'] .''.$section5_value['share_holding'].'%'.$section5_value['vintage_in_current_biz'].''.$section5_value['total_work_exp'].''.( isset ($section5_value['previous_experience_details']) && $section5_value['previous_experience_details'] ? $section5_value['previous_experience_details'] : 'NA' ).''.$section5_value['started_biz'].'
+ + + + + + + + + + + + + + + + $section16_value) + { + echo ''. + ''. + ''. + ''. + + // ''. + ''. + ''; + } + + } + + ?> +
Other Family Members involved in the business
NameRelationshipRelation to Individual StakeholdersRelation to Company / FirmStarted Biz (Yes / No)
'.$section16_value['member_name'] .''.$section16_value['relationship'].''.$section16_value['stakeholder_relation'].''.$section16_value['company_relation'].''.( isset ($section5_value['previous_experience_details']) && $section5_value['previous_experience_details'] ? $section5_value['previous_experience_details'] : 'NA' ).''.$section5_value['started_biz'].'
+ + + + + + + + + + + + + $section6_value) + { + echo ''. + ''. + ''.''; + // ''. + + // ''. + // ''. + + } + + } + + ?> +
Brief of the Business / Service
Product/Service NameContribution Business ProductBusiness Process Brief
'.$section6_value['product_name'] .''.$section6_value['contribution_business_product'].'%'.$section6_value['business_process'].'
'.$section5_value['total_work_exp'].''.( isset ($section5_value['previous_experience_details']) && $section5_value['previous_experience_details'] ? $section5_value['previous_experience_details'] : 'NA' ).''.$section5_value['started_biz'].'
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Employee Strength
No of Employees as per person metNo fo Employees Sighted during the VisitApprox Salary Paid per month (Rs)
Permanent >>Permanent >>Permanent >>
Temporary >>Temporary >>Temporary >>
+ + + + + + + + + + + + + + + + +
Seasonality of the Business
Business Seasonal (Yes / No)If Seasonal Please mention the Lean Months
Reason
+ + + +
Business Assets
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + +
Financial Information
Name of the Company / Firm whose financials are noted
+ + + + $fy_value) + { + // if(is_numeric($fy_key)) + // { + // $totol++; + echo ''; + // } + } + ?> + + + + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + // echo ''; + echo ''; + } + } + ?> + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + + // echo ''; + + if($fy_key == 0) + { + echo ''; + } + else + { + // //echo $pre_year_sales; + // $sales_over_py = round( ((($fy_value['sales_revenue'] - $pre_year_sales) / $pre_year_sales ) * 100),2); + + $sales_over_py = $fy_value['sales_py']; + echo ''; + + } + // $pre_year_sales = $fy_value['sales_revenue']; + } + } + ?> + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + if($fy_key == 0) + { + echo ''; + } + else + { + // $net_profit_over_py = round( ((($fy_value['net_profit'] - $pre_year_net_profit) / $pre_year_net_profit ) * 100),2); + $net_profit_over_py = $fy_value['netprofit_py']; + echo ''; + + } + // $pre_year_net_profit = $fy_value['net_profit']; + } + } + ?> + + + + $fy_value) + { + if(is_numeric($fy_key)) + { + if($fy_key == 0) + { + echo ''; + } + else + { + // $year_net_pro_loss_per_over_py = round( ((( (($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ) - $pre_year_net_pro_loss_per) / $pre_year_net_pro_loss_per ) * 100),2); + + $year_net_pro_loss_per_over_py = $fy_value['netprofit_py_percent']; + echo ''; + // // echo ''; //(($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ) + + } + // $pre_year_net_pro_loss_per = (($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ); + } + } + ?> + +
Particulars of Financials as per books of AccountsFY - '.($fy_value['fy']).'
Sales / Revenue (Rs) '. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($fy_value['sales_revenue'])).'
Net Profit / (Net Loss) (Rs) '.$rupee_symbol.' '. MYUTIL::customIndianNumberFormat($fy_value['net_profit']).'
Net Profit or (Net Loss) to Sales % '.round((($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ),2).'%'.($fy_value['net_profit_sales_percent']).'
% in Sales over PY '.($fy_value['sales_py']).'NA'. ((($sales_over_py == 0 ) ? $dash :( $sales_over_py > 0 ? $uparrow : $downarrow))).'' . abs($sales_over_py). ' %
% in Net Profit over PY NA'. ((($net_profit_over_py == 0 ) ? $dash :( $net_profit_over_py > 0 ? $uparrow : $downarrow))).' ' . abs($net_profit_over_py). '%
% in Net Profit % over PY NA'. ((($year_net_pro_loss_per_over_py == 0 ) ? $dash :( $year_net_pro_loss_per_over_py > 0 ? $uparrow : $downarrow))).' ' . abs($year_net_pro_loss_per_over_py). '% '. (($year_net_pro_loss_per_over_py > 0 )? '' : '').' ( ' . $year_net_pro_loss_per_over_py. ' )
+ +
+ + + + + + + + + + \ No newline at end of file