From 2bf8601db4dea65f0a3d145e95b3b1c7a1cb37a3 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Mon, 16 May 2022 11:28:08 +0530 Subject: [PATCH] SALES PD IMG INTEGRATION WITH CET --- api/application/config/constants.php | 6 +++ .../controllers/Sales_PD_Controller.php | 2 +- .../helpers/salespd_cetapp_helper.php | 37 +++++++------------ 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index b9046e0e..8d1d5487 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -123,6 +123,8 @@ defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://apitest. defined('OPTIMIZED_IMAGE_BUCKET_NAME') OR define('OPTIMIZED_IMAGE_BUCKET_NAME','optimized-images-demo'); defined('IMAGE_OPTIMIZE_LAMBDA_URL') OR define('IMAGE_OPTIMIZE_LAMBDA_URL','https://wlaax92nne.execute-api.ap-south-1.amazonaws.com/demo'); defined('VIDEO_SHORT_URL') OR define('VIDEO_SHORT_URL','https://lkt.pdgenie.com/'); +defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); +defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); } else if(ENVIRONMENT == 'testing') { @@ -141,6 +143,8 @@ else if(ENVIRONMENT == 'testing') defined('OPTIMIZED_IMAGE_BUCKET_NAME') OR define('OPTIMIZED_IMAGE_BUCKET_NAME','optimized-images-demo'); defined('IMAGE_OPTIMIZE_LAMBDA_URL') OR define('IMAGE_OPTIMIZE_LAMBDA_URL','https://wlaax92nne.execute-api.ap-south-1.amazonaws.com/demo'); defined('VIDEO_SHORT_URL') OR define('VIDEO_SHORT_URL','https://lkt.pdgenie.com/'); + defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); + defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); } else if(ENVIRONMENT == 'production') { @@ -159,6 +163,8 @@ else if(ENVIRONMENT == 'production') defined('OPTIMIZED_IMAGE_BUCKET_NAME') OR define('OPTIMIZED_IMAGE_BUCKET_NAME','optimized-images-live'); defined('IMAGE_OPTIMIZE_LAMBDA_URL') OR define('IMAGE_OPTIMIZE_LAMBDA_URL','https://4u9t03hvfb.execute-api.ap-south-1.amazonaws.com/live'); defined('VIDEO_SHORT_URL') OR define('VIDEO_SHORT_URL','https://l.pdgenie.com/'); + defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); + defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); } /*********************END of AWS resources Constants*************************************************/ diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 11e7195f..4a9c83ed 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -224,7 +224,7 @@ class Sales_PD_Controller extends REST_Controller { $img_split = explode( ',', $view_data['section9'][$i]['img']); $img_fields['img'] = $img_split[1]; // $img_fields[0]['img'] = $view_data['section9'][$i]['img']; - salespd_cetapp::pushwithcetphotographapi($img_fields); + salespd_cetapp::pushwithcetphotographapi($img_fields,$i); } // "section9":{"selfie_with_person_met":"SAVED","approach_to_pd_location":["SAVED",""],"name_board_seen":["SAVED",""],"stock_image":["SAVED","SAVED","SAVED","SAVED",""],"workplace_interior_image":["SAVED","SAVED",""]}} // $arr1 =array();$arr2 =array(); diff --git a/api/application/helpers/salespd_cetapp_helper.php b/api/application/helpers/salespd_cetapp_helper.php index f2ab5720..51b274e8 100644 --- a/api/application/helpers/salespd_cetapp_helper.php +++ b/api/application/helpers/salespd_cetapp_helper.php @@ -43,52 +43,41 @@ class SALESPD_CETAPP // log_message('ERROR',"result : ".$result); // log_message('ERROR',"result : ".json_encode($result)); curl_close( $ch ); - $CI =&get_instance(); + } // multipart/form-data; - public static function pushwithcetphotographapi($fields) + public static function pushwithcetphotographapi($fields,$index) { - log_message('ERROR','#### pushwithcetphotographapi Helper FNS'); + // log_message('ERROR','#### pushwithcetphotographapi Helper FNS'); + $CI =&get_instance(); $img = $fields['img']; $pdid = $fields['pdid']; $img = str_replace('data:image/png;base64,', '', $img); $img = str_replace(' ', '+', $img); $data = base64_decode($img); - // $file = $CI->external_path.'/tmp/' . uniqid() .'png'; - // $file = $CI->external_path.'/tmp/' . date('Y-m-d_h:i:s') .'png'; - // $file = $CI->external_path.'/tmp/temp.png'; - $file = '/opt/lampp/htdocs/ssa_external_data/testing/tmp/temp.png'; - // $success = file_put_contents($file, base64_decode($data)); + $file = $CI->external_path.'/tmp/temp'. $index .date('Y-m-d_h-i-s') .'.png'; + $curlFile = curl_file_create($file); $success = file_put_contents($file, $data); - if($success){ - log_message('ERROR',"CET APP PDID (".$pdid.") ".$fields['img_name']." = Successfully Uploaded"); - }else{ - log_message('ERROR',"CET APP PDID (".$pdid.") ".$fields['img_name']." = Upload failed"); - } - // unlink($file_name_with_full_path); - $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); $ch = curl_init(); + // $url = 'https://apitest.pdgenie.com/file_receive.php'; $url = 'https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'; $log_msg = " PullSalesPdPhotographsData api (".$fields['img_name'].")"; - $fields['img'] = $file; + $fields['img'] = $curlFile; curl_setopt( $ch,CURLOPT_URL, $url); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); - // curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); // curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true ); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); - $result=curl_exec ($ch); + $result=curl_exec($ch); $response = json_decode($result); - log_message('ERROR',"CET APP PDID (".$pdid.") ".$log_msg." curl result : ".json_encode($result)." response :".json_encode($response)); - // print_r($result); - // $file_name_with_full_path = $CI->external_path.'/tmp/'. temp .'.png'; + log_message('ERROR',"###CET APP PDID (".$pdid.") ".$log_msg."response :".json_encode($response)); curl_close( $ch ); - unlink($file); - $CI =&get_instance(); - // unlink($file_name_with_full_path); + unlink($file); + // unlink($file_name_with_full_path); } }