From 0170fd35a14a713750c0923b7d878cf5b8078095 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 6 Jan 2023 22:07:59 +0530 Subject: [PATCH] SMC Credit PD Changes : ps --- .../controllers/SMC_Credit_PD_Controller.php | 49 +++++++++++-------- .../helpers/cet_creditpd_helper.php | 15 +++--- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index 60a8cb3c..3c13051d 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -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 '); diff --git a/api/application/helpers/cet_creditpd_helper.php b/api/application/helpers/cet_creditpd_helper.php index ff8d5d90..c8c378c8 100644 --- a/api/application/helpers/cet_creditpd_helper.php +++ b/api/application/helpers/cet_creditpd_helper.php @@ -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 = "