Code Committed : ps
This commit is contained in:
parent
76554e814f
commit
7937b69c07
@ -27,6 +27,7 @@ class Sales_PD_Controller extends REST_Controller {
|
|||||||
$this->load->helper('camunda');
|
$this->load->helper('camunda');
|
||||||
$this->load->library('phpmailer_library');
|
$this->load->library('phpmailer_library');
|
||||||
$this->load->helper('cet_salespd');
|
$this->load->helper('cet_salespd');
|
||||||
|
$this->load->helper('smcfinance');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -330,7 +331,7 @@ class Sales_PD_Controller extends REST_Controller {
|
|||||||
log_message('ERROR', '#### upload Sales PDData To CETApp Function Called');
|
log_message('ERROR', '#### upload Sales PDData To CETApp Function Called');
|
||||||
$columns = array('SALES_PD_DATA.sales_pd_id');
|
$columns = array('SALES_PD_DATA.sales_pd_id');
|
||||||
$table = SALES_PD_DATA . ' as SALES_PD_DATA';
|
$table = SALES_PD_DATA . ' as SALES_PD_DATA';
|
||||||
$where_arr = array('SALES_PD_DATA.is_the_data_transfer_cet'=>0,'SALES_PD_DATA.status' => COMPLETED,'SALES_PD_DATA.sales_pd_id'=>$sales_pd_id);
|
$where_arr = array('SALES_PD_DATA.is_the_data_transfer_cet'=>1,'SALES_PD_DATA.status' => COMPLETED,'SALES_PD_DATA.sales_pd_id'=>$sales_pd_id);
|
||||||
$details = $this->Sales_PD_Model->selectCustomRecords($columns, $where_arr, $table);
|
$details = $this->Sales_PD_Model->selectCustomRecords($columns, $where_arr, $table);
|
||||||
if(!empty($details)){
|
if(!empty($details)){
|
||||||
$response = $this->dataSynchronization($sales_pd_id,0);
|
$response = $this->dataSynchronization($sales_pd_id,0);
|
||||||
@ -1011,6 +1012,18 @@ class Sales_PD_Controller extends REST_Controller {
|
|||||||
$records['completed_date'] = date('Y-m-d H:i:s');
|
$records['completed_date'] = date('Y-m-d H:i:s');
|
||||||
//echo 'final';die();
|
//echo 'final';die();
|
||||||
$id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id']));
|
$id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id']));
|
||||||
|
$columns = array('SALES_PD_DATA.sales_pd_sno');
|
||||||
|
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||||
|
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $records['sales_pd_id']);
|
||||||
|
$sales_pd_data = $this->Sales_PD_Model->selectCustomRecords($columns,$where_condition_array,$table);
|
||||||
|
$sales_pd_sno = $sales_pd_data[0]['sales_pd_sno'];
|
||||||
|
$smcauthtoken = smcfinance::SmcFinanceAuthUrl();
|
||||||
|
if($smcauthtoken != null){
|
||||||
|
log_message('ERROR','## smc i got token, '.$smcauthtoken);
|
||||||
|
smcfinance::SmcFinanceApiUrl($records['sales_pd_id'],$sales_pd_sno,2,$smcauthtoken);
|
||||||
|
}else{
|
||||||
|
log_message('ERROR','## no token, '.$smcauthtoken);
|
||||||
|
}
|
||||||
|
|
||||||
//CAMUNDA::completeSalesPDTask($records['sales_pd_id']);
|
//CAMUNDA::completeSalesPDTask($records['sales_pd_id']);
|
||||||
|
|
||||||
@ -1982,6 +1995,14 @@ public function filterSalesPDList_post() {
|
|||||||
log_message('ERROR','## 6) Finally, '.$data['msg']);
|
log_message('ERROR','## 6) Finally, '.$data['msg']);
|
||||||
date_default_timezone_set("Asia/Kolkata");
|
date_default_timezone_set("Asia/Kolkata");
|
||||||
$current_date = date("d/m/Y H:i:s");
|
$current_date = date("d/m/Y H:i:s");
|
||||||
|
$smcauthtoken = smcfinance::SmcFinanceAuthUrl();
|
||||||
|
if($smcauthtoken != null){
|
||||||
|
log_message('ERROR','## 7) i got token, '.$smcauthtoken);
|
||||||
|
smcfinance::SmcFinanceApiUrl($salepdid,$salepd_serial_no,1,$smcauthtoken);
|
||||||
|
}else{
|
||||||
|
log_message('ERROR','## 7) no token, '.$smcauthtoken);
|
||||||
|
}
|
||||||
|
|
||||||
if(ENVIRONMENT == 'production'){
|
if(ENVIRONMENT == 'production'){
|
||||||
$auth_user_id = "MwiseSales@yahoo.com";
|
$auth_user_id = "MwiseSales@yahoo.com";
|
||||||
$auth_password = "sine1234";
|
$auth_password = "sine1234";
|
||||||
|
|||||||
119
api/application/helpers/smcfinance_helper.php
Normal file
119
api/application/helpers/smcfinance_helper.php
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SMCFINANCE
|
||||||
|
{
|
||||||
|
|
||||||
|
// 1. AUTH URL
|
||||||
|
// API URL : http://ums.devopsmcfinance.com/umsnode/ums/api/v1/auth/login
|
||||||
|
// TYPE : POST
|
||||||
|
// BODY : { "userCode": "APIEdge", "userPass": "sineUAT", "application": [ "Sales App-API" ] }
|
||||||
|
public static function SmcFinanceAuthUrl()
|
||||||
|
{
|
||||||
|
|
||||||
|
log_message('ERROR','#### Smc Finance Auth Url Helper FNS');
|
||||||
|
// echo "Token Generation/Refresh Fns";
|
||||||
|
$headers = array('Content-Type: application/json');
|
||||||
|
try{
|
||||||
|
$ch = curl_init();
|
||||||
|
$body = '{ "userCode": "APIEdge","userPass": "sineUAT", "application": [ "Sales App-API" ] }';
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL, SMC_FINANCE_AUTH_URL);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
|
||||||
|
|
||||||
|
// $result = curl_exec($ch );
|
||||||
|
$result = (array)curl_exec($ch );
|
||||||
|
if($result){
|
||||||
|
$response_decoded = json_decode($result[0]);
|
||||||
|
$token = $response_decoded->data->accessToken;
|
||||||
|
}else{
|
||||||
|
$token = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $response_decoded = json_decode($result);
|
||||||
|
// $response = $response_decoded;
|
||||||
|
curl_close( $ch );
|
||||||
|
log_message('ERROR', "Smc Finance Auth Url token : " . $token);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$token = null;
|
||||||
|
// $response->error = array($e->getMessage());
|
||||||
|
log_message('ERROR', "Smc Finance Auth Url ERR : " . $e->getMessage());
|
||||||
|
}
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 2. Refresh Token
|
||||||
|
// API URL: http://ums.devopsmcfinance.com/umsnode/ums/api/v1/auth/access-token
|
||||||
|
// TYPE : POST
|
||||||
|
// BODY : { "refreshToken": {Refresh Token} }
|
||||||
|
public static function SmcFinanceRefreshToken($token)
|
||||||
|
{
|
||||||
|
$CI =& get_instance();
|
||||||
|
// $headersData = getallheaders();
|
||||||
|
log_message('ERROR','#### Smc Finance Refresh Token in Helper FNS ');
|
||||||
|
$headers = array('Content-Type: application/json');
|
||||||
|
try{
|
||||||
|
$ch = curl_init();
|
||||||
|
$body = '{ "refreshToken":$token'.$token.' }';
|
||||||
|
curl_setopt($ch, CURLOPT_URL, SMC_FINANCE_REFRESH_TOKEN);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
|
||||||
|
|
||||||
|
$result = curl_exec($ch );
|
||||||
|
$response_decoded = json_decode($result);
|
||||||
|
$response = $response_decoded;
|
||||||
|
curl_close( $ch );
|
||||||
|
log_message('ERROR','#### Smc Finance Refresh Token reponse '.$response);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$response->error = array($e->getMessage());
|
||||||
|
log_message('ERROR','#### Smc Finance Refresh Token reponse Err '. $e->getMessage());
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. API URL
|
||||||
|
// API URL: http://devopsmcfinance.com/salesapi/salesapplication/v1/sales-lead/${salesid}/update-pd
|
||||||
|
// TYPE : PUT
|
||||||
|
// BODY : { "pdId": "MWISE-LFMP-357", "pdStatus": 1 }
|
||||||
|
public static function SmcFinanceApiUrl($sales_pd_id,$sales_pd_sno,$sales_pd_status,$token)
|
||||||
|
{
|
||||||
|
log_message('ERROR',"SMC Finance Api Fns ");
|
||||||
|
$headers = array('Content-Type: application/json','Authorization : Bearer '.$token);
|
||||||
|
try{
|
||||||
|
$ch = curl_init();
|
||||||
|
$body = '{"pdId": '.$sales_pd_sno.',"pdStatus":'.$sales_pd_status.'}';
|
||||||
|
$put_url = SMC_FINANCE_API_URL.$sales_pd_id.'/update-pd';
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $put_url);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
|
||||||
|
|
||||||
|
$result = curl_exec($ch );
|
||||||
|
$response_decoded = json_decode($result);
|
||||||
|
curl_close( $ch );
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
// $response->error = array($e->getMessage());
|
||||||
|
$response_decoded = null;
|
||||||
|
log_message('ERROR', "SMC Finance Api Fns ERR : " . $e->getMessage());
|
||||||
|
}
|
||||||
|
return $response_decoded;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user