91 lines
3.7 KiB
PHP
91 lines
3.7 KiB
PHP
<?php
|
|
|
|
class CET_CREDITPD
|
|
{
|
|
// public static function fns(){
|
|
// echo "I am at 6";
|
|
// }
|
|
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"]);
|
|
}
|
|
$key_check = array("Supplier details","Clients details","Stock details", "Neighbourhood Details", "Existing Loan Obligations","Business Assets");
|
|
for($i=0;$i<count($key_check);$i++){
|
|
if(array_key_exists($key_check[$i],$data)){
|
|
// echo $key_check[$i];
|
|
// echo gettype($key_check[$i])."\n";die();
|
|
$key_name = $key_check[$i];
|
|
if(is_array($data[$key_name]) && array_key_exists('display_data', $data[$key_name]))
|
|
unset($data[$key_check[$i]]['display_data']);
|
|
}
|
|
}
|
|
$fields['data'] = $data;
|
|
$pdid = $fields['pdid'];
|
|
$headers = array('Content-Type: application/json');
|
|
$ch = curl_init();
|
|
$output_data = json_encode( $fields );
|
|
// log_message('ERROR','#### output_data '.$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 = "<label class='text-success'>File createed and data added Success fully</p>";
|
|
// echo $message;
|
|
// }
|
|
// return false;
|
|
// print_r($fields);die();
|
|
// log_message('ERROR',"PullcreditPDData api Request Format : ".$output_data);
|
|
// curl_setopt( $ch,CURLOPT_URL, "https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData");
|
|
curl_setopt( $ch,CURLOPT_URL, CET_CREDIT_PD_INTEGRATION_URL);
|
|
curl_setopt( $ch,CURLOPT_POST, true );
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
|
|
curl_setopt( $ch,CURLOPT_POSTFIELDS, $output_data);
|
|
$result = curl_exec($ch );
|
|
$response = json_decode($result);
|
|
log_message('ERROR',"CET APP CREDIT PDID (".$pdid.") response :".json_encode($response));
|
|
curl_close( $ch );
|
|
return $response;
|
|
}
|
|
|
|
// multipart/form-data;
|
|
public static function pushwithcetphotographapi($fields,$index)
|
|
{
|
|
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/temp'. $index .date('Y-m-d_h-i-s') .'.png';
|
|
$curlFile = curl_file_create($file);
|
|
$success = file_put_contents($file, $data);
|
|
$headers = array('Content-Type: multipart/form-data');
|
|
// $headers = array('Content-Type: application/json');
|
|
$ch = curl_init();
|
|
$log_msg = " PullcreditPdPhotographsData api (".$fields['img_name'].")";
|
|
$fields['img'] = $curlFile;
|
|
log_message('ERROR',"CET APP CREDIT PDID (".$pdid.") response :".json_encode($fields));
|
|
curl_setopt( $ch,CURLOPT_URL, CET_CREDIT_PD_INTEGRATION_IMG_URL);
|
|
curl_setopt( $ch,CURLOPT_POST, true );
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
// curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
|
|
$result=curl_exec($ch);
|
|
$response = json_decode($result);
|
|
log_message('ERROR',"###CET APP CREDIT PDID (".$pdid.") ".$log_msg."response :".json_encode($response));
|
|
curl_close( $ch );
|
|
unlink($file);
|
|
// unlink($file_name_with_full_path);
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
?>
|