Photograph Details : ps

This commit is contained in:
VE10-Sanjeev 2023-03-16 14:05:14 +05:30
parent 7ed86279f0
commit ea55e0de37
3 changed files with 66 additions and 54 deletions

View File

@ -243,7 +243,8 @@ class SMC_Credit_PD_Controller extends REST_Controller {
$this->SMC_Credit_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SMC_CREDIT_PD,array('smc_credit_pd' => $smc_credit_pd)); $this->SMC_Credit_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SMC_CREDIT_PD,array('smc_credit_pd' => $smc_credit_pd));
### Automation CET Data Push Credit PD ### Automation CET Data Push Credit PD
sleep(10); sleep(10);
$result = $this->dataSynchronization($smc_credit_pd); $result = $this->dataSynchronization($smc_credit_pd,0);
$data['CETresponse'] = $result;
log_message('ERROR', '#### Automation CET Data Push Credit PD ('.$smc_credit_pd.') status '.$result->status.' Data Transfered'); log_message('ERROR', '#### Automation CET Data Push Credit PD ('.$smc_credit_pd.') status '.$result->status.' Data Transfered');
if(isset($result->status) && $result->status == 200){ if(isset($result->status) && $result->status == 200){
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$result->status." Data Transfered"); log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$result->status." Data Transfered");
@ -311,10 +312,10 @@ class SMC_Credit_PD_Controller extends REST_Controller {
$where_arr = array('PDTRIGGER.is_the_data_transfer_cet'=>0,'PDTRIGGER.pd_status' => COMPLETED,'PDTRIGGER.pd_id'=>$smc_credit_pd); $where_arr = array('PDTRIGGER.is_the_data_transfer_cet'=>0,'PDTRIGGER.pd_status' => COMPLETED,'PDTRIGGER.pd_id'=>$smc_credit_pd);
$details = $this->SMC_Credit_PD_Model->selectCustomRecords($columns, $where_arr, $table); $details = $this->SMC_Credit_PD_Model->selectCustomRecords($columns, $where_arr, $table);
if(!empty($details)){ if(!empty($details)){
$response = $this->dataSynchronization($smc_credit_pd); $response = $this->dataSynchronization($smc_credit_pd,1);
$data['CETresponse'] = $response; $data['CETresponse'] = $response;
if($response){ if($response){
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$response." Data Transfered"); log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.json_encode($response)." Data Transfered");
$update_fields2 = array('is_the_data_transfer_cet' => 1); $update_fields2 = array('is_the_data_transfer_cet' => 1);
$this->SMC_Credit_PD_Model->updateRecords($update_fields2,PDTRIGGER,array('pd_id' => $smc_credit_pd)); $this->SMC_Credit_PD_Model->updateRecords($update_fields2,PDTRIGGER,array('pd_id' => $smc_credit_pd));
$data['dataStatus'] = true; $data['dataStatus'] = true;
@ -371,10 +372,10 @@ class SMC_Credit_PD_Controller extends REST_Controller {
if(!empty($details)){ if(!empty($details)){
$flag = 0;$ids=array(); $flag = 0;$ids=array();
for ($i = 0; $i < count($details); $i++) { for ($i = 0; $i < count($details); $i++) {
log_message('ERROR', "smcCreditPD inx = $i ".$smc_credit_pd);
$smc_credit_pd = $details[$i]['pd_id']; $smc_credit_pd = $details[$i]['pd_id'];
log_message('ERROR', "smcCreditPD inx = $i ".$smc_credit_pd);
// echo $smc_credit_pd; // echo $smc_credit_pd;
$result = $this->dataSynchronization($smc_credit_pd); $result = $this->dataSynchronization($smc_credit_pd,1);
$data['CETresponse'][$smc_credit_pd] = $result; $data['CETresponse'][$smc_credit_pd] = $result;
sleep(2); sleep(2);
// $flag = $result == true ? $flag+1 : $flag; // $flag = $result == true ? $flag+1 : $flag;
@ -414,7 +415,7 @@ class SMC_Credit_PD_Controller extends REST_Controller {
} }
} }
function dataSynchronization($smc_credit_pd) function dataSynchronization($smc_credit_pd,$dummy_flag)
{ {
$this->load->helper('smc_creditpd'); $this->load->helper('smc_creditpd');
$mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd);
@ -505,47 +506,51 @@ class SMC_Credit_PD_Controller extends REST_Controller {
} }
} }
} }
if($dummy_flag == 0){
$photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('img_name','IF(img_name="satellite","satellite.png",rand_name) AS img'),array('fk_smc_credit_pd_id' => $smc_credit_pd,'isactive' => 1),SMC_CREDIT_PD_DOCS); $photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('img_name','IF(img_name="satellite","satellite.png",rand_name) AS img'),array('fk_smc_credit_pd_id' => $smc_credit_pd,'isactive' => 1),SMC_CREDIT_PD_DOCS);
if(count($photograph_data)>0){ if(count($photograph_data)>0){
$CETAPP_creditPD_data['Photograph Details']['photo']=$photograph_data; $CETAPP_creditPD_data['Photograph Details']['photo']=$photograph_data;
} }
}
$result = cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data); $result = cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data);
if($result == true){ if(isset($result->status) && $result->status == 200){
$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); // if($dummy_flag == 1){
$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); // $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);
// log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') There are ' . count($photograph_data).' Images'); // $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);
$totalimages = count($satellite_image)+count($photograph_data); // // log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') There are ' . count($photograph_data).' Images');
if(count($photograph_data)>0){ // $totalimages = count($satellite_image)+count($photograph_data);
$j=0; // if(count($photograph_data)>0){
for ($i = 0; $i < count($photograph_data); $i++){ // $j=0;
$img_fields = $common_fields; // for ($i = 0; $i < count($photograph_data); $i++){
$img_fields['img_name'] = $photograph_data[$i]['img_name']; // $img_fields = $common_fields;
$img_split = explode( ',', $photograph_data[$i]['img']); // $img_fields['img_name'] = $photograph_data[$i]['img_name'];
$img_fields['img'] = $img_split[1]; // $img_split = explode( ',', $photograph_data[$i]['img']);
$resultimages = cet_creditpd::pushwithcetphotographapi($img_fields,$i); // $img_fields['img'] = $img_split[1];
if(isset($resultimages->status) && ($resultimages->status == 200)){$j++;}else{ log_message('ERROR', '#### SMC Credit PD ('.$smc_credit_pd.') ' . $photograph_data[$i]['img_name'].' Image Not Transfer Check it'); } // $resultimages = cet_creditpd::pushwithcetphotographapi($img_fields,$i);
}} // if(isset($resultimages->status) && ($resultimages->status == 200)){$j++;}else{ log_message('ERROR', '#### SMC Credit PD ('.$smc_credit_pd.') ' . $photograph_data[$i]['img_name'].' Image Not Transfer Check it'); }
if(!empty($satellite_image)){ // }}
log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') satellite Available'); // if(!empty($satellite_image)){
$stt_fields = $common_fields; // log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') satellite Available');
$stt_fields['img_name'] = $satellite_image[0]['img_name']; // $stt_fields = $common_fields;
$stt_fields['img'] = $satellite_image[0]['img']; // $stt_fields['img_name'] = $satellite_image[0]['img_name'];
$resultstatellite = cet_creditpd::pushwithcetphotographapi($stt_fields,0); // $stt_fields['img'] = $satellite_image[0]['img'];
if(isset($resultstatellite->status) && ($resultstatellite->status == 200)){$j++;}else{ log_message('ERROR', '#### SMC Credit PD ('.$smc_credit_pd.') ' . $satellite_image[0]['img_name'].' Images Not Transfer Check it'); } // $resultstatellite = cet_creditpd::pushwithcetphotographapi($stt_fields,0);
} // if(isset($resultstatellite->status) && ($resultstatellite->status == 200)){$j++;}else{ log_message('ERROR', '#### SMC Credit PD ('.$smc_credit_pd.') ' . $satellite_image[0]['img_name'].' Images Not Transfer Check it'); }
// 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"; // // print_r($CETAPP_creditPD_data);
// $json = json_decode($view_data['pd_section_data'],true); // // $path = $this->external_path ."/pd_reports/" . $mater_details[0]['pd_id'] . "/new-file-5-".$mater_details[0]['pd_id'].".json";
// $fp = fopen($path, 'w'); // // $json = json_decode($view_data['pd_section_data'],true);
// fwrite($fp, $jsonString); // // $fp = fopen($path, 'w');
// fclose($fp); // // fwrite($fp, $jsonString);
// if(file_put_contents($path, $output_data)) // // fclose($fp);
// { // // if(file_put_contents($path, $output_data))
// $message = "<label class='text-success'>File createed and data added Success fully</p>"; // // {
// echo $message; // // $message = "<label class='text-success'>File createed and data added Success fully</p>";
// }die(); // // echo $message;
$result->imageStatus = $j.'/'.$totalimages; // // }die();
// $result->imageStatus = $j.'/'.$totalimages;
// }
return $result; return $result;
}else{ }else{
log_message('ERROR', '#### Section Details pushed Images Details Not Pushed'); log_message('ERROR', '#### Section Details pushed Images Details Not Pushed');
@ -2351,6 +2356,9 @@ public function filterSalesPDList_post() {
} }
$CET_response = cet_creditpd::repushwithcetphotographapi($common_fields); $CET_response = cet_creditpd::repushwithcetphotographapi($common_fields);
$CET_api_response[$credit_pd_id] = $CET_response; $CET_api_response[$credit_pd_id] = $CET_response;
$CET_api_response[$credit_pd_id]->totalImages = count($photograph_data);
$a = array();
if(isset($CET_response->status) && $CET_response->status == 200){ if(isset($CET_response->status) && $CET_response->status == 200){
foreach ($photograph_data as $key => $value){ foreach ($photograph_data as $key => $value){
@ -2363,7 +2371,9 @@ public function filterSalesPDList_post() {
$gcp_result = $this->googlecloud->uploadFileToGCPBucket($gcpBucketName,$objectName,$source); $gcp_result = $this->googlecloud->uploadFileToGCPBucket($gcpBucketName,$objectName,$source);
if($gcp_result == true) log_message('ERROR', '### Credit-PD ('.$credit_pd_id.') '.$value['img_name'].' Image Stored In GCP'); if($gcp_result == true) log_message('ERROR', '### Credit-PD ('.$credit_pd_id.') '.$value['img_name'].' Image Stored In GCP');
else log_message('ERROR', '### Credit-PD ('.$credit_pd_id.') '.$records['img_name'].' Image Not Stored In GCP'); else log_message('ERROR', '### Credit-PD ('.$credit_pd_id.') '.$records['img_name'].' Image Not Stored In GCP');
if($gcp_result == true && $value['img_name'] != 'satellite') $this->Sales_PD_Model->updateRecords(array('rand_name' => $rand_name),SMC_CREDIT_PD_DOCS,array('doc_id'=>$value['doc_id'])); if($gcp_result == true && $value['img_name'] != 'satellite') $this->SMC_Credit_PD_Model->updateRecords(array('rand_name' => $rand_name),SMC_CREDIT_PD_DOCS,array('doc_id'=>$value['doc_id']));
array_push($a,$value['img']);
$CET_api_response[$credit_pd_id]->images = $a;
} }
log_message('ERROR', '#### Credit PD ('.$credit_pd_id.') - CET response - '.json_encode($CET_response,true)); log_message('ERROR', '#### Credit PD ('.$credit_pd_id.') - CET response - '.json_encode($CET_response,true));
} else log_message('ERROR', '#### Credit PD ('.$credit_pd_id.') - CET response - '.json_encode($CET_response,true)); } else log_message('ERROR', '#### Credit PD ('.$credit_pd_id.') - CET response - '.json_encode($CET_response,true));

View File

@ -1990,6 +1990,8 @@ public function filterSalesPDList_post() {
} }
$CET_response = cet_salespd::repushwithcetphotographapi($section_fields); $CET_response = cet_salespd::repushwithcetphotographapi($section_fields);
$CET_api_response[$sales_pd_id] = $CET_response; $CET_api_response[$sales_pd_id] = $CET_response;
$CET_api_response[$sales_pd_id]->totalImages = count($photograph_data);
$a = array();
if(isset($CET_response->status) && $CET_response->status == 200){ if(isset($CET_response->status) && $CET_response->status == 200){
foreach ($photograph_data as $key => $value){ foreach ($photograph_data as $key => $value){
$rand_name = $value['rand_name']; $rand_name = $value['rand_name'];
@ -2016,6 +2018,8 @@ public function filterSalesPDList_post() {
$update_fields2 = array('rand_name' => $rand_name); $update_fields2 = array('rand_name' => $rand_name);
$this->Sales_PD_Model->updateRecords($update_fields2,SALEPD_DOCS,array('doc_id'=>$value['doc_id'])); $this->Sales_PD_Model->updateRecords($update_fields2,SALEPD_DOCS,array('doc_id'=>$value['doc_id']));
} }
array_push($a,$value['img']);
$CET_api_response[$sales_pd_id]->images = $a;
} }
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') - CET response - '.json_encode($CET_response,true)); log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') - CET response - '.json_encode($CET_response,true));
} }

View File

@ -17,19 +17,18 @@ class smc_creditpd
case 4://General Business case 4://General Business
$json = json_decode($section['json'],true); $json = json_decode($section['json'],true);
if(isset($json['business_entity'])){
for($i=0;$i<count($json['business_entity']);$i++) for($i=0;$i<count($json['business_entity']);$i++)
{ {
$value = $json['business_entity'][$i]['company_name']; $json['business_entity'][$i]['name_of_the_company'] = (isset($json['business_entity'][$i]['company_name']) ? $company[$json['business_entity'][$i]['company_name']] : 'NA');
$json['business_entity'][$i]['name_of_the_company'] = (isset($value) ? $company[$value] : 'NA'); }}
}
$return_data = $json; $return_data = $json;
break; break;
case 5://Key Stakeholders case 5://Key Stakeholders
$json = json_decode($section['json'],true); $json = json_decode($section['json'],true);
for($i=0;$i<count($json['key_stakeholders']);$i++) for($i=0;$i<count($json['key_stakeholders']);$i++)
{ {
$value = $json['key_stakeholders'][$i]['company_name']; $json['key_stakeholders'][$i]['name_of_the_company'] = (isset($json['key_stakeholders'][$i]['company_name']) ? $company[$json['key_stakeholders'][$i]['company_name']] : 'NA');
$json['key_stakeholders'][$i]['name_of_the_company'] = (isset($value) ? $company[$value] : 'NA');
} }
$return_data = $json; $return_data = $json;
break; break;
@ -37,8 +36,7 @@ class smc_creditpd
$json = json_decode($section['json'],true); $json = json_decode($section['json'],true);
for($i=0;$i<count($json['key_products_contribution']);$i++) for($i=0;$i<count($json['key_products_contribution']);$i++)
{ {
$value = $json['key_products_contribution'][$i]['company_name']; $json['key_products_contribution'][$i]['name_of_the_company'] = (isset($json['key_products_contribution'][$i]['company_name']) ? $company[$json['key_products_contribution'][$i]['company_name']] : 'NA');
$json['key_products_contribution'][$i]['name_of_the_company'] = (isset($value) ? $company[$value] : 'NA');
} }
$return_data = $json; $return_data = $json;
break; break;