| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/cronjob/ |
Upload File : |
<?php
//error_reporting(E_ALL);
//error_reporting(0);
require_once 'init.php';
$objFlight = new Travel_Model_TblFlight();
function writeLog($data)
{
$fileName = "updatepnr" . date("Y-m-d") . ".txt";
$fp = fopen("log/" . $fileName, 'a+');
$data = date("Y-m-d H:i:s") . " - " . $data;
fwrite($fp, $data);
fclose($fp);
}
function FlightsTripJackURL($AgencySysId, $ApiKeyForFlight)
{
$objFlight = new Travel_Model_TblFlight();
$IsAPIProd = $objFlight->getIsAPIProdFlight($AgencySysId);
if ($IsAPIProd && $ApiKeyForFlight['IsCheckWallet'] == 1) {
$urlArray = array(
'APIKEY' => "399470738cc8adc-776f-4ef7-b46d-b87640ddd0e4", /// live key Catabatic Technology. as per prashant
'TRIPJACK_FL_SEARCHALL_URL' => 'https://api.tripjack.com/fms/v1/air-search-all',
'TRIPJACK_FL_API_FARE_RULE_URL' => 'https://api.tripjack.com/fms/v1/farerule',
'TRIPJACK_FL_API_REVIEW_URL' => 'https://api.tripjack.com/fms/v1/review',
'TRIPJACK_FL_API_INSTANT_BOOK_URL' => 'https://api.tripjack.com/oms/v1/air/book',
'TRIPJACK_FL_API_BOOKINGDETAILS_URL' => 'https://api.tripjack.com/oms/v1/booking-details',
'TRIPJACK_FL_API_GETAMENDMENTCHARGES_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/amendment-charges',
'TRIPJACK_FL_API_SUBMITAMENDMENT_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/submit-amendment',
'TRIPJACK_FL_API_AMENDMENTDETAILS_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/amendment-details',
'TRIPJACK_FL_API_FAREVALIDATE_URL' => 'https://api.tripjack.com/oms/v1/air/fare-validate',
'TRIPJACK_FL_API_SEAT_URL' => 'https://api.tripjack.com/fms/v1/seat',
'FLIGHT_API_LOGS' => true,
);
} else if ($IsAPIProd && $ApiKeyForFlight['IsCheckWallet'] == 0) {
$urlArray = array(
'APIKEY' => "399470738cc8adc-776f-4ef7-b46d-b87640ddd0e4", /// live key Catabatic Technology.as per prashant
'TRIPJACK_FL_SEARCHALL_URL' => 'https://api.tripjack.com/fms/v1/air-search-all',
'TRIPJACK_FL_API_FARE_RULE_URL' => 'https://api.tripjack.com/fms/v1/farerule',
'TRIPJACK_FL_API_REVIEW_URL' => 'https://api.tripjack.com/fms/v1/review',
'TRIPJACK_FL_API_INSTANT_BOOK_URL' => 'https://api.tripjack.com/oms/v1/air/book',
'TRIPJACK_FL_API_BOOKINGDETAILS_URL' => 'https://api.tripjack.com/oms/v1/booking-details',
'TRIPJACK_FL_API_GETAMENDMENTCHARGES_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/amendment-charges',
'TRIPJACK_FL_API_SUBMITAMENDMENT_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/submit-amendment',
'TRIPJACK_FL_API_AMENDMENTDETAILS_URL' => 'https://api.tripjack.com/oms/v1/air/amendment/amendment-details',
'TRIPJACK_FL_API_FAREVALIDATE_URL' => 'https://api.tripjack.com/oms/v1/air/fare-validate',
'TRIPJACK_FL_API_SEAT_URL' => 'https://api.tripjack.com/fms/v1/seat',
'FLIGHT_API_LOGS' => true,
);
} else {
$urlArray = array(
'APIKEY' => "311588105d9884-721f-46d8-9e83-b7a77119c824", /// Test key Catabatic Technology.as per prashant
'TRIPJACK_FL_SEARCHALL_URL' => 'https://apitest.tripjack.com/fms/v1/air-search-all',
'TRIPJACK_FL_API_FARE_RULE_URL' => 'https://apitest.tripjack.com/fms/v1/farerule',
'TRIPJACK_FL_API_REVIEW_URL' => 'https://apitest.tripjack.com/fms/v1/review',
'TRIPJACK_FL_API_INSTANT_BOOK_URL' => 'https://apitest.tripjack.com/oms/v1/air/book',
'TRIPJACK_FL_API_BOOKINGDETAILS_URL' => 'https://apitest.tripjack.com/oms/v1/booking-details',
'TRIPJACK_FL_API_GETAMENDMENTCHARGES_URL' => 'https://apitest.tripjack.com/oms/v1/air/amendment/amendment-charges',
'TRIPJACK_FL_API_SUBMITAMENDMENT_URL' => 'https://apitest.tripjack.com/oms/v1/air/amendment/submit-amendment',
'TRIPJACK_FL_API_AMENDMENTDETAILS_URL' => 'https://apitest.tripjack.com/oms/v1/air/amendment/amendment-details',
'TRIPJACK_FL_API_FAREVALIDATE_URL' => 'https://apitest.tripjack.com/oms/v1/air/fare-validate',
'TRIPJACK_FL_API_SEAT_URL' => 'https://apitest.tripjack.com/fms/v1/seat',
'FLIGHT_API_LOGS' => true,
);
}
return $urlArray;
}
function GetAmendmentDetails($arrData, $AgencySysId)
{
$checkOptModel = new Payment_Model_Checkotp();
$ApiKeyForFlight = $checkOptModel->getTripJectApiKeyForFlight($AgencySysId, 3);
$TripJackURL = FlightsTripJackURL($AgencySysId, $ApiKeyForFlight);
if ($ApiKeyForFlight['IsCheckWallet'] == 1) {
$APIKEY = $ApiKeyForFlight['APIKEY'];
} else {
$APIKEY = $TripJackURL['APIKEY'];
}
//
$data_stringh = json_encode(["amendmentId" => $arrData['amendmentId']]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $TripJackURL['TRIPJACK_FL_API_AMENDMENTDETAILS_URL']);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'apikey:' . $APIKEY,
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
$ResponseStatus = $response['status']['success'];
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$logParams = [
"user_id" => 1,
"AgencySysId" => $AgencySysId,
"custom_error" => ($ResponseStatus == 1) ? "Amendment Details success" : "Amendment Details failed",
'error' => $ErrorMessage,
"text_udf" => ['response' => $response], // Response
"char_udf" => ['request' => $arrData], // Request
"udf1" => $arrData['BookingId'],
"status" => ($ResponseStatus == 1) ? 2 : 1,
];
CreateLogs($logParams);
return $response;
}
$GeModificationData = $objFlight->GeModificationData(null, 'All');
// echo "<pre>";
// print_r($GeModificationData);
// exit;
if ($GeModificationData) {
foreach ($GeModificationData as $key => $value) {
if ($value['RequestType'] == 'CANCELLATION') {
try {
$ModificationId = $value['ModificationId'];
$intTPSysId = $value['TPSysId'];
$BookingId = $value['BookingId'];
$cRemarks = $value['Remarks'];
$requestTypeValue = $value['RequestType'];
$AgentSysId = $value['AgentSysId'];
$ChangeRequestId = $value['ChangeRequestId'];
$RefundMode = $value['RefundMode'];
$APIResponseData = json_decode($value['APIResponseData'], 1);
$RequestData = json_decode($value['RequestData'], 1);
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$ModificationId = $value['ModificationId'];
$servicefee = isset($value['servicefee']) ? $value['servicefee'] : 0;
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataByCron($value['TPSysId']);
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$AgencyName = $arrCustomerInvoiceData[0]['AgentAgencyName'];
$AgencySysId = $arrCustomerInvoiceData[0]['AgencySysId'];
$DataPost_ = isset($APIResponseData['DataPost']) ? $APIResponseData['DataPost'] : '';
$guid_ = isset($APIResponseData['guid']) ? $APIResponseData['guid'] : '';
$AmendmentCharges = $RequestData;
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$BookingDetails = [];
if ($arrCustomerInvoiceData) {
foreach ($arrCustomerInvoiceData as $keys => $booking) {
$arrAPIBookingRes = json_decode($booking['APIBookingRes'], true);
if (is_array($arrAPIBookingRes)) {
$arrAPIBookingRes = $arrAPIBookingRes;
} else {
$arrAPIBookingRes = json_decode($arrAPIBookingRes, true);
}
$travellerInfos = $arrAPIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
$strTicketPNRLCC = isset($arrAPIBookingRes['response']['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $arrAPIBookingRes['response']['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
$finalpnr = [];
foreach ($arrAPIBookingRes['value']['Segments'] as $keyss => $Segments) {
$originAirportCode = $Segments['originAirportCode'];
$destinationAirportCode = $Segments['destinationAirportCode'];
$segCodeAtt[] = $AirportCode = $originAirportCode . '-' . $destinationAirportCode;
$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
}
$PNRNew = !empty($finalpnr) ? implode(',', $finalpnr) : '';
$BookingDetails[] = array(
'FromTo' => $booking['SourceAirportCode'],
'To' => $booking['DestAirportCode'],
'PNR' => $PNRNew,
);
}
}
$data = array(
"amendmentId" => $value['ChangeRequestId'],
"BookingId" => $BookingId,
);
$ChangeResponse = GetAmendmentDetails($data, $value['AgencySysId']);
//$ChangeResponse = json_decode('{"bookingId":"TJS108300102311","amendmentId":"TJA3324734947","amendmentStatus":"SUCCESS","refundableAmount":602,"trips":[{"src":"DEL","dest":"BOM","departureDate":"2021-08-31T11:30","flightNumbers":["2871"],"airlines":["SG"],"travellers":[{"fn":"prashant","ln":"gupta","amendmentCharges":3567.7,"refundableamount":602,"totalFare":4169.7}]}],"status":{"success":true,"httpStatus":200}}', true);
$intChangeRequestStatus = $ChangeResponse['status']['success'];
$refundableAmount__ = isset($ChangeResponse['refundableAmount']) ? $ChangeResponse['refundableAmount'] : 0;
$amendmentcharges = 0;
$amountCostToAgent = ($refundableAmount__ - $servicefee);
if ($amountCostToAgent > 0) {
$amountCostToAgent = $amountCostToAgent;
} else {
$amountCostToAgent = 0;
}
try {
if ($intChangeRequestStatus == 1) {
if ($ChangeResponse['trips']) {
foreach ($ChangeResponse['trips'] as $i => $val) {
foreach ($val['travellers'] as $pass) {
$amendmentcharges += ($pass['amendmentCharges']);
}
}
}
/// ######## Quicksum Booking Push API code #######################
$finalRespone = [];
$finalPostValue = [];
if ($AgencySysId == '6134') { // '6134'
$totalPas = count($DataPost_);
if ($DataPost_) {
foreach ($DataPost_ as $key => $PostValue) {
$PostValue['RefundRequestId'] = $ChangeResponse['amendmentId'];
$PostValue['RefundAmount'] = number_format((($amountCostToAgent / $totalPas)), 2, '.', '');
try {
$inputKey = '0E2CBEB29CFD40E8820AA3EFC758E9D4';
$iv = 'quicksun6534632#';
$aes = new Travel_Model_Encrytion(json_encode($PostValue), $inputKey, $iv);
$finalRequest = array(
"EncryptedValue" => base64_encode($aes->encrypt()),
"ClientNameUserId" => $AgencyName,
"TransactionId" => $guid_
);
$curl_p = curl_init('http://103.234.184.56/HelloGTX_TripJackAPI/api/gtxflightbooking/bookingcancellation');
//$curl_p = curl_init('http://182.71.94.67/helloGTXTravelAPIDev/api/gtxflightbooking/bookingcancellation'); // Test
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, json_encode($finalRequest));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
curl_setopt($curl_p, CURLOPT_HTTPHEADER, array(
"cache-control: no-cache",
"content-type: application/json"
));
$response = curl_exec($curl_p);
curl_close($curl_p);
$APIresponse = json_decode($response, true);
$APIStatus = isset($APIresponse['EncryptedValue']) ? $APIresponse['EncryptedValue'] : "";
$Message = isset($APIresponse['Message']) ? $APIresponse['Message'] : "";
if ($APIStatus) {
$aes1 = new Travel_Model_Encrytion(base64_decode($APIStatus), $inputKey, $iv);
$decrypt = $aes1->decrypt();
$finalRespone[$key] = $finalRespone_ = json_decode($decrypt, 1);
$TransactionStatus = isset($finalRespone_['TransactionStatus']) ? $finalRespone_['TransactionStatus'] : 0;
$logParams = [
"user_id" => 1,
"AgencySysId" => $AgencySysId,
"custom_error" => ($TransactionStatus == 1) ? "Qcuicksun Refund Success" : "Qcuicksun Refund failed",
'error' => $Message,
"text_udf" => ['response' => $finalRespone_], // Response
"char_udf" => ['request' => $PostValue], // Request
"udf1" => $BookingId,
"status" => ($TransactionStatus == 1) ? 2 : 1,
];
CreateLogs($logParams);
} else {
$logParams = [
"user_id" => 1,
"AgencySysId" => $AgencySysId,
"custom_error" => "Qcuicksun Refund failed",
'error' => $Message,
"text_udf" => ['response' => $APIresponse], // Response
"char_udf" => ['request' => $PostValue], // Request
"udf1" => $BookingId,
"status" => 1,
];
CreateLogs($logParams);
}
$finalPostValue[$key] = $PostValue;
} catch (Exception $error) {
$logParams = [
"user_id" => 1,
"custom_error" => "Error Qcuicksun Cancellation",
'error' => '',
"text_udf" => ['response' => $error->getMessage()], // Response
"char_udf" => ['request' => []], // Request
"udf1" => $BookingId,
"status" => 1,
];
CreateLogs($logParams);
}
}
}
}
// echo "<pre>";
// print_r($ChangeResponse);
// die('www');
if (isset($arrtravellerList) && !empty($arrtravellerList)) {
$UpdateData = array(
"status" => 1,
);
$objFlight->updateModification($UpdateData, $ModificationId);
$ChangeResponse['QuicksunResponse'] = $finalRespone;
$ChangeResponse['QuicksunRequest'] = $finalPostValue;
$dataModification = array(
"ChangeRequestId" => $ChangeResponse['amendmentId'],
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $BookingId,
"RequestType" => $requestTypeValue,
"Remarks" => $cRemarks,
"RequestData" => json_encode($RequestData),
"APIResponseData" => json_encode($ChangeResponse),
"servicefee" => ($servicefee),
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"RefundMode" => $RefundMode,
"refundedamount" => $amountCostToAgent,
"amendmentcharges" => $amendmentcharges,
"status" => 19,
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
$objFlight->insertFlightModification($dataModification);
$updateTP['StatusType'] = 19;
$updateTP['ChangeRequestId'] = $ChangeResponse['amendmentId'];
$updateTP['ChangeRequestStatus'] = 1;
$objFlight->updateBookingStatusTravelPlan($updateTP, $intTPSysId, $MasterTPSysId);
// foreach ($arrtravellerList as $key => $value) {
// if (isset($PaxDetails[$key]) && !empty($PaxDetails[$key])) {
// $data = array(
// "ChangeRequestId" => $ChangeResponse['amendmentId'],
// "ChangeRequestStatus" => 1,
// "ChangeRequestRes" => json_encode($ChangeResponse)
// );
// $objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
// }
// }
}
echo "<pre>";
print_r(json_encode($ChangeResponse));
echo "************************<br>";
} else {
$logParams = [
"user_id" => 1,
"custom_error" => "Error TJ Amendment Details",
'error' => '',
"text_udf" => ['response' => $ChangeResponse], // Response
"char_udf" => ['request' => $data], // Request
"udf1" => $BookingId,
"status" => 1,
];
CreateLogs($logParams);
echo "<pre>";
print_r(json_encode($ChangeResponse));
echo "************************<br>";
}
} catch (Exception $e) {
$logParams = [
"user_id" => 1,
"custom_error" => "Error Update Cancellation",
'error' => '',
"text_udf" => ['response' => $e->getMessage()], // Response
"char_udf" => ['request' => []], // Request
"udf1" => $BookingId,
"status" => 1,
];
CreateLogs($logParams);
print_r($e->getMessage());
exit;
}
} catch (Zend_Exception $ex) {
$ex->getMessage();
$Return = array('success' => false, 'message' => 'failed to update cancellation. try again.');
echo json_encode($Return);
exit;
}
}
}
}
function GetFullUrl()
{
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
$host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
$uri = $protocol . '://' . $host . $s['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
return $url;
}
function CreateLogs($data)
{
$requests = $data;
$data = [
"user_id" => isset($data['user_id']) ? $data['user_id'] : 1,
"agency_sys_id" => isset($data['AgencySysId']) ? $data['AgencySysId'] : '',
"application_name" => $_SERVER['HTTP_HOST'],
"site_url" => GetFullUrl(),
"module_name" => 'Cronjob',
"controller_name" => 'FlightUpdate',
"action_name" => 'UpdateCancel',
"custom_error" => isset($data['custom_error']) ? $data['custom_error'] : '',
"error" => isset($data['error']) ? $data['error'] : '',
"ip_address" => $_SERVER['REMOTE_ADDR'],
"text_udf" => isset($data['text_udf']) ? json_encode($data['text_udf']) : '', // Response
"char_udf" => isset($data['char_udf']) ? json_encode($data['char_udf']) : '', // Request
"udf1" => isset($data['udf1']) ? $data['udf1'] : '',
"udf2" => isset($data['udf2']) ? $data['udf2'] : '',
"status" => isset($data['status']) ? $data['status'] : 1, //
"created_on" => date('Y-m-d H:i:s'),
"updated_on" => date('Y-m-d H:i:s'),
"is_active" => isset($data['is_active']) ? $data['is_active'] : true, //,
"is_mark_for_delete" => isset($data['is_mark_for_delete']) ? $data['is_mark_for_delete'] : false, //,
];
$url = 'http://logs.hellogtx.com/api/v1/create-logs/';
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
return $response;
}