SMC LOAD EXCEL API DONE

This commit is contained in:
Velz2020 2020-11-06 23:04:41 +05:30
parent 567fc3883f
commit f62d9df583
4 changed files with 281 additions and 29 deletions

View File

@ -807,6 +807,7 @@ class SMC_Credit_PD_Controller extends REST_Controller {
//de active old entries
$is_updated = $this->SMC_Credit_PD_Model->updateRecords(array('isactive' => 0),SMC_CREDIT_PD_SECTION_DATA,array('fk_pd_id' => $records['fk_pd_id'],'fk_form_id' => $records['fk_form_id']));
$records['json'] = json_encode($records['json']);
//make new entry
$new_json_id = $this->SMC_Credit_PD_Model->saveRecords($records,SMC_CREDIT_PD_SECTION_DATA);
@ -1288,22 +1289,26 @@ public function filterSalesPDList_post() {
{
$records = $this->post('records');
$pd_master_data = $this->PD_Model->getPDMasterDetails($records['pd_id'],$records['random_string']);
//print_r($pd_master_data);
// 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 = XLPATH.'/tmp/'.$pd_master_data[0]['modified_fname'];
//echo $filename;
// $filename = XLPATH.'/tmp/mySMCPD_client_working.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]['modified_fname'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+5 minutes');
file_put_contents($filename, $singed_uri);
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+5 minutes');
//echo $singed_uri;
$sucess = file_put_contents($filename, $singed_uri);
//echo '*'.$sucess;
}
// die();
//get exact data
$cur_section_data = readexceldata::getExcelSectionData($filename,$records['form_id'],$records['pd_id']);
$cur_section_data = readexceldata::getExcelSectionData($filename,(isset($records['form_id']) ? $records['form_id'] : null),$records['pd_id']);
if(count($cur_section_data))
{
$data['dataStatus'] = true;

View File

@ -8,15 +8,22 @@ class readexceldata
$CI =&get_instance();
$CI->load->library('myspreadsheet');
// echo $file_path_withname;echo file_exists($file_path_withname); die();
// $file_path_withname = 'C:/xampp/htdocs/ssa_external_data/testing/tmp/mySMCPD.xlsx';
// $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
$spreadsheet_io_fact = $CI->myspreadsheet->getIOFactory($file_path_withname);
//$curr_spreadshett = $spreadsheet_io_fact::load($file_path_withname);
//echo $spreadsheet_io_fact->getSheetCount();
//echo $spreadsheet_io_fact->getSheetCount();
//$spreadsheet_io_fact->setReadDataOnly(true);
$spreadsheet_io_fact->setActiveSheetIndex(0);
$sheetData = $spreadsheet_io_fact->getActiveSheet()->toArray(null, false, false, true);
// print_r($sheetData);
return SELF::seperateSectionData($section_id,$sheetData,$pd_id);
$sheetData = $spreadsheet_io_fact->getActiveSheet()->toArray(null, true, false, true);
//print_r($sheetData);die();
return
SELF::seperateSectionData($section_id,$sheetData,$pd_id);
// print_r(SELF::seperateSectionData($section_id,$sheetData,$pd_id));die();
// $CI->load->model('PD_Model');
//return ( $CI->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name'),array('fk_pd_id' => $pd_id),PDAPPLICANTSDETAILS));
@ -46,14 +53,14 @@ class readexceldata
{
$pd_address = $CI->PD_Model->getPDAddress($pd_id);
if(count($pd_address)){ $return_data[] = array('key_name' => 'initiated_address','value' => $pd_address[0]['addressline1'].', '.$pd_address[0]['city_name'].', '.$pd_address[0]['state_name'].' - '.$pd_address[0]['pincode'] ); }
if(count($pd_address)){ $return_data['initiated_address'] = $pd_address[0]['addressline1'].', '.$pd_address[0]['city_name'].', '.$pd_address[0]['state_name'].' - '.$pd_address[0]['pincode']; }
}
if($section_id == 3) //get sub product as custom func tion
{
$pd_master = $CI->PD_Model->getPDMasterDetails($pd_id);
if(count($pd_master)){ $return_data[] = array('key_name' => 'sub_product','value' => $pd_master[0]['fk_subproduct_id']); }
if(count($pd_master)){ $return_data['sub_product'] = $pd_master[0]['fk_subproduct_id']; }
}
break;
@ -71,18 +78,37 @@ class readexceldata
{
//$start_letter = 'B';$i = 1;
$return_data = array();
$keys = array();
foreach ($sheetData as $key => $value)
{
$tmp = SELF::returnMatchedData($section_ref_data,$value);
if($tmp)
// print_r($value);
// die();
$tmp = SELF::returnMatchedData($section_ref_data,$value);//print_r($tmp);
if(is_array($tmp))
{
$temp['key_name'] = $tmp;
$temp['value'] = $value['C'];
$return_data[] = $temp;
if(isset($tmp['parent_key']))
{
$trimedData = SELF::trimExcelEmptyCells($value);
$temp[$tmp['parent_key']][$tmp['key_name']] = SELF::getMultipleCellValues($trimedData,$tmp['key_name']);
$keys[$tmp['parent_key']][] = $tmp['key_name'];
$return_data = $temp;
}
else
{
$temp[$tmp['key_name']] = $value['C'];
$return_data = $temp;
}
}
}
// print_r($keys);
// print_r($return_data);die();
$return_data = SELF::transformRowColumsForMultipleData($return_data,$keys);
// print_r($return_data);
// die();
return ($return_data);
}
static function getTriggerData($sheetData,$section_ref_data)
{
@ -92,11 +118,11 @@ class readexceldata
{
// print_r($value['C']);die();
$tmp = SELF::returnMatchedData($section_ref_data,$value);
if($tmp)
if(is_array($tmp) && isset($tmp['key_name']))
{
$temp['key_name'] = $tmp;
$temp['value'] = $value['C'];
$return_data[] = $temp;
$temp[$tmp['key_name']] = $value['C'];
//$temp['value'] = $value['C'];
$return_data = $temp;
}
if($key == 8)
{
@ -116,9 +142,13 @@ class readexceldata
{
foreach ($arr as $key => $value)
{
if($val['A'] == $value['ref'])
if(!$value['parent_key'] && ($val['A'] == $value['ref']))
{
return $value['key_name'];
return array('key_name' => $value['key_name']);
}
else if($value['parent_key'] && ($val['A'] == $value['ref']))
{
return array('key_name' => $value['key_name'],'parent_key' => $value['parent_key']);
}
}
}
@ -132,6 +162,64 @@ class readexceldata
return $type == 1 ? $value['applicant_name'] : ($type == 2 ? $value['title'] : ($value['title'].' '.$value['applicant_name']));
}
}
}
}
static function trimExcelEmptyCells($arr)
{
$return_data = array();
foreach ($arr as $key => $value)
{
if($value)
{
$return_data[$key] = $value;
}
}
return $return_data;
}
static function getMultipleCellValues($trimedData,$key_name)
{
$return_data = array();
foreach ($trimedData as $key => $value)
{
if($key != 'A' && $key != 'B')
{
// $return_data[] = array($key_name => $value);
$return_data[] = $value;
}
}
return $return_data;
}
static function transformRowColumsForMultipleData($return_data,$keys)
{
$final_data = array();
// print_r($return_data);
// print_r($keys);die();
foreach ($keys as $current_key => $arr)
{
if(array_key_exists($current_key, $return_data))
{
$data_to_be_transform = $return_data[$current_key];
// print_r($data_to_be_transform);
$total_no_of_fields = count($data_to_be_transform);
$total_no_of_data = count( (reset($data_to_be_transform)) );
// echo $total_no_of_fields.'-'.$total_no_of_data;die();
$temp = array();
for($i = 0;$i<$total_no_of_fields;$i++)
{
for($j=0;$j<$total_no_of_data;$j++)
{
$temp[$j][ $arr[$i] ] = isset($data_to_be_transform[ $arr[$i] ][$j]) ? $data_to_be_transform[ $arr[$i] ][$j] : 'DNA';
}
}
$return_data[$current_key] = $temp;
}
}
return $return_data;
}
}
?>

View File

@ -58,12 +58,14 @@ class SMC_Credit_PD_Model extends SPARQ_Model {
// $master_forms = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('isactive' => 1),SMC_CREDIT_PD_FORMS);
// print_r($master_forms);
$table = SMC_CREDIT_PD_FORMS.' as SMC_CREDIT_PD_FORMS';
$fields = array('SMC_CREDIT_PD_FORMS.form_name','SMC_CREDIT_PD_FORMS.form_id as fk_form_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');
$fields = array('SMC_CREDIT_PD_FORMS.form_name','SMC_CREDIT_PD_FORMS.form_id as fk_form_id','SMC_CREDIT_PD_SECTION_DATA.fk_pd_id','if(SMC_CREDIT_PD_SECTION_DATA.json is not null,true,false) as is_answered');
$joins = array(
array('table'=>SMC_CREDIT_PD_SECTION_DATA." as SMC_CREDIT_PD_SECTION_DATA",'condition'=>"SMC_CREDIT_PD_SECTION_DATA.fk_form_id = SMC_CREDIT_PD_FORMS.form_id AND SMC_CREDIT_PD_SECTION_DATA.fk_pd_id = $pd_id and SMC_CREDIT_PD_SECTION_DATA.fk_form_id = $pd_id and SMC_CREDIT_PD_SECTION_DATA.isactive = $pd_id" ,'jointype'=>'LEFT')
array('table'=>SMC_CREDIT_PD_SECTION_DATA." as SMC_CREDIT_PD_SECTION_DATA",'condition'=>"SMC_CREDIT_PD_SECTION_DATA.fk_form_id = SMC_CREDIT_PD_FORMS.form_id AND SMC_CREDIT_PD_SECTION_DATA.fk_pd_id = $pd_id and SMC_CREDIT_PD_SECTION_DATA.isactive = 1 " ,'jointype'=>'LEFT')
);
$where_condition_array = array('SMC_CREDIT_PD_FORMS.isactive' => 1);
return $master_forms = $this->getJoinRecords($fields,$table,$joins,$where_condition_array);
return
$master_forms = $this->getJoinRecords($fields,$table,$joins,$where_condition_array,'SMC_CREDIT_PD_FORMS.form_id','ASC');
print_r($this->db->last_query());die();
}

View File

@ -423,6 +423,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
/* #########Doc sighted gallary css######### */
/*Vendor Section Bold Text Display*/
.vsbtd{
font-size: 14px;
font-weight: bolder;;
}
/* ######### TOOLTIP CSS START ######### */
.tooltip {
@ -4702,6 +4708,157 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<!-- #################END of Annexure B(RI) section start#################-->
<!-- ######################### VENDOR SECTION START ###########################-->
<!-- ######################### VENDOR SECTION START ###########################-->
<?php
echo '<div id="page_break"></div>';
$vendor_form_json = json_decode($pd_processed_forms[25][0]['json'],true);
echo "<h2><center> Field Visit Report of $main_applicant_name</center></h2>";
echo '<h2>General Section</h2>';
$vendor_gen_section_text = vendor_form::getVendorGeneralSectionContent($vendor_form_json['questions'][0]);
echo "<p style='text-align:justify;'>$vendor_gen_section_text</p>";
echo '<h2>Address Section</h2>';
$vendor_address_section = $vendor_form_json['questions'][1];
$address_content = vendor_form::getVendoraddressSectionContent($vendor_address_section);
echo "<p>Field Visit Initiated Address: ".$vendor_address_section['address'].", ". $address_content['initiated_address']['city_name'] .", ".$address_content['initiated_address']['state_name']." - ".$address_content['initiated_address']['pincode']." </p>";
if(!$vendor_address_section['is_pd_done_on_initiated_address'])
{
echo "<p>Field Visit Actual Visited Address: ".$vendor_address_section['alternative_addresses'][0]['alternative_address'].", ". $address_content['actual_address']['city_name'] .", ".$address_content['actual_address']['state_name']." - ".$address_content['actual_address']['pincode']." </p>";
echo "<p>Reason: ".$vendor_address_section['alternative_addresses'][0]['reason_for_alternative_address']."</p>";
}
$locality = preg_match("/^[aeiouAEIOU]/U", $address_content['comment_locality']) ? 'an '.$address_content['comment_locality'] : 'a '.$address_content['comment_locality'];
echo "<p style='text-align:justify;'>The Field Visit was done at <span class='vsbtd'>".$address_content['address_type']."</span> of the loan applicants. The ".$address_content['address_type']." is located in a <span class='vsbtd'>".$address_content['address_locality']."</span> and the estimated area of the <span class='vsbtd'>".$address_content['address_type']."</span> is <span class='vsbtd'>".$vendor_address_section['estimated_area']." ". $address_content['uom']."</span>. The location was <span class='vsbtd'>".$address_content['pd_location_approach']."</span>. As Per Officer, the ".$address_content['address_type']." is situated in <span class='vsbtd'>$locality Locality</span>.</p>";
echo '<h2>Business information</h2>';
$vendor_business_info = $vendor_form_json['questions'][2]['business_group'][0];
echo $emp = $vendor_business_info['officer_total'] > 0 ? "<p>At the time of Field Visit , <span class='vsbtd'>".$vendor_business_info['officer_total']." </span>employees sighted at the visited premises.</p>" : "<p>At the time of Field Visit, no employees sighted at the visited premises.</p>";
echo $name_board = $vendor_business_info['was_the_company_name_board_sighted'] == 'yes' ? "<p>The Business <span class='vsbtd'>Name board was seen</span> at the visited premises.</p>" : "<p>The Business <span class='vsbtd'>Name board was not seen</span> at the visited premises.</p>";
if(($vendor_business_info['documents_sighted'] == 'yes'))
{
$doc_names = '';
$photo_names = array('rent_agreement' => 'Rent Agreement','eb_bill' => 'EB Bill','factory_cert' => 'Factory Certificate','export_import_cert' => 'Export/Import Certificate','esic_regn' => 'ESIC Registration','pf_regn' => 'PF Registration','gst_Regn_cert' => 'GST Registration','shop_eat_act_cert' => 'Shop/Est act Certificate','practice_cert' => 'Practice Certificate');
foreach ($vendor_business_info['documents_info'] as $doc_key => $doc_value)
{
$doc_names .= $photo_names [ $doc_value['document_name'] ].', ';
}
$were = count($vendor_business_info['documents_info']) == 1 ? 'was' : 'were';
$doc_names = substr_replace($doc_names,' ',-2);
echo "<p style='text-align:justify;'>$doc_names $were sighted during Field Visit and photographs available in zipped file enclosed with report.</p>";
}
else
{
echo '<p>No Documents were sighted during Field Visit.</p>';
}
$vendor_business_asset_info = $vendor_form_json['questions'][2]['business_group'][1];
echo $vendor_business_asset_info['business_is_pd_visited'] == 'yes' ? '<p><span class="vsbtd">Business Activity was seen</span> during Field visit</p>': '<p><span class="vsbtd">Business Activity was not seen</span> during Field Visit.</p>';
$vendor_stock_info = $vendor_form_json['questions'][2]['business_group'][2];
echo $vendor_stock_info['is_stock_photo'] == 'yes' ? '<p><span class="vsbtd">Stock was observed</span> during Field visit and photographs available in zipped file enclosed with report.</p>': '<p>No Stock was observed during Field Visit.</p>';
echo $vendor_business_asset_info['business_asset_sight'] == 'yes' ? '<p>Business Assets were sighted during Field visit and photographs available in zipped file enclosed with report.</p>': '<p>No Business Assets were sighted during Field Visit.</p>';
echo "<p>During Field visit, officer clicked office/Name board/Entrance photographs and same is available in
zipped folder attached with report.</p>";
$vendor_credit_manager_info = $vendor_form_json['questions'][6];
if(count($vendor_credit_manager_info['docs_to_be_sighted']))
{
echo '<h2>Credit Manager Special Requests:</h2></br>';
foreach ($vendor_credit_manager_info['docs_to_be_sighted'] as $cm_key => $cm_value)
{
echo '<span class="vsbtd">Document Required:</span>'.$cm_value['placeholder'].'<br>';
echo '<span class="vsbtd">Provided (Yes / No):</span>'.ucfirst($cm_value[ $cm_value['control_name'] ] );
echo isset($cm_value['reason']) ? '<br><span class="vsbtd">Reason:</span>'.$cm_value['reason'] : '';
}
}
echo '<h2>Neighbourhood Check Details</h2></br>';
$vendor_neighbour = $vendor_form_json['questions'][3];
$existNeighRefCheck=array();
$pd_offiecer_status_about_neighbor = "";
$neighbourhood_form_common_remarks = $vendor_neighbour['neighbour_reference_remark'];
if(strcasecmp($vendor_neighbour['neighbourhood_status'],'could not verify')){
$pd_offiecer_status_about_neighbor = $vendor_neighbour['neighbourhood_status'];
if(count($vendor_neighbour['neighbourhood_list'])>0){
$company_name = MYUTIL::findCompanyName($all_company_details,1,1);
$existNeighRefCheck=NEIGHBOURREFERENCECHECKFORM::getNeighbourhoodDetails($company_name,$vendor_neighbour['neighbourhood_list'],$pd_master_details[0],$applicants_details);//applicants_details comes from controller
}
}
// if(&& count($neighbourRefRow['referencecheck_list'])>0){
// $existNeighRefCheck=NEIGHBOURREFERENCECHECKFORM::getReferenceDetails($neighbourRefRow['referencecheck_list'],$pd_master_details[0]);
// }
?>
<?php
//echo $pd_offiecer_status_about_neighbor;
if(count($existNeighRefCheck)>0){
//print_r($existNeighRefCheck);die();
?>
<?php foreach($existNeighRefCheck as $nkey => $nfValue) {
echo $nfValue['neighbourhood_name_only'];
?>
<ul>
<li style="margin: 15px 0;"><?php echo $nfValue['neighbourhood_name']; ?></li>
<li style="margin: 15px 0;"><?php echo $nfValue['neighbourhood_do_know']; ?></li>
<li style="margin: 15px 0;"><?php echo $nfValue['neighbourhood_business_running_yr']; ?></li>
<li style="margin: 15px 0;"><?php echo $nfValue['ownership']; ?></li>
</ul>
<?php }?>
<li style="margin: 15px 0;"> Neighbourhood Check Status is <span style="font-size:16px;font-weight:bold;"><?php echo $pd_offiecer_status_about_neighbor;?>.</span></li>
</li>
<?php
}
else{?>
<!-- <p>Status of check: Could Not Verify. <br>Neighbour Check was not possible due to Could not verify</p> -->
<!-- <p>Neighbour Check was not possible due to Could not verify</p> -->
<p>Status of the check: could not verify.</p>
<?php
}
if($neighbourhood_form_common_remarks != ""){ echo '<p>'. $neighbourhood_form_common_remarks.'</p>';}
?>
<!-- #################end neighbourhood/reference check #################-->
<?php
// echo '<h3>Submit:</h3>';
$vendoe_final_remars = $vendor_form_json['questions'][5];
echo '<p><span class="vsbtd">Final Status of Field Visit:'. $vendoe_final_remars['final_visit_status'] .'</span></p>';
echo '<p><span class="vsbtd">Remarks:</span>'. $vendoe_final_remars['final_comments'] .'</p>';
echo '<br><br><br>';
echo '<p><span class="vsbtd">Name of the Officer visited:</span>'.$pd_master_details[0]['vendor_pdofficer_name'].'</p>';
echo '<p><span class="vsbtd">Name of the Agency visited:</span>'.$pd_master_details[0]['agency_name'].'</p>';
echo '<p><span class="vsbtd">Date & Time of visit:</span>'.$pd_master_details[0]['pd_visit_date'].'</p>';
// echo '<div><img style="width:100px;height:50px;opacity: 0.5;" src="https://apitest.pdgenie.com/sparqtest/api/vs.jpg"/></div>';
?>
<!-- ######################### VENDOR SECTION END ###########################-->
<!-- ######################### VENDOR SECTION END ###########################-->
<?php
// ########################### End disclaimer start #########################################
$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer,2);