SMC Credit PD Changes : ps

This commit is contained in:
VE10-Sanjeev 2023-01-06 22:07:59 +05:30
parent 5b0c17735f
commit 0170fd35a1
2 changed files with 38 additions and 26 deletions

View File

@ -274,7 +274,7 @@ class SMC_Credit_PD_Controller extends REST_Controller {
$smc_credit_pd = $this->uri->segment(2);
$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));
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') There are ' . count($pd_section_data).' Forms ');
if (!empty($pd_section_data)) {
$forms_data_to_be_get_direct_from_excel_sheet = array(3, 9, 10, 15);
$companylist = $this->getCompanyName($pd_section_data[0]);
@ -312,23 +312,7 @@ class SMC_Credit_PD_Controller extends REST_Controller {
$filter_form_id[$key] = $value['fk_form_id'];
}
}
}
$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 = [];
@ -374,8 +358,27 @@ class SMC_Credit_PD_Controller extends REST_Controller {
}
}
cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data);
// print_r($CETAPP_creditPD_data);
$result = cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data);
if($result == true){
$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);
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') There are ' . count($photograph_data).' Images');
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];
$resultimages = cet_creditpd::pushwithcetphotographapi($img_fields,$i);
}}
if(!empty($satellite_image)){
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') satellite Available');
$stt_fields = $common_fields;
$stt_fields['img_name'] = $satellite_image[0]['img_name'];
$stt_fields['img'] = $satellite_image[0]['img'];
$resultstatellite = cet_creditpd::pushwithcetphotographapi($stt_fields,0);
}
// print_r($CETAPP_creditPD_data);
// $path = $this->external_path ."/pd_reports/" . $mater_details[0]['pd_id'] . "/new-file-5-".$mater_details[0]['pd_id'].".json";
// $json = json_decode($view_data['pd_section_data'],true);
// $fp = fopen($path, 'w');
@ -390,6 +393,12 @@ class SMC_Credit_PD_Controller extends REST_Controller {
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Data Shared Successfully';
}else{
log_message('ERROR', '#### Section Details pushed Images Details Not Pushed');
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Section Details pushed Images Details Not Pushed ! Try Later';
}
$this->response($data, REST_Controller::HTTP_OK);
} else {
log_message('ERROR', '#### There is No Data Found relevant Credit PDID ');

View File

@ -8,6 +8,7 @@ class CET_CREDITPD
public static function pushwithcetcreditpdapi($fields,$data)
{
log_message('ERROR','#### Inside cet creditpd helper fns');
$CI =&get_instance();
if (array_key_exists("Photograph's", $data)) {
unset($data["Photograph's"]);
}
@ -27,14 +28,15 @@ class CET_CREDITPD
$ch = curl_init();
$output_data = json_encode( $fields );
// log_message('ERROR','#### output_data '.$output_data);
// $path = $path ."/tmp/".$fields['pdid'].".json";
// $fp = fopen($path, 'w');
// fwrite($fp, $output_data);
// $path = $CI->external_path."/tmp/".$fields['pdid']."1.json";
// // $fp = fopen($path, 'w');
// // fwrite($fp, $output_data);
// if(file_put_contents($path, $output_data))
// {
// $message = "<label class='text-success'>File createed and data added Success fully</p>";
// echo $message;
// }die();
// }
// return false;
// print_r($fields);die();
// log_message('ERROR',"PullcreditPDData api Request Format : ".$output_data);
// curl_setopt( $ch,CURLOPT_URL, "https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData");
@ -48,7 +50,7 @@ class CET_CREDITPD
$response = json_decode($result);
log_message('ERROR',"CET APP CREDIT PDID (".$pdid.") response :".json_encode($response));
curl_close( $ch );
return $response->status == 200 ? true : false;
}
// multipart/form-data;
@ -69,6 +71,7 @@ class CET_CREDITPD
$ch = curl_init();
$log_msg = " PullcreditPdPhotographsData api (".$fields['img_name'].")";
$fields['img'] = $curlFile;
log_message('ERROR',"CET APP CREDIT PDID (".$pdid.") response :".json_encode($fields));
curl_setopt( $ch,CURLOPT_URL, CET_CREDIT_PD_INTEGRATION_IMG_URL);
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
@ -81,7 +84,7 @@ class CET_CREDITPD
curl_close( $ch );
unlink($file);
// unlink($file_name_with_full_path);
return $response->status == 200 ? true : false;
}
}