From c7036683830b9c9044b890523076c4f62e0a7eea Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 1 Feb 2023 17:25:28 +0530 Subject: [PATCH] automation Sales PD Called : ps --- .../controllers/SMC_Credit_PD_Controller.php | 17 +++++++++++++++-- .../controllers/Sales_PD_Controller.php | 13 +++++++++++++ api/application/helpers/cet_creditpd_helper.php | 4 ++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index c6931c50..785dd277 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -230,6 +230,15 @@ 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)); + sleep(10); + $result = $this->dataSynchronization($smc_credit_pd); + log_message('ERROR', '#### Automation Credit PD ('.$smc_credit_pd.') status '.$result->status.' Data Transfered'); + // $flag = $result == true ? $flag+1 : $flag; + if($result->status == 200){ + log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$result->status." 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)); + } if($api) { // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); @@ -279,6 +288,9 @@ class SMC_Credit_PD_Controller extends REST_Controller { if(!empty($details)){ $response = $this->dataSynchronization($smc_credit_pd); if($response){ + log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$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; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'Data Shared Successfully'; @@ -331,17 +343,18 @@ 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']; // echo $smc_credit_pd; $result = $this->dataSynchronization($smc_credit_pd); // $flag = $result == true ? $flag+1 : $flag; - if($result == true){ + if($result->status == 200){ + log_message('ERROR', '#### Credit PD ('.$smc_credit_pd.') status '.$result->status." Data Transfered"); $flag = $flag+1; array_push($ids, $smc_credit_pd); //update here. $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; diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index d8034a9b..1db7a6a5 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -234,6 +234,16 @@ class Sales_PD_Controller extends REST_Controller { { $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + sleep(10); + $result = $this->dataSynchronization($sales_pd_id); + log_message('ERROR', '#### Automation CET Data Push Sales PD ('.$sales_pd_id.') status '.$result->status." Data Transfered"); + if($result->status == 200){ + log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status." Data Transfered"); + $update_fields2 = array('is_the_data_transfer_cet' => 1); + $this->Sales_PD_Model->updateRecords($update_fields2,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + }else{ + log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status); + } if($api) { $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); @@ -283,6 +293,9 @@ class Sales_PD_Controller extends REST_Controller { if(!empty($details)){ $response = $this->dataSynchronization($sales_pd_id); if($response){ + log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$response->status." Data Transfered"); + $update_fields2 = array('is_the_data_transfer_cet' => 1); + $this->Sales_PD_Model->updateRecords($update_fields2,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'Data Shared Successfully'; diff --git a/api/application/helpers/cet_creditpd_helper.php b/api/application/helpers/cet_creditpd_helper.php index c8c378c8..5f2b90c4 100644 --- a/api/application/helpers/cet_creditpd_helper.php +++ b/api/application/helpers/cet_creditpd_helper.php @@ -50,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; + return $response; } // multipart/form-data; @@ -84,7 +84,7 @@ class CET_CREDITPD curl_close( $ch ); unlink($file); // unlink($file_name_with_full_path); - return $response->status == 200 ? true : false; + return $response; } }