diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 5c849cff..85415d7f 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -372,7 +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['uploadCreditPDDataToCETApp/(:num)'] = 'SMC_Credit_PD_Controller/uploadCreditPDDataToCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index a2377e69..018ff16d 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -271,42 +271,15 @@ class SMC_Credit_PD_Controller extends REST_Controller { { 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); + $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); + $pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($smc_credit_pd,$mater_details[0]['fk_product_id'],null,null,'REPORT'); + log_message('ERROR', '#### Total Credit PD is ' . count($pd_section_data)); + if (!empty($pd_section_data)) { $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)) { + if (count($pd_section_data) > 0) { + $common_fields = array('pdid'=>$mater_details[0]['pd_id'], + 'product'=>$mater_details[0]['product_abbr'], + 'caseno'=>$mater_details[0]['pd_sno']); foreach ($pd_section_data as $key => $value) { if (isset($value['json']) && $value['json'] != '') { $filter_form_id[$key] = $value['fk_form_id']; @@ -319,51 +292,53 @@ class SMC_Credit_PD_Controller extends REST_Controller { } } } - } - - $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') { + $photograph_data = $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); + $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(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(!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); + } + if ($mater_details[0]['product_abbr'] == 'LFMP' && (array_key_exists("key_stakeholders",$pd_section_data[5])) ) { $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; + $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))) @@ -382,15 +357,6 @@ class SMC_Credit_PD_Controller extends REST_Controller { } 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';