diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index d650ba59..5ee92000 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -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; diff --git a/api/application/helpers/readexceldata_helper.php b/api/application/helpers/readexceldata_helper.php index c0bd0dce..af34dd91 100644 --- a/api/application/helpers/readexceldata_helper.php +++ b/api/application/helpers/readexceldata_helper.php @@ -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; + } } ?> \ No newline at end of file diff --git a/api/application/models/SMC_Credit_PD_Model.php b/api/application/models/SMC_Credit_PD_Model.php index d7626381..bdf87f3b 100644 --- a/api/application/models/SMC_Credit_PD_Model.php +++ b/api/application/models/SMC_Credit_PD_Model.php @@ -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(); } diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php index ff58113f..0f8b7fe4 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php @@ -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'); + + + + '; + $vendor_form_json = json_decode($pd_processed_forms[25][0]['json'],true); + echo "
$vendor_gen_section_text
"; + + echo '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']."
"; + if(!$vendor_address_section['is_pd_done_on_initiated_address']) + { + echo "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']."
"; + echo "Reason: ".$vendor_address_section['alternative_addresses'][0]['reason_for_alternative_address']."
"; + } + + $locality = preg_match("/^[aeiouAEIOU]/U", $address_content['comment_locality']) ? 'an '.$address_content['comment_locality'] : 'a '.$address_content['comment_locality']; + echo "The Field Visit was done at ".$address_content['address_type']." of the loan applicants. The ".$address_content['address_type']." is located in a ".$address_content['address_locality']." and the estimated area of the ".$address_content['address_type']." is ".$vendor_address_section['estimated_area']." ". $address_content['uom'].". The location was ".$address_content['pd_location_approach'].". As Per Officer, the ".$address_content['address_type']." is situated in $locality Locality.
"; + + echo 'At the time of Field Visit , ".$vendor_business_info['officer_total']." employees sighted at the visited premises.
" : "At the time of Field Visit, no employees sighted at the visited premises.
"; + + echo $name_board = $vendor_business_info['was_the_company_name_board_sighted'] == 'yes' ? "The Business Name board was seen at the visited premises.
" : "The Business Name board was not seen at the visited premises.
"; + + 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 "$doc_names $were sighted during Field Visit and photographs available in zipped file enclosed with report.
"; + } + else + { + echo 'No Documents were sighted during Field Visit.
'; + } + $vendor_business_asset_info = $vendor_form_json['questions'][2]['business_group'][1]; + + echo $vendor_business_asset_info['business_is_pd_visited'] == 'yes' ? 'Business Activity was seen during Field visit
': 'Business Activity was not seen during Field Visit.
'; + + $vendor_stock_info = $vendor_form_json['questions'][2]['business_group'][2]; + + echo $vendor_stock_info['is_stock_photo'] == 'yes' ? 'Stock was observed during Field visit and photographs available in zipped file enclosed with report.
': 'No Stock was observed during Field Visit.
'; + + echo $vendor_business_asset_info['business_asset_sight'] == 'yes' ? 'Business Assets were sighted during Field visit and photographs available in zipped file enclosed with report.
': 'No Business Assets were sighted during Field Visit.
'; + echo "During Field visit, officer clicked office/Name board/Entrance photographs and same is available in + zipped folder attached with report.
"; + + $vendor_credit_manager_info = $vendor_form_json['questions'][6]; + if(count($vendor_credit_manager_info['docs_to_be_sighted'])) + { + echo 'Status of the check: could not verify.
+ + '. $neighbourhood_form_common_remarks.'';} + ?> + + + Submit:'; + $vendoe_final_remars = $vendor_form_json['questions'][5]; + echo 'Final Status of Field Visit:'. $vendoe_final_remars['final_visit_status'] .'
'; + echo 'Remarks:'. $vendoe_final_remars['final_comments'] .'
'; + + echo 'Name of the Officer visited:'.$pd_master_details[0]['vendor_pdofficer_name'].'
'; + echo 'Name of the Agency visited:'.$pd_master_details[0]['agency_name'].'
'; + echo 'Date & Time of visit:'.$pd_master_details[0]['pd_visit_date'].'
'; + // echo '