diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index c858eee9..6245eb5a 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -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)); ### Automation CET Data Push Credit PD 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'); if(isset($result->status) && $result->status == 200){ 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); $details = $this->SMC_Credit_PD_Model->selectCustomRecords($columns, $where_arr, $table); if(!empty($details)){ - $response = $this->dataSynchronization($smc_credit_pd); + $response = $this->dataSynchronization($smc_credit_pd,1); $data['CETresponse'] = $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); $this->SMC_Credit_PD_Model->updateRecords($update_fields2,PDTRIGGER,array('pd_id' => $smc_credit_pd)); $data['dataStatus'] = true; @@ -371,10 +372,10 @@ class SMC_Credit_PD_Controller extends REST_Controller { if(!empty($details)){ $flag = 0;$ids=array(); for ($i = 0; $i < count($details); $i++) { - log_message('ERROR', "smcCreditPD inx = $i ".$smc_credit_pd); $smc_credit_pd = $details[$i]['pd_id']; + log_message('ERROR', "smcCreditPD inx = $i ".$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; sleep(2); // $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'); $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); @@ -505,48 +506,52 @@ class SMC_Credit_PD_Controller extends REST_Controller { } } } - $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){ - $CETAPP_creditPD_data['Photograph Details']['photo']=$photograph_data; - } + 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); + if(count($photograph_data)>0){ + $CETAPP_creditPD_data['Photograph Details']['photo']=$photograph_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'); - $totalimages = count($satellite_image)+count($photograph_data); - if(count($photograph_data)>0){ - $j=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(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'); - $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); - 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"; - // $json = json_decode($view_data['pd_section_data'],true); - // $fp = fopen($path, 'w'); - // fwrite($fp, $jsonString); - // fclose($fp); - // if(file_put_contents($path, $output_data)) - // { - // $message = "