SALES PD CAMUNDA INTEGRATION
This commit is contained in:
parent
181152fad2
commit
087134d74d
@ -99,7 +99,7 @@ defined('SAVEROOMINFO_API') OR define('SAVEROOMINFO_API', 'saveRoomInfo')
|
||||
defined('SAVESMCCREDITPDIMAGE_API') OR define('SAVESMCCREDITPDIMAGE_API', 'saveSMCCreditPDImage'); // no errors
|
||||
defined('GETSMCPDIMGSECTIONDATA_API') OR define('GETSMCPDIMGSECTIONDATA_API', 'getSMCPDImgSectionData'); // no errors
|
||||
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN','getFullPDDetails'); // no errors
|
||||
|
||||
defined('CAMUNDA_URL') OR define('CAMUNDA_URL','http://34.121.71.79:8080/engine-rest/');
|
||||
/*********************AWS resources Constants*************************************************/
|
||||
defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic');
|
||||
if(ENVIRONMENT == 'development')
|
||||
|
||||
@ -302,6 +302,7 @@ $route['filterSalesPDList']='Sales_PD_Controller/filterSalesPDList';
|
||||
$route['generateSatelliteImg']='Sales_PD_Controller/generateSatelliteImg';
|
||||
$route['getSalesPDImgDataCusLink']='Sales_PD_Controller/getSalesPDImgDataCusLink';
|
||||
$route['sendSalesCusLinkViaSMS']='Sales_PD_Controller/sendSalesCusLinkViaSMS';
|
||||
$route['camundaTest']='Sales_PD_Controller/camundaTest';
|
||||
|
||||
|
||||
$route['listSMCCreditPD/(:num)']='SMC_Credit_PD_Controller/listSMCCreditPD';
|
||||
|
||||
@ -11028,15 +11028,28 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
if(!empty($_FILES['video_file']))
|
||||
{
|
||||
$folder_to_check = XLPATH.'/pd_reports/'.$records['fk_pd_id'].'/videos';
|
||||
|
||||
if(!file_exists($folder_to_check))
|
||||
{
|
||||
mkdir($folder_to_check,0777);
|
||||
}
|
||||
// die();
|
||||
// $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name']));
|
||||
$modified_fname = str_replace(' ','_',($_FILES['video_file']['name']));
|
||||
// echo file_exists($folder_to_check);die();
|
||||
|
||||
$config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $modified_fname);
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
$this->upload->initialize($config);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if($this->upload->do_upload('video_file'))
|
||||
{
|
||||
|
||||
log_message('ERROR','video uplaod done :' . $folder_to_check);
|
||||
$sourcefile = $folder_to_check.'/'.$modified_fname;
|
||||
// echo $sourcefile;
|
||||
$key = 'pd'.$records['fk_pd_id'].'/video/'.$modified_fname;
|
||||
@ -11052,6 +11065,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
unlink($sourcefile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','video uplaod failed :' . $folder_to_check);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
log_message('ERROR','video uplaod failed exception:' . $folder_to_check.' - '.$e->getMessage());
|
||||
}
|
||||
// die();
|
||||
|
||||
if($is_bucket_upload_sucess && $id)
|
||||
|
||||
@ -9,6 +9,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
|
||||
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||
include_once APPPATH.'/vendor/autoload.php';
|
||||
|
||||
|
||||
class Sales_PD_Controller extends REST_Controller {
|
||||
@ -22,6 +23,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$this->load->library('AWS_S3');
|
||||
$this->load->library('pdfgenerator');
|
||||
$this->load->helper('satellite_image');
|
||||
$this->load->helper('camunda');
|
||||
$this->load->library('phpmailer_library');
|
||||
|
||||
|
||||
@ -549,6 +551,9 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$records['sales_pd_sno'] = $salepd_serial_no;
|
||||
// print_r($records);die();
|
||||
$id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
|
||||
|
||||
//start camunda process
|
||||
CAMUNDA::startSalesPDInstance($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -659,6 +664,8 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
//echo 'final';die();
|
||||
$id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id']));
|
||||
|
||||
CAMUNDA::completeSalesPDTask($id);
|
||||
|
||||
$this->prepareSalesPDReport($records['sales_pd_id'],false);
|
||||
sleep(10);
|
||||
log_message('ERROR','####SALESPD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']);
|
||||
@ -1191,6 +1198,15 @@ public function filterSalesPDList_post() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function camundaTest_post()
|
||||
{
|
||||
// echo 'hi';
|
||||
|
||||
CAMUNDA::completeSalesPDTask(1);
|
||||
//CAMUNDA::startSalesPDInstance(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
154
api/application/helpers/camunda_helper.php
Normal file
154
api/application/helpers/camunda_helper.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
class CAMUNDA
|
||||
{
|
||||
|
||||
//include_once APPPATH.'/vendor/autoload.php';
|
||||
|
||||
//create a new instance
|
||||
public static function startNewInstance($process_def_id,$data = array())
|
||||
{
|
||||
$url = CAMUNDA_URL.'process-definition/'.$process_def_id.'/start';
|
||||
$client = new \GuzzleHttp\Client();
|
||||
try {
|
||||
|
||||
$response = $client->post( $url, [
|
||||
'headers' => ['Content-Type' => 'application/json']
|
||||
//'body' => json_encode($data)
|
||||
]);
|
||||
|
||||
if($response && $response->getStatusCode() == 200)
|
||||
{
|
||||
return (json_decode(($response->getBody()->getContents())));
|
||||
// echo $response->getBody()->getContents()->id;
|
||||
// echo $response->getBody()->getContents()['id'];
|
||||
// die();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
//return null;
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// complete an activity in an instance or instance
|
||||
public static function completeInstance($instanceID,$data = array())
|
||||
{
|
||||
$url = CAMUNDA_URL.'task/'.$instanceID.'/complete';
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->post( $url, [
|
||||
'headers' => ['Content-Type' => 'application/json']
|
||||
//'body' => json_encode($data)
|
||||
]);
|
||||
|
||||
if($response && $response->getStatusCode() == 200)
|
||||
{
|
||||
return json_encode($response->getBody()->getContents());
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getListOfInstanceByProcessDefinitionKey($processDefinitionKey,$data = array())
|
||||
{
|
||||
$url = CAMUNDA_URL . 'task?processDefinitionKey='.$processDefinitionKey;
|
||||
// echo $url;//die();
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->request('GET',$url);
|
||||
|
||||
// $client = new \GuzzleHttp\Client();
|
||||
// $res = $client->get( $url, [
|
||||
// 'headers' => ['Content-Type' => 'application/json'],
|
||||
// 'body' => json_encode($data)
|
||||
// ]);
|
||||
if($response && $response->getStatusCode() == 200)
|
||||
{
|
||||
return json_decode($response->getBody()->getContents());
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// print_r();
|
||||
// print_r($response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
public static function startSalesPDInstance($sales_pd_id)
|
||||
{
|
||||
|
||||
$CI =& get_instance();
|
||||
if($sales_pd_id)
|
||||
{
|
||||
$newProcessInstanceID = SELF::startNewInstance('sales_pd_demo:1:38949d25-8c83-11eb-a4f2-42010a800002');
|
||||
if($newProcessInstanceID && property_exists($newProcessInstanceID, 'id'))
|
||||
{
|
||||
$updated = $CI->Sales_PD_Model->updateRecords(array('t_process_instance_id' => $newProcessInstanceID->id),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
|
||||
log_message('ERROR','####Camunda start new instance success - ', $sales_pd_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','####Camunda start new instance failed - ', $sales_pd_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function completeSalesPDTask($sales_pd_id)//completeSalesPDTask ot instance
|
||||
{
|
||||
|
||||
$CI =& get_instance();
|
||||
if($sales_pd_id)
|
||||
{
|
||||
$fields=array('t_process_instance_id');
|
||||
$sales_pd_data = $CI->Sales_PD_Model->selectCustomRecords($fields,array('sales_pd_id' => $sales_pd_id),SALES_PD_DATA);
|
||||
|
||||
if($sales_pd_data && count($sales_pd_data))
|
||||
{
|
||||
//get list of task
|
||||
$task_id = null;
|
||||
$list_of_task = SELF::getListOfInstanceByProcessDefinitionKey('sales_pd_demo');
|
||||
if($list_of_task && count($list_of_task))
|
||||
{
|
||||
foreach ($list_of_task as $task_key => $task)
|
||||
{
|
||||
if($sales_pd_data[0]['t_process_instance_id'] == $task->processInstanceId)
|
||||
{
|
||||
$task_id = $task->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','####Couldn`t identify Camunda instance - ', $sales_pd_id);
|
||||
}
|
||||
|
||||
|
||||
if($task_id)
|
||||
{
|
||||
SELF::completeInstance($task_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','####Couldn`t identify task id - ', $sales_pd_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','#### could not get sales pd data - ', $sales_pd_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user