| 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/gtxapi.hellogtx.com/library/Helper/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Hotel.php
* File Desc. : Hotel helper to including supporting functions/methods for Hotels
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 03 Feb 2025
* ************************************************************* */
class Zend_Controller_Action_Helper_Hotel extends Zend_Controller_Action_Helper_Abstract
{
public $baseUrl;
public $siteName;
private $db;
private $pluginLoader;
public function __construct()
{
$this->pluginLoader = new Zend_Loader_PluginLoader();
$this->db = Zend_Db_Table::getDefaultAdapter();
$BootStrap = $this->config();
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
}
public function config()
{
$front = $this->getFrontController();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
throw new Exception('Unable to find bootstrap');
}
return $bootstrap->getOptions()['bootstrap'];
}
public function calculateNoOfDays($date1, $date2)
{
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365 * 60 * 60 * 24));
$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
$days = ceil(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24)) + 1;
$nightCount = ($days > 1) ? ($days - 1) : 1;
return $nightCount;
}
public function tbocityMaster($keyword = null, $CountryId = 0)
{
$query = urlencode(strtoupper($keyword));
if (!empty(trim($query))) {
$url = 'https://hotels.globaltravelexchange.com/api/v1/tbo-hotel-cities/?keywords=' . $query;
$data = array(
'keywords' => $query
);
$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, "GET");
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);
if (curl_errno($ch)) {
print(curl_error($ch));
exit;
}
curl_close($ch);
$responseData = json_decode($outputH, true);
$FilterData = array_filter($responseData, function ($var) use ($CountryId) {
return ($var['CountryId'] == $CountryId);
});
$FilterData = array_values($FilterData);
return (isset($FilterData[0]) && !empty($FilterData[0]))?$FilterData[0]:[];
}
}
public function HotelCodeMaster($data = null, $AgencySysId = null, $url=null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// new code this
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode("TBOStaticAPITest:Tbo@11530818"),
));
$output = curl_exec($ch);
curl_close($ch);
$responseData = json_decode($output, true);
if (!empty($responseData['Hotels'])) {
$FilterData = array_column($responseData['Hotels'], 'HotelCode');
$array_chunk = array_chunk($FilterData,100);
// echo '<pre>';
// print_r(($array_chunk));
// die;
return (isset($array_chunk) && !empty($array_chunk))?$array_chunk:[];
}
}
public function ARR_SALUTIONTBO()
{
return array("1" => "Mr.", "2" => "Ms.", "3" => "Mrs.", "4" => "Mstr.", "5" => "Miss."
// "1" => "Sr.", // Mr
// "2" => "Sra.", // Ms
// "3" => "Sra.", // Mrs
// "4" => "Srto.", // Mstr (Master - young boy)
// "5" => "Srta." // Miss (young girl)
);
}
public function apiHoteltBookingRESTEL($post, $AgencySysId, $Securitykey)
{
if ($post && $AgencySysId) {
$BookingData = (isset($post['BookingData']) && !empty($post['BookingData'])) ? $post['BookingData'] : [];
$email = (isset($post['BookingData']['email']) && !empty($post['BookingData']['email'])) ? $post['BookingData']['email'] : '';
$mobile = (isset($post['BookingData']['mobile']) && !empty($post['BookingData']['mobile'])) ? $post['BookingData']['mobile'] : '';
$HotelCode = (isset($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode']) && !empty($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'])) ? $post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'] : '';
$booking_room_data = (isset($BookingData['HotelBookingData']['booking_room_data']) && !empty($BookingData['HotelBookingData']['booking_room_data'])) ? $BookingData['HotelBookingData']['booking_room_data'] : [];
$HotelPassenger = [];
$bookingCode = [];
$ARR_SALUTIONTBO = $this->ARR_SALUTIONTBO();
// echo "post<pre>";print_r(json_encode($post));die("post");
if($booking_room_data){
foreach($booking_room_data as $roomKey => $roomVal){
$bookingCode[]['lin'] = isset($roomVal['TraceId']) ? $roomVal['TraceId'] : [];
foreach($roomVal['customer'] as $keyC => $customerVal){
$paxTitle = $ARR_SALUTIONTBO[$customerVal['Salutation']];
$HotelPassenger["paxes"][$roomKey]["pax"][$keyC] = [
'titulo' => trim($paxTitle),
'nombrePax' => $customerVal['FirstName'],
'apellidos' => $customerVal['LastName'],
'edad' => isset($customerVal['Age']) ? $customerVal['Age'] : 20,
];
}
}
}
// echo "bookingCode<pre>";print_r($bookingCode);die;
$bookingrequest = [
"peticion" => [
"nombre" => "Servicio de pre-reserva",
"agencia" => "Agencia prueba",
"tipo" => "202",
"parametros" => array_merge_recursive([
"codigo_hotel" => $HotelCode,
"nombre_cliente" => "CATABATIC TECHNOLOGY PRIVADA LIMITADA XML",
"email" => $email,
"telefono" => $mobile,
"observaciones" => "Observaciones test",
"num_expediente" => "00000000",
"forma_pago" => "44",
"res" => array_values(array_unique($bookingCode)),
// "paxes" => ["pax" => $HotelPassenger],
], $HotelPassenger)
]
];
// echo "bookingrequest<pre>";print_r(json_encode($bookingrequest));die("bookingrequest====");
$AdditionalInfor = [
"peticion" => [
"nombre" => "Observaciones hoteles",
"agencia" => "Agencia Prueba",
"tipo" => "24",
"parametros" => $bookingCode
]
];
$data = array('status' => true, 'message' => 'success', 'AdditionalInfor' => $AdditionalInfor, 'bookingrequest' => $bookingrequest);
return ($data);
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
public function apiHoteltBookingHOTELBEDS($post, $AgencySysId, $Securitykey)
{
if ($post && $AgencySysId) {
$BookingData = (isset($post['BookingData']) && !empty($post['BookingData'])) ? $post['BookingData'] : [];
$email = (isset($post['BookingData']['email']) && !empty($post['BookingData']['email'])) ? $post['BookingData']['email'] : '';
$mobile = (isset($post['BookingData']['mobile']) && !empty($post['BookingData']['mobile'])) ? $post['BookingData']['mobile'] : '';
$HotelCode = (isset($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode']) && !empty($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'])) ? $post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'] : '';
$booking_room_data = (isset($BookingData['HotelBookingData']['booking_room_data']) && !empty($BookingData['HotelBookingData']['booking_room_data'])) ? $BookingData['HotelBookingData']['booking_room_data'] : [];
$HolderFirstName = (isset($booking_room_data[0]['customer'][0]['FirstName']) && !empty($booking_room_data[0]['customer'][0]['FirstName'])) ? $booking_room_data[0]['customer'][0]['FirstName'] : '';
$HolderLastName = (isset($booking_room_data[0]['customer'][0]['LastName']) && !empty($booking_room_data[0]['customer'][0]['LastName'])) ? $booking_room_data[0]['customer'][0]['LastName'] : '';
$rooms = [];
if($booking_room_data){
foreach($booking_room_data as $roomKey => $roomVal){
$rooms[$roomKey]['rateKey'] = isset($roomVal['RoomTypeCode']) ? $roomVal['RoomTypeCode'] : [];
foreach($roomVal['customer'] as $keyC => $customerVal){
$rooms[$roomKey]['paxes'][$keyC] = [
"roomId" => 1,
"type" => ($customerVal['paxType'] == 1) ? "AD" : "CH",
"name" => $customerVal['FirstName'],
"surname" => $customerVal['LastName'],
];
}
}
}
$bookingrequest = [
"holder" => ["name" => $HolderFirstName, "surname" => $HolderLastName],
"rooms" => $rooms,
"clientReference" => "IntegrationAgency",
"remark" => "Booking remarks are to be written here."
];
return ($bookingrequest);
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
function getHttpRequestArray($data, $url, $AgencySysId = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
public function apiHttpRequest($Request, $url, $Securitykey)
{
if ($Request) {
$data_stringh = json_encode($Request);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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',
'SecurityKey: ' . $Securitykey,
// 'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
return $response;
} else {
return $response = [];
}
exit;
}
public function httpBuildQuery($Request,$url)
{
if ($Request) {
$jsonEncode = http_build_query($Request);
$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_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($jsonEncode));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'SecurityKey: ' . SECURITYKEY,
'Content-Length: ' . strlen($jsonEncode),
));
$outputH = curl_exec($ch);
// print_r($outputH);die;
$response = json_decode($outputH, true);
return $response;
} else {
return $response = [];
}
exit;
}
}