SMC EXCEL TO REPORT DATA FETCH
This commit is contained in:
parent
dac7783b3e
commit
699acfeedf
@ -1307,28 +1307,12 @@ public function filterSalesPDList_post() {
|
||||
{
|
||||
$records = $this->post('records');
|
||||
$pd_master_data = $this->PD_Model->getPDMasterDetails($records['pd_id'],$records['random_string']);
|
||||
$cur_section_data = array();
|
||||
// $cur_section_data = array();
|
||||
$cur_section_data = $this->loadDataFromExcelBusiProcess($pd_master_data,(isset($records['form_id']) && $records['form_id'] ? $records['form_id'] : null));
|
||||
// print_r($pd_master_data);die();
|
||||
// echo $records['form_id'];die();
|
||||
//check excel file in local, otherwise get it from s3 and store locallly
|
||||
$filename = ($pd_master_data[0]['re_uploaded'] ? XLPATH.'/tmp/'.$pd_master_data[0]['re_uploaded_file_name'] : XLPATH.'/tmp/'.$pd_master_data[0]['modified_fname']);
|
||||
|
||||
// $filename = XLPATH.'/tmp/mySMCPD_client_working.xlsx';
|
||||
// $filename = 'C:\Users\Venba\Downloads\Kathir Info Pvt.xlsx';
|
||||
// echo $filename;die();
|
||||
if(!file_exists($filename))
|
||||
{
|
||||
|
||||
//echo 'getting it from s3';
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_data[0]['fk_lender_id'];
|
||||
$key = 'tmp/'. ($pd_master_data[0]['re_uploaded'] ? $pd_master_data[0]['re_uploaded_file_name'] : $pd_master_data[0]['modified_fname']);
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+5 minutes');
|
||||
//echo $singed_uri;
|
||||
$sucess = file_put_contents($filename, file_get_contents($singed_uri));
|
||||
|
||||
//echo '*'.$sucess;
|
||||
}
|
||||
$cur_section_data = readexceldata::getExcelSectionData($filename,(isset($records['form_id']) && $records['form_id'] ? $records['form_id'] : null),$records['pd_id']);
|
||||
|
||||
|
||||
|
||||
if(count($cur_section_data))
|
||||
@ -1349,6 +1333,29 @@ public function filterSalesPDList_post() {
|
||||
}
|
||||
|
||||
|
||||
function loadDataFromExcelBusiProcess($pd_master_data,$form_id)
|
||||
{
|
||||
$filename = ($pd_master_data[0]['re_uploaded'] ? XLPATH.'/tmp/'.$pd_master_data[0]['re_uploaded_file_name'] : XLPATH.'/tmp/'.$pd_master_data[0]['modified_fname']);
|
||||
|
||||
// $filename = XLPATH.'/tmp/mySMCPD_client_working.xlsx';
|
||||
// $filename = 'C:\Users\Venba\Downloads\Kathir Info Pvt.xlsx';
|
||||
// echo $filename;die();
|
||||
if(!file_exists($filename))
|
||||
{
|
||||
|
||||
//echo 'getting it from s3';
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_data[0]['fk_lender_id'];
|
||||
$key = 'tmp/'. ($pd_master_data[0]['re_uploaded'] ? $pd_master_data[0]['re_uploaded_file_name'] : $pd_master_data[0]['modified_fname']);
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+5 minutes');
|
||||
//echo $singed_uri;
|
||||
$sucess = file_put_contents($filename, file_get_contents($singed_uri));
|
||||
|
||||
//echo '*'.$sucess;
|
||||
}
|
||||
return $cur_section_data = readexceldata::getExcelSectionData($filename,$form_id,$pd_master_data[0]['pd_id']);
|
||||
}
|
||||
|
||||
|
||||
public function getSMCPDImgSectionData_post()
|
||||
{
|
||||
$rand_string = $this->post('rand_string');
|
||||
@ -1461,20 +1468,37 @@ public function filterSalesPDList_post() {
|
||||
|
||||
$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');
|
||||
//$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');
|
||||
$pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($records['pd_id'],$view_data['pd_master_details'][0]['fk_product_id'],null,null,'REPORT');
|
||||
// print_r ($view_data['pd_master_details']);die();
|
||||
// print_r($pd_section_data[12]);die();
|
||||
// print_r($pd_section_data);die();
|
||||
$forms_data_to_be_get_direct_from_excel_sheet = array(3,9,10,15);
|
||||
if(count($pd_section_data))
|
||||
{
|
||||
foreach ($pd_section_data as $key => $value)
|
||||
{
|
||||
|
||||
if(isset($value['json']) && $value['json'] != '')
|
||||
{
|
||||
$value['json'] = smc_creditpd::getSMCCreditPDReportContent($value,$records['pd_id']);
|
||||
// if($value['fk_form_id'] == 2){print_r($value['json']);die();}
|
||||
$view_data['pd_section_data'][$value['fk_form_id']] = $value['json'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(in_array($value['fk_form_id'],$forms_data_to_be_get_direct_from_excel_sheet))
|
||||
{
|
||||
$data_from_excel = $this->loadDataFromExcelBusiProcess($view_data['pd_master_details'],$value['fk_form_id']);
|
||||
//print_r($data_from_excel);die();
|
||||
$view_data['pd_section_data'][$value['fk_form_id']] = $data_from_excel;
|
||||
|
||||
}
|
||||
}
|
||||
//die();
|
||||
}
|
||||
}
|
||||
// print_r($view_data['pd_section_data'][1]);die();
|
||||
// print_r($view_data['pd_section_data'][15]);die();
|
||||
$view_data['smc_images'] = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $records['pd_id'],'isactive' => 1,'img_name!=' => 'satellite'),SMC_CREDIT_PD_DOCS);
|
||||
$view_data['satellite'] = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $records['pd_id'],'isactive' => 1,'img_name=' => 'satellite'),SMC_CREDIT_PD_DOCS);
|
||||
//print_r(count($view_data['smc_images']));die();
|
||||
@ -1513,7 +1537,7 @@ public function filterSalesPDList_post() {
|
||||
// die();
|
||||
//score card part
|
||||
$html_content = $this->load->view('smc_creditpd_reports/MWISE',$view_data,true);
|
||||
// echo $html_content;die();
|
||||
//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
|
||||
|
||||
@ -172,7 +172,33 @@ class readexceldata
|
||||
$return_data = SELF::transformRowColumsForMultipleData($return_data,$keys);
|
||||
if(SELF::$current_section_id == 10)
|
||||
{
|
||||
$return_data['financial_info'] = array_reverse($return_data['financial_info']);
|
||||
|
||||
//implement financial calculations
|
||||
$pre_yr_fin_data = array();
|
||||
if(isset($return_data['financial_info']) && count($return_data['financial_info']) >= 1)
|
||||
{
|
||||
$return_data['financial_info'] = array_reverse($return_data['financial_info']);
|
||||
$return_data['financial_info_available'] = 'yes';
|
||||
|
||||
foreach ($return_data['financial_info'] as $fy_key => $fy_value)
|
||||
{
|
||||
|
||||
$net_profit_sales_percent = (isset($fy_value['sales_revenue']) && is_numeric($fy_value['sales_revenue']) && isset($fy_value['net_profit']) && is_numeric($fy_value['net_profit']) ? (($fy_value['net_profit'] / $fy_value['sales_revenue']) * 100): 0.00);
|
||||
$return_data['financial_info'][$fy_key]['net_profit_sales_percent'] = number_format($net_profit_sales_percent,2,'.','');
|
||||
|
||||
$return_data['financial_info'][$fy_key]['sales_py'] = ($fy_key == 0 ? 'NA' : number_format ((($fy_value['sales_revenue'] - $pre_yr_fin_data['sales_revenue']) / $pre_yr_fin_data['sales_revenue']),2,'.',''));
|
||||
|
||||
$return_data['financial_info'][$fy_key]['netprofit_py'] = ($fy_key == 0 ? 'NA' : number_format ((($fy_value['net_profit'] - $pre_yr_fin_data['net_profit']) / $pre_yr_fin_data['net_profit'] ),2,'.',''));
|
||||
|
||||
$return_data['financial_info'][$fy_key]['netprofit_py_percent'] = ($fy_key == 0 ? 'NA' : number_format((($net_profit_sales_percent - $pre_yr_fin_data['net_profit_sales_percent']) / $pre_yr_fin_data['net_profit_sales_percent']),2,'.',''));
|
||||
|
||||
|
||||
$pre_yr_fin_data = $fy_value;
|
||||
$pre_yr_fin_data['net_profit_sales_percent'] = $net_profit_sales_percent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$return_data['broken_period_turnover_percent'] = SELF::getNumFormat($return_data['broken_period_turnover_percent'],'per');
|
||||
// $return_data['net_profit_to_sales_percent'] = SELF::getNumFormat($return_data['net_profit_to_sales_percent'],'per');
|
||||
|
||||
@ -61,6 +61,10 @@ class SMC_Credit_PD_Model extends SPARQ_Model {
|
||||
$table = CREDITPDTEMPLATE.' as CREDITPDTEMPLATE';
|
||||
// $table = SMC_CREDIT_PD_FORMS.' as SMC_CREDIT_PD_FORMS';
|
||||
$fields = array('SMC_CREDIT_PD_FORMS.form_name','CREDITPDTEMPLATE.pd_form_id as fk_form_id','CREDITPDTEMPLATE.fk_product_id','SMC_CREDIT_PD_SECTION_DATA.fk_pd_id','if(SMC_CREDIT_PD_SECTION_DATA.json is not null,true,false) as is_answered','SMC_CREDIT_PD_SECTION_DATA.is_reupload_data_fetched','SMC_CREDIT_PD_FORMS.complete_check_enabled');
|
||||
if($api == 'REPORT')
|
||||
{
|
||||
$fields = array('SMC_CREDIT_PD_FORMS.form_name','CREDITPDTEMPLATE.pd_form_id as fk_form_id','CREDITPDTEMPLATE.fk_product_id','SMC_CREDIT_PD_SECTION_DATA.fk_pd_id','SMC_CREDIT_PD_SECTION_DATA.json','if(SMC_CREDIT_PD_SECTION_DATA.json is not null,true,false) as is_answered','SMC_CREDIT_PD_SECTION_DATA.is_reupload_data_fetched','SMC_CREDIT_PD_FORMS.complete_check_enabled');
|
||||
}
|
||||
$joins = array(
|
||||
array('table'=>SMC_CREDIT_PD_SECTION_DATA." as SMC_CREDIT_PD_SECTION_DATA",'condition'=>"SMC_CREDIT_PD_SECTION_DATA.fk_form_id = CREDITPDTEMPLATE.pd_form_id AND CREDITPDTEMPLATE.fk_product_id = $product_id AND SMC_CREDIT_PD_SECTION_DATA.fk_pd_id = $pd_id and SMC_CREDIT_PD_SECTION_DATA.isactive = 1 " ,'jointype'=>'LEFT'),
|
||||
array('table'=>SMC_CREDIT_PD_FORMS." as SMC_CREDIT_PD_FORMS",'condition'=>"CREDITPDTEMPLATE.pd_form_id = SMC_CREDIT_PD_FORMS.form_id" ,'jointype'=>'INNER JOIN')
|
||||
|
||||
@ -1013,9 +1013,9 @@ $business_pd_visited_remark = (isset($pd_section_data[8]['business_pd_visited_re
|
||||
</table>
|
||||
<table class="scorecard_table">
|
||||
<tbody>
|
||||
<?php echo '<tr> <td>Sales / Revenue ('.$rupee_symbol.') </td><td class="tdcenteralign">'.$rupee_symbol.' '. MYUTIL::customIndianNumberFormat($pd_section_data[10]['sales_amount']) .'</td> </tr>'?>
|
||||
<?php echo '<tr> <td>Net Profit or (Net Loss) to Sales % </td><td class="tdcenteralign">'. ( $pd_section_data[10]['net_profit_to_sales_percent'] != ''? $pd_section_data[10]['net_profit_to_sales_percent'] : '-').'</td> </tr>'?>
|
||||
<?php echo '<tr> <td>Net Profit / (Net Loss) ('.$rupee_symbol.') </td><td class="tdcenteralign">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($pd_section_data[10]['net_profit_rs']) .'</td> </tr>'?>
|
||||
<?php echo '<tr> <td>Sales / Revenue ('.$rupee_symbol.') </td><td class="tdcenteralign">'.(isset($pd_section_data[10]['sales_amount']) && $pd_section_data[10]['sales_amount'] != '' ? $rupee_symbol.' '. MYUTIL::customIndianNumberFormat($pd_section_data[10]['sales_amount']) : '-') .'</td> </tr>'?>
|
||||
<?php echo '<tr> <td>Net Profit or (Net Loss) to Sales % </td><td class="tdcenteralign">'. ( isset($pd_section_data[10]['net_profit_to_sales_percent']) && $pd_section_data[10]['net_profit_to_sales_percent'] != ''? $pd_section_data[10]['net_profit_to_sales_percent'] : '-').'</td> </tr>'?>
|
||||
<?php echo '<tr> <td>Net Profit / (Net Loss) ('.$rupee_symbol.') </td><td class="tdcenteralign">'.(isset($pd_section_data[10]['net_profit_rs']) && $pd_section_data[10]['net_profit_rs'] != '' ? $rupee_symbol.' '.MYUTIL::customIndianNumberFormat($pd_section_data[10]['net_profit_rs']) : '-') .'</td> </tr>'?>
|
||||
|
||||
</tbody>
|
||||
</table><br>
|
||||
@ -1025,8 +1025,8 @@ $business_pd_visited_remark = (isset($pd_section_data[8]['business_pd_visited_re
|
||||
</table>
|
||||
<table class="scorecard_table">
|
||||
<tbody>
|
||||
<?php echo '<tr> <td class="tdcenteralign" colspan="2">Debtor Days</td> <td colspan="2" class="tdcenteralign"</td>'.$pd_section_data[10]['debtor_days_cm'].'<td colspan="2" class="tdcenteralign">Creditor Days</td> <td colspan="2" class="tdcenteralign">'.$pd_section_data[10]['creditor_days_cm'].'</td> <td colspan="2" class="tdcenteralign">Stock Days</td> <td colspan="2" class="tdcenteralign">'.$pd_section_data[10]['inventory_days_cm'].'</td> </tr>'?>
|
||||
<?php echo '<tr> <td colspan="8" class="tdcenteralign">Does the business have any working capital facility from any lender other than Moneywise? (Yes / No)</td> <td colspan="4" class="tdcenteralign">'.$pd_section_data[10]['is_any_other_working_captial_facility'].'</td></tr>'?>
|
||||
<?php echo '<tr> <td class="tdcenteralign" colspan="2">Debtor Days</td> <td colspan="2" class="tdcenteralign"</td>'.(isset($pd_section_data[10]['debtor_days_cm']) ? $pd_section_data[10]['debtor_days_cm'] : '-').'<td colspan="2" class="tdcenteralign">Creditor Days</td> <td colspan="2" class="tdcenteralign">'.( isset($pd_section_data[10]['creditor_days_cm']) ? $pd_section_data[10]['creditor_days_cm'] : '-').'</td> <td colspan="2" class="tdcenteralign">Stock Days</td> <td colspan="2" class="tdcenteralign">'.(isset($pd_section_data[10]['inventory_days_cm']) ? $pd_section_data[10]['inventory_days_cm'] : '-').'</td> </tr>'?>
|
||||
<?php echo '<tr> <td colspan="8" class="tdcenteralign">Does the business have any working capital facility from any lender other than Moneywise? (Yes / No)</td> <td colspan="4" class="tdcenteralign">'.(isset($pd_section_data[10]['is_any_other_working_captial_facility']) ? $pd_section_data[10]['is_any_other_working_captial_facility'] : '-').'</td></tr>'?>
|
||||
<?php
|
||||
if(isset($pd_section_data[10]['facility_details_specify']))
|
||||
{
|
||||
@ -1297,7 +1297,7 @@ Business run by the applicant</td><td colspan="4"><?php echo $pd_section_data[1
|
||||
<tr>
|
||||
<th colspan="10">Existing Loan Obligations</th>
|
||||
</tr>
|
||||
<?php if(isset($pd_section_data[15]['existing_loan_details']) && count($pd_section_data[15]['existing_loan_details']) && ($pd_section_data[15]['existing_loan_details'][0]['loan_type'] != '' && $pd_section_data[15]['existing_loan_details'][0]['lender_name'] != '' && $pd_section_data[15]['existing_loan_details'][0]['loan_amount'] != '')){?>
|
||||
<?php if(isset($pd_section_data[15]['existing_loan_details']) && count($pd_section_data[15]['existing_loan_details']) && ($pd_section_data[15]['existing_loan_details'][0]['loan_type'] != '' && $pd_section_data[15]['existing_loan_details'][0]['loan_amount'] != '')){?>
|
||||
<tr>
|
||||
<th colspan="1">Sr. No.</th>
|
||||
<th colspan="1">Loan<br>Type</th>
|
||||
@ -1316,7 +1316,7 @@ Business run by the applicant</td><td colspan="4"><?php echo $pd_section_data[1
|
||||
<?php
|
||||
foreach ($pd_section_data[15]['existing_loan_details'] as $key15 => $value15)
|
||||
{
|
||||
echo '<tr><td class="tdcenteralign">'. ($key15 + 1) .'</td><td>'. $value15['loan_type'] .'</td><td>'.$rupee_symbol.MYUTIL::customIndianNumberFormat($value15['loan_amount']).'</td><td>'.$value15['lender_name'].'</td><td>'.$value15['loan_taken_by'].'</td><td class="tdcenteralign">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($value15['instalment_amount']).'</td><td class="tdcenteralign">'.$value15['instalment_frequency'].'</td><td class="tdcenteralign">'.($value15['original_tenure_months'] != '' ? $value15['original_tenure_months'] : 'NA').'</td><td class="tdcenteralign">'.($value15['current_tenure_months'] != '' ? $value15['current_tenure_months'] : 'NA').'</td><td class="tdcenteralign">'.($value15['elapsed_tenure_months'] != '' ? $value15['elapsed_tenure_months'] : 'NA') .'</td></tr>';
|
||||
echo '<tr><td class="tdcenteralign">'. ($key15 + 1) .'</td><td>'. $value15['loan_type'] .'</td><td>'.$rupee_symbol.MYUTIL::customIndianNumberFormat($value15['loan_amount']).'</td><td class="tdcenteralign">'.($value15['lender_name'] != '' ? $value15['lender_name'] : 'NA').'</td><td>'.$value15['loan_taken_by'].'</td><td class="tdcenteralign">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($value15['instalment_amount']).'</td><td class="tdcenteralign">'.$value15['instalment_frequency'].'</td><td class="tdcenteralign">'.($value15['original_tenure_months'] != '' ? $value15['original_tenure_months'] : 'NA').'</td><td class="tdcenteralign">'.($value15['current_tenure_months'] != '' ? $value15['current_tenure_months'] : 'NA').'</td><td class="tdcenteralign">'.($value15['elapsed_tenure_months'] != '' ? $value15['elapsed_tenure_months'] : 'NA') .'</td></tr>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user