upload Credit PD Data To CET App api : ps

This commit is contained in:
VE10-Sanjeev 2022-09-01 22:56:32 +05:30
parent ac4f101ffd
commit cc7ac5ff04
2 changed files with 144 additions and 45 deletions

View File

@ -372,6 +372,7 @@ $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only deve
$route['uploadSalesPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp';
$route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp';
$route['uploadCreditPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadCreditPDDataToCETApp';
$route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp';
$route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox';

View File

@ -267,6 +267,149 @@ class SMC_Credit_PD_Controller extends REST_Controller {
}
function uploadCreditPDDataToCETApp_get()
{
log_message('ERROR', '#### upload SMC Credit PDData To CETApp Called');
$smc_credit_pd = $this->uri->segment(2);
if (!empty($smc_credit_pd)) {
log_message('ERROR', '#### SMC Credit PD = ' . $smc_credit_pd);
$columns = array('SMC_CREDIT_PD.*', 'ENTITY.short_name', 'PRODUCT.abbr');
$table = SMC_CREDIT_PD . ' as SMC_CREDIT_PD';
$joins = array(
array(
'table' => ENTITY . ' as ENTITY',
'condition' => 'SMC_CREDIT_PD.lender_id = ENTITY.entity_id',
'jointype' => 'INNER'
),
array(
'table' => PRODUCTS . ' as PRODUCT',
'condition' => 'SMC_CREDIT_PD.product_id = PRODUCT.product_id',
'jointype' => 'INNER'
)
);
$where_condition_array = array('SMC_CREDIT_PD.smc_credit_pd' => $smc_credit_pd);
$SMC_CREDIT_PD = $this->SMC_Credit_PD_Model->getJoinRecords($columns, $table, $joins, $where_condition_array);
log_message('ERROR', '#### Total Credit PD is ' . count($SMC_CREDIT_PD));
$mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd);
$forms_data_to_be_get_direct_from_excel_sheet = array(3, 9, 10, 15);
// print_r($SMC_CREDIT_PD);die();
if (count($SMC_CREDIT_PD) > 0) {
$all_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('smc_credit_pd' => $smc_credit_pd, 'isactive' => 1), SMC_CREDIT_PD_SECTION_DATA);
$common_fields = array(
'pdid' => $SMC_CREDIT_PD['fk_sales_pd_id'],
'product' => $SMC_CREDIT_PD['abbr'],
'caseno' => $SMC_CREDIT_PD['smc_credit_pd_sno']
);
foreach ($all_section_data as $sec_key => $section) {
$section_fields['section' . $section['section_id']] = $this->processSalesPDJSON($section);
}
$pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($SMC_CREDIT_PD['fk_sales_pd_id'], $SMC_CREDIT_PD['product_id'], null, null, 'REPORT');
if (count($pd_section_data)) {
foreach ($pd_section_data as $key => $value) {
if (isset($value['json']) && $value['json'] != '') {
$filter_form_id[$key] = $value['fk_form_id'];
$CETAPP_creditPD_data[$value['form_name']] = $value['json'];
} else {
if (in_array($value['fk_form_id'], $forms_data_to_be_get_direct_from_excel_sheet)) {
$data_from_excel = $this->loadDataFromExcelBusiProcess($mater_details, $value['fk_form_id']);
$filter_form_id[$key] = $value['fk_form_id'];
$CETAPP_creditPD_data[$value['form_name']] = $data_from_excel;
}
}
}
}
$photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('fk_smc_credit_pd' => $smc_credit_pd, 'img_name !=' => 'satellite', 'isactive' => 1), SALEPD_DOCS);
if (count($photograph_data) > 0) {
for ($i = 0; $i < count($photograph_data); $i++) {
$img_fields = $common_fields;
$img_fields['img_name'] = $photograph_data[$i]['img_name'];
$img_split = explode(',', $photograph_data[$i]['img']);
$img_fields['img'] = $img_split[1];
cet_creditpd::pushwithcetphotographapi($img_fields, $i);
}
}
if ($mater_details[0]['product_abbr'] == 'LFMP') {
$LFMP_KeyStackholders = $pd_section_data[5]['key_stakeholders'];
$temp_arr = [];
for ($i = 0; $i < count($LFMP_KeyStackholders); $i++) {
$value = $LFMP_KeyStackholders[$i];
if (isset($value["stakeholder_name0"])) {
$temp_arr[] = array(
"company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name0"],
"share_holding" => $value["share_holding0"], "vintage_in_current_biz" => $value["vintage_in_current_biz0"],
"total_work_exp" => $value["total_work_exp0"], "started_biz" => $value["started_biz0"],
"previous_experience_details" => (isset($value['previous_experience_details0']) ? $value['previous_experience_details0'] : '')
);
}
if (isset($value["stakeholder_name1"])) {
$temp_arr[] = array(
"company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name1"],
"share_holding" => $value["share_holding1"], "vintage_in_current_biz" => $value["vintage_in_current_biz1"],
"total_work_exp" => $value["total_work_exp1"], "started_biz" => $value["started_biz1"],
"previous_experience_details" => (isset($value['previous_experience_details1']) ? $value['previous_experience_details1'] : '')
);
}
if (isset($value["stakeholder_name2"])) {
$temp_arr[] = array(
"company_name" => $value["company_name"],
"stakeholder_name" => $value["stakeholder_name2"], "share_holding" => $value["share_holding2"],
"vintage_in_current_biz" => $value["vintage_in_current_biz2"], "total_work_exp" => $value["total_work_exp2"], "started_biz" => $value["started_biz2"],
"previous_experience_details" => (isset($value['previous_experience_details2']) ? $value['previous_experience_details2'] : '')
);
}
}
$CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr;
} // ### LFMP key_stakeholders ends
if ((in_array(1, $filter_form_id)) && (in_array(21, $filter_form_id)))
// && (in_array(4,$filter_form_id)))
{
$officer_id = isset($mater_details[0]['fk_updatedby']) ? $mater_details[0]['fk_updatedby'] : '';
$visit_date = isset($mater_details[0]['pd_visit_date']) ? $mater_details[0]['pd_visit_date'] : '';
if (!empty($officer_id)) {
$officer_details = $this->SMC_Credit_PD_Model->selectCustomRecords(array('userid as officer_id', 'email', 'mobile_no', 'concat(first_name," ",last_name) as officer'), array('userid' => $officer_id), USERPROFILE);
if (!empty($officer_details)) {
foreach ($officer_details as $key => $value) {
$CETAPP_creditPD_data['Officer Details'] = $value;
$CETAPP_creditPD_data['Officer Details']['pd_visit_date'] = $visit_date;
}
}
}
}
cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data);
$satellite_image = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id', 'img', 'img_name', 'isactive'), array('fk_smc_credit_pd_id' =>$smc_credit_pd, 'isactive' => 1, 'img_name=' => 'satellite'), SMC_CREDIT_PD_DOCS);
if (!empty($satellite_image)) {
$stt_fields = $common_fields;
$stt_fields['img_name'] = $satellite_image[0]['img_name'];
$stt_fields['img'] = $satellite_image[0]['img'];
cet_creditpd::pushwithcetphotographapi($stt_fields, 0);
}
//
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Data Shared Successfully';
$this->response($data, REST_Controller::HTTP_OK);
} else {
log_message('ERROR', '#### There is No Data Found relevant Credit PDID ');
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'There is No Data Found relevant Credit PDID ! Try Later';
$this->response($data, REST_Controller::HTTP_OK);
}
} else {
log_message('ERROR', '#### Can`t able Found the Credit PDID ');
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Can`t able Found the Creditpd PDID ! Try Later';
$this->response($data, REST_Controller::HTTP_OK);
}
}
public function listSMCCreditPD_get()
{
@ -1529,12 +1672,6 @@ public function filterSalesPDList_post() {
$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->getSMCTemplateForPD($records['pd_id'],$view_data['pd_master_details'][0]['fk_product_id'],null,null,'REPORT');
//$common_fields = array('pdid'=>111,
// 'product'=>$view_data['pd_master_details'][0]['product_abbr'],
// 'caseno'=>'MWISE00840');
$common_fields = array('pdid'=>$view_data['pd_master_details'][0]['pd_id'],
'product'=>$view_data['pd_master_details'][0]['product_abbr'],
'caseno'=>$view_data['pd_master_details'][0]['pd_sno']);
// print_r($pd_section_data);die();
$forms_data_to_be_get_direct_from_excel_sheet = array(3,9,10,15);
@ -1553,8 +1690,6 @@ public function filterSalesPDList_post() {
$filter_form_id[$key] = $value['fk_form_id'];
// if($value['fk_form_id'] == 2){print_r($value['json']);die();}
$view_data['pd_section_data'][$value['fk_form_id']] = $value['json'];
$CETAPP_creditPD_data[$value['form_name']] = $value['json'];
// $CETAPP_creditPD_data[$value['fk_form_id']] = $value['json'];
}
else
{
@ -1565,9 +1700,6 @@ public function filterSalesPDList_post() {
//print_r($data_from_excel);die();
$view_data['pd_section_data'][$value['fk_form_id']] = $data_from_excel;
$filter_form_id[$key] = $value['fk_form_id'];
$CETAPP_creditPD_data[$value['form_name']] = $data_from_excel;
// $CETAPP_creditPD_data[$value['fk_form_id']]= $data_from_excel;
}
}
//die();
@ -1578,21 +1710,6 @@ public function filterSalesPDList_post() {
// 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);
if(count($view_data['smc_images'])>0){
for ($i = 0; $i < count($view_data['smc_images']); $i++){
$img_fields = $common_fields;
$img_fields['img_name'] = $view_data['smc_images'][$i]['img_name'];
$img_split = explode( ',', $view_data['smc_images'][$i]['img']);
$img_fields['img'] = $img_split[1];
// $img_fields[0]['img'] = $view_data['section9'][$i]['img'];
cet_creditpd::pushwithcetphotographapi($img_fields,$i);
}}
if(!empty($view_data['satellite'])){
$stt_fields = $common_fields;
$stt_fields['img_name'] = $view_data['satellite'][0]['img_name'];
$stt_fields['img'] = $view_data['satellite'][0]['img'];
cet_creditpd::pushwithcetphotographapi($stt_fields,0);
}
// print_r($view_data['smc_images']);die();
//print_r(count($view_data['smc_images']));die();
@ -1664,26 +1781,7 @@ public function filterSalesPDList_post() {
}
}
$view_data['pd_section_data'][5]['key_stakeholders'] = $temp_arr;
$CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr;
// $CETAPP_creditPD_data[5]['key_stakeholders'] = $temp_arr;
}// ### LFMP key_stakeholders ends
// log_message('ERROR',"SUSEEN".json_encode($CETAPP_creditPD_data));die();
if((in_array(1,$filter_form_id)) && (in_array(21,$filter_form_id)))
// && (in_array(4,$filter_form_id)))
{
$officer_id = isset($view_data['pd_master_details'][0]['fk_updatedby']) ? $view_data['pd_master_details'][0]['fk_updatedby'] : '';
$visit_date = isset($view_data['pd_master_details'][0]['pd_visit_date']) ? $view_data['pd_master_details'][0]['pd_visit_date'] : '';
if(!empty($officer_id)){
$officer_details = $this->SMC_Credit_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer'),array('userid' => $officer_id),USERPROFILE);
if(!empty($officer_details)){
foreach($officer_details as $key=>$value) {
$CETAPP_creditPD_data['Officer Details'] = $value;
$CETAPP_creditPD_data['Officer Details']['pd_visit_date'] = $visit_date;
}
}
}
}
cet_creditpd::pushwithcetcreditpdapi($common_fields,$CETAPP_creditPD_data);
$view_data['report_attachments'] = (new report_attachments)->getSMCReportAttchments($records['pd_id'],$view_data['pd_master_details'][0]['random_string'],$view_data['pd_master_details']);