| 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/application/controllers/ |
Upload File : |
<?php
/**
* Class Flight
*
* @name Flight
* @author Praveen Kumar
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Flight Related function
*
*/
class FlightController extends Catabatic_ValidateGtx {
private $SMSURL;
private $SMSMETHOD;
private $SMSAPIKEY;
private $SMSSENDER;
private $SMSFORMAT;
private $intLoggedinUserId = '';
private $intLoggedinAgencyId = '';
public $baseUrl = '';
public function init() {
parent::init();
error_reporting(1);
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->view->headScript()->appendFile($this->baseUrl . '/public/js/flight/flight.js');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->SMSURL = Catabatic_Helper::getSMSURL();
$this->SMSMETHOD = Catabatic_Helper::getSMSMETHOD();
$this->SMSAPIKEY = Catabatic_Helper::getSMSAPIKEY();
$this->SMSSENDER = Catabatic_Helper::getSMSSENDER();
$this->SMSFORMAT = Catabatic_Helper::getSMSFORMAT();
//Zend_Session::rememberMe(60 * 60 * 24 * 7);
// marking session as read only locked
$sessionLogin_user->lock();
//echo "==========".$sessionLogin_user->intLoggedinUserAgencySysId;
#get session variable
$this->SupplierTypeSysId = 2;
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserGroupId = $sessionLogin_user->intLoggedinUserGroupSysId;
$this->intLoggedinAgencyId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->intLoggedinUserFirstName = $sessionLogin_user->FirstName;
$this->intLoggedinUserEmailId = $sessionLogin_user->EmailId;
$this->intLoggedinUserContactNo = $sessionLogin_user->ContactNo1;
$this->agencyDetails = $sessionLogin_user->agencyDetails;
$this->IsSMSApi = $sessionLogin_user->agencyDetails['IsSMSApi'];
if (!empty($this->intLoggedinAgencyId)) {
$this->InfoSourceSysId = '2'; // Information Source is Agent //
}
// unlocking read-only lock
if ($sessionLogin_user->isLocked()) {
$sessionLogin_user->unLock();
}
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$this->_crmcustomertravelItenary = new Travel_Model_CRM_CustomerTravelItenary();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$this->_crmcusttravelplanAir = new Travel_Model_CRM_CustomerTravelPlanAir();
$this->_objFlight = new Travel_Model_TblFlight();
$this->paymentMdl = new Payment_Model_Payment();
$this->_crmremarkObj = new Travel_Model_CRM_Remark();
#### Script to send email ####
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->smtpUserName = $aConfig['smtpUserName'];
$this->smtpPassword = $aConfig['smtpPassword'];
$this->smtpPort = $aConfig['smtpPort'];
$this->smtpHost = $aConfig['smtpHost'];
$this->fromEmail = $aConfig['fromEmail'];
$this->fromName = $aConfig['fromName'];
#### Script to send email End ####
$this->BITLYLOGIN = 'gpurwar';
$this->BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
$this->CurrencyRate = 1;
$this->CurrencyTitle = 'INR';
$this->CurrencyId = 1;
}
public function indexAction() {
$objFlight = new Travel_Model_TblFlight();
$objAirline = new Travel_Model_TblAirline();
//get All Airline List
$airlineList = $objAirline->getAirlineList();
$this->view->airlineList = $airlineList;
//Get City List
//$cityList = $objFlight->getInventoryCityList($this->intLoggedinAgencyId);
//$this->view->cityList = $cityList;
//Get Supplier List
$supplierList = $objFlight->getSuppliersList($cityId = '', $this->intLoggedinUserId);
$this->view->supplierList = $supplierList;
//Get Flight Total Seat
$totalResult = $objFlight->getFlightTotalSeat($this->intLoggedinAgencyId);
$this->view->totalResult = $totalResult;
//Get Flight Total Cost
$totalCostResult = $objFlight->getFlightTotalCost($this->intLoggedinAgencyId);
$this->view->totalCostResult = $totalCostResult;
//Get Flight Total Sold Cost
$totalSoldCostResult = $objFlight->getFlightTotalSoldCost($this->intLoggedinAgencyId);
//Get Total Standard Cost
$totalStandardCostResult = $objFlight->getFlightStandardTotalCost($this->intLoggedinAgencyId);
//Get Total Standard Sold Cost
$totalStandardSoldCostResult = $objFlight->getFlightStandardTotalSoldCost($this->intLoggedinAgencyId);
//get Final Total seat cost
$final_total_cost = $totalCostResult['total_cost'] + $totalStandardCostResult;
$this->view->final_total_cost = $final_total_cost;
//Get Final Total Sold Cost
$final_total_sold_cost = $totalSoldCostResult['total_sold_cost'] + $totalStandardSoldCostResult;
$this->view->final_total_sold_cost = $final_total_sold_cost;
//Get Final Unsold Total Cost
$final_total_unsold_cost = $final_total_cost - $final_total_sold_cost;
$this->view->final_total_unsold_cost = $final_total_unsold_cost;
//Start Search Code
$searchArr = array();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if (!empty($getData)) {
if (@$getData['fromCityName'] != "") {
$fromCityName = @$getData['fromCityName'];
} else {
$fromCityName = "";
}
if (@$getData['DestinationId'] != 0) {
$DestinationId = @$getData['DestinationId'];
} else {
$DestinationId = "";
}
if (@$getData['toDestinationId'] != 0) {
$toDestinationId = @$getData['toDestinationId'];
} else {
$toDestinationId = "";
}
if (@$getData['toCityName'] != "") {
$toCityName = @$getData['toCityName'];
} else {
$toCityName = "";
}
if (@$getData['date'] != 0) {
$date = $getData['date'];
} else {
$date = "";
}
if (@$getData['supplierId'] != 0) {
$supplierId = $getData['supplierId'];
} else {
$supplierId = "";
}
if (@$getData['airlineId'] != 0) {
$airlineId = $getData['airlineId'];
} else {
$airlineId = "";
}
$searchArr = array(
'isWay' => @$getData['isWay'],
'fromCityName' => @$getData['fromCityName'],
'toCityName' => @$getData['toCityName'],
'DestinationId' => $DestinationId,
'toDestinationId' => $toDestinationId,
'date' => $date,
'supplierId' => $supplierId,
'airlineId' => $airlineId
);
}
} else {
$isWay = $this->_getParam('isWay');
$fromCityName = $this->_getParam('fromCityName');
$toCityName = $this->_getParam('toCityName');
$DestinationId = $this->_getParam('DestinationId');
$toDestinationId = $this->_getParam('toDestinationId');
$date = $this->_getParam('date');
$supplierId = $this->_getParam('supplierId');
$airlineId = $this->_getParam('airlineId');
if ($DestinationId != 0) {
$DestinationId = $DestinationId;
} else {
$DestinationId = "";
}
if ($toDestinationId != 0) {
$toDestinationId = $toDestinationId;
} else {
$toDestinationId = "";
}
if ($date != 0) {
$date = $date;
} else {
$date = "";
}
if ($supplierId != 0) {
$supplierId = $supplierId;
} else {
$supplierId = "";
}
if ($airlineId != 0) {
$airlineId = $airlineId;
} else {
$airlineId = "";
}
$searchArr = array(
'isWay' => $isWay,
'fromCityName' => $fromCityName,
'toCityName' => $toCityName,
'DestinationId' => $DestinationId,
'toDestinationId' => $toDestinationId,
'date' => $date,
'supplierId' => $supplierId,
'airlineId' => $airlineId
);
}
//echo "<pre>"; print_r($searchArr);
//$objFlight->searchArr = $searchArr;
$this->view->searchArr = $searchArr;
$flightList = $objFlight->getAllFlightList($this->intLoggedinAgencyId, $searchArr);
//echo "<pre>"; print_r($flightList); die;
//$this->view->flightList = $flightList;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($flightList);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(10); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
//For display message
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function saveFlightInventoryAction() {
$this->_helper->layout->disableLayout();
$this->_helper->flashMessenger->addMessage("Flight Inventory saved successfully.");
$this->_helper->redirector('index', 'flight', 'default');
}
public function getTocityAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strCityName = $this->getRequest()->getParam('term');
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getCityList($strCityName);
//echo "<pre>";print_r($result);die;
echo $this->_helper->json($result);
exit;
}
}
public function getFromcityAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strCityName = $this->getRequest()->getParam('term');
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getCityList($strCityName);
//echo "<pre>";print_r($result);die;
echo $this->_helper->json($result);
exit;
}
}
public function getFlightAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strFlightNo = $this->getRequest()->getParam('term');
$strFlightDate = $this->getRequest()->getParam('flightDate');
$strMode = $this->getRequest()->getParam('mode');
$strModeType = $this->getRequest()->getParam('modeType');
$strFlightDateOnward = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strFlightDate, 'd/m/y');
//echo $strFlightNo;
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getFlightList($strFlightNo, $strFlightDateOnward, $strMode, $strModeType);
//echo "<pre>";print_r($result);
//echo count($result); die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo $this->_helper->json($result);
exit;
}
}
public function getairlinenameAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$airlineID = $this->getRequest()->getParam('airlineID');
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getAirline($airlineID);
$title = $result[0]['Title'];
echo $title;
}
public function getFlightAutoSearchByoAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strFlightNo = $this->getRequest()->getParam('term');
$strFlightDate = $this->getRequest()->getParam('flightDate');
$strMode = $this->getRequest()->getParam('mode');
$strModeType = $this->getRequest()->getParam('modeType');
$strFlightDateOnward = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strFlightDate, 'd/m/y');
//echo $strFlightNo;
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getFlightListBYO($strFlightNo, $strFlightDateOnward, $strMode, $strModeType);
//echo "<pre>";print_r($result);
//echo count($result); die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo $this->_helper->json($result);
exit;
}
}
public function getFlightChangeDetailsAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$FlightNumber = $this->getRequest()->getParam('FlightNumber');
$OnwardSourcePlaceId = $this->getRequest()->getParam('OnwardSourcePlaceId');
$OnwardDestinationPlaceId = $this->getRequest()->getParam('OnwardDestinationPlaceId');
//echo $strFlightNo; exit;
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getFlightChangeDetailsList($FlightNumber, $OnwardSourcePlaceId, $OnwardDestinationPlaceId);
//echo "<pre>";print_r($result);
//echo count($result); die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo json_encode($result);
exit;
}
}
public function addFlightAction() {
$this->_helper->layout->disableLayout();
$this->view->fType = $this->getRequest()->getParam('key');
$objFlight = new Travel_Model_TblFlight();
$objAirline = new Travel_Model_TblAirline();
//Get Airline List
$arrAirlineList = $objAirline->getAirlineList();
$this->view->arrAirlineList = $arrAirlineList;
//Get Place List
$arrPlaceList = $objFlight->getAllPlacelList();
//echo "<pre>";print_r($arrPlaceList); die;
$this->view->arrPlaceList = $arrPlaceList;
}
public function saveFlightAction() {
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Call Flight Model
$objFlight = new Travel_Model_TblFlight();
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
if (empty($this->intLoggedinUserId)) {
throw new Exception('There has been an error, Please try again later');
}
/* For Flight Connecting */
if (!empty($post)) {
$FlightNumber = isset($post['FlightNumber']) ? $post['FlightNumber'] : '';
$airline_id = isset($post['airline_id']) ? $post['airline_id'] : '0';
$airline_code = isset($post['airline_code']) ? $post['airline_code'] : '';
$from_date = isset($post['from_date']) ? $post['from_date'] : '';
$to_date = isset($post['to_date']) ? $post['to_date'] : '';
$IsDirect = isset($post['IsDirect']) ? $post['IsDirect'] : '0';
$FlyingMinutes = isset($post['FlyingMinutes']) ? $post['FlyingMinutes'] : '';
$SourcePlaceSysId = isset($post['SourcePlaceSysId']) ? $post['SourcePlaceSysId'] : '';
$DestPlaceSysId = isset($post['DestPlaceSysId']) ? $post['DestPlaceSysId'] : '';
$StopCount = isset($post['StopCount']) ? $post['StopCount'] : '0';
$Stops = isset($post['Stops']) ? json_encode($post['Stops']) : ''; //isset($post['Stops']) ? $post['Stops'] : '';
$localFromDateTime = @date("Y-m-d h:i", strtotime($from_date));
$localToDateTime = @date("Y-m-d h:i", strtotime($to_date));
//Fixed variables
$soursePlaceDetails = $objFlight->getPlacelDetailsByPlaceId($SourcePlaceSysId);
if ($soursePlaceDetails['Code'] != "") {
$SourceAirportCode = $soursePlaceDetails['Code'];
} else {
$SourceAirportCode = "";
}
$destiPlaceDetails = $objFlight->getPlacelDetailsByPlaceId($DestPlaceSysId);
if ($destiPlaceDetails['Code'] != "") {
$DestAirportCode = $destiPlaceDetails['Code'];
} else {
$DestAirportCode = "";
}
$ICSourceSysId = 3; // 3 For TBO
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
} else {
throw new Exception('There has been an error, Please try again later');
}
if (empty($FlightNumber)) {
$response = array('success' => false, 'msg' => 'Please enter flight number');
echo json_encode($response);
exit;
}
if ($airline_id == 0) {
$response = array('success' => false, 'msg' => 'Please enter airline');
echo json_encode($response);
exit;
}
/* Check if connecting flight already exists */
// $arrFlightConnecting = $objFlight->getCustomizedMarkups($InvnItemSysId,$this->intLoggedinUserId );
//
// if(!empty($arrFlightConnecting) > 0 ) {
// $response = array('success' => false, 'msg' => 'Connecting flight of the selected airlines has already been added.');
// echo json_encode($response);
// exit;
// }
$insert = array(
'FlightNumber' => $FlightNumber,
'AirlineSysId' => $airline_id,
'ICSourceSysId' => $ICSourceSysId,
'IsFromAgency' => $IsFromAgency,
'LocalFromTime' => $localFromDateTime,
'FromUTCTime' => $from_date,
'LocalToTime' => $localToDateTime,
'ToUTCTime' => $to_date,
'IsDirect' => $IsDirect,
'DayLightSavingDiff' => $DayLightSavingDiff,
'FlyingMinutes' => $FlyingMinutes,
'SourcePlaceSysId' => $SourcePlaceSysId,
'DestPlaceSysId' => $DestPlaceSysId,
'SourceAirportCode' => $SourceAirportCode,
'DestAirportCode' => $DestAirportCode,
'AirportHaultMinutes' => $AirportHaultMinutes,
'StopCount' => $StopCount,
'Stops' => $Stops,
'Rating' => $Rating,
'FllightFeatureMask' => $FllightFeatureMask,
'UpdatedByISSysId' => $UpdatedByISSysId,
'CreatedByISSysId' => $CreatedByISSysId,
'ImageTN' => $ImageTN,
'ImgForList' => $ImgForList,
'ImgeDetails' => $ImgeDetails,
'UpdateDate' => $UpdateDate,
'CreateDate' => $CreateDate,
'ApproveBy' => $ApproveBy,
'ApprovalDate' => $ApprovalDate,
'IsApproved' => $IsApproved,
'IsActive' => $IsActive,
'IsMarkForDel' => $IsMarkForDel
);
// echo "<pre>";
// print_r($insert);
// exit;
try {
$newAirInvenSysId = $objFlight->addFlightDetails($insert);
$newAirInvenSysDetails = $objFlight->getAirInvenSysDetails($newAirInvenSysId);
$response = array('success' => 'Flight saved successfully', 'AirInvenSysDetails' => $newAirInvenSysDetails);
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
}
public function getAirlineAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strAirline = $this->getRequest()->getParam('term');
//echo $strFlightNo; exit;
$result = array();
$objAirline = new Travel_Model_TblAirline();
$result = $objAirline->getAirlineAutoSearchList($strAirline);
//echo "<pre>";print_r($result);die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo $this->_helper->json($result);
exit;
}
}
public function getFlightSourcePlaceListByoAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$flightId = $this->getRequest()->getParam('FlightNumber');
$arrFlightSourcePlaceList = $objFlight->getFlightSourcePlaceListBYO($flightId);
//echo "<pre>";print_r($arrFlightSourcePlaceList);
$sourcePlaceSelect = '';
if (!empty($arrFlightSourcePlaceList)) {
$sourcePlaceSelect = '<option value="">Select</option>';
foreach ($arrFlightSourcePlaceList as $arrFlightSourcePlace) {
$DepartureTime = (array) $arrFlightSourcePlace['DepartureTime'];
$source_des_time = date("d M Y ,H:i", strtotime($DepartureTime['date']));
$sourceDesSelectName = $arrFlightSourcePlace['Title'] . ' (' . $source_des_time . ')';
$sourcePlaceSelect .= '<option value="' . $arrFlightSourcePlace['PlaceSysId'] . '">' . $sourceDesSelectName . '</option>';
}
}
echo $sourcePlaceSelect;
exit;
}
}
public function getFlightSourcePlaceListAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$flightId = $this->getRequest()->getParam('FlightNumber');
$arrFlightSourcePlaceList = $objFlight->getFlightSourcePlaceList($flightId);
//echo "<pre>";print_r($arrFlightSourcePlaceList);
$sourcePlaceSelect = '';
if (!empty($arrFlightSourcePlaceList)) {
$sourcePlaceSelect = '<option value="">Select</option>';
foreach ($arrFlightSourcePlaceList as $arrFlightSourcePlace) {
$DepartureTime = (array) $arrFlightSourcePlace['DepartureTime'];
$source_des_time = date("H:i", strtotime($DepartureTime['date']));
$sourceDesSelectName = $arrFlightSourcePlace['Title'] . ' (' . $source_des_time . ')';
$sourcePlaceSelect .= '<option value="' . $arrFlightSourcePlace['PlaceSysId'] . '">' . $sourceDesSelectName . '</option>';
}
}
echo $sourcePlaceSelect;
exit;
}
}
public function getFlightDestinationPlaceListByoAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$FlightNumber = $this->getRequest()->getParam('FlightNumber');
$arrFlightDestinationPlaceList = $objFlight->getFlightDestinationPlaceListBYO($FlightNumber);
$destinationPlaceSelect = '';
if (!empty($arrFlightDestinationPlaceList)) {
$destinationPlaceSelect = '<option value="">Select</option>';
foreach ($arrFlightDestinationPlaceList as $arrFlightDestinationPlace) {
$ArrivalTime = (array) $arrFlightDestinationPlace['ArrivalTime'];
$source_des_time = date("d M Y ,H:i", strtotime($ArrivalTime['date']));
$sourceDesSelectName = $arrFlightDestinationPlace['Title'] . ' (' . $source_des_time . ')';
$destinationPlaceSelect .= '<option value="' . $arrFlightDestinationPlace['PlaceSysId'] . '">' . $sourceDesSelectName . '</option>';
}
}
echo $destinationPlaceSelect;
exit;
}
}
public function getFlightDestinationPlaceListAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$FlightNumber = $this->getRequest()->getParam('FlightNumber');
$arrFlightDestinationPlaceList = $objFlight->getFlightDestinationPlaceList($FlightNumber);
$destinationPlaceSelect = '';
if (!empty($arrFlightDestinationPlaceList)) {
$destinationPlaceSelect = '<option value="">Select</option>';
foreach ($arrFlightDestinationPlaceList as $arrFlightDestinationPlace) {
$ArrivalTime = (array) $arrFlightDestinationPlace['ArrivalTime'];
$source_des_time = date("H:i", strtotime($ArrivalTime['date']));
$sourceDesSelectName = $arrFlightDestinationPlace['Title'] . ' (' . $source_des_time . ')';
$destinationPlaceSelect .= '<option value="' . $arrFlightDestinationPlace['PlaceSysId'] . '">' . $sourceDesSelectName . '</option>';
}
}
echo $destinationPlaceSelect;
exit;
}
}
public function viewFlightInventoryBulkFormAction() {
$this->_helper->layout->setLayout('newLayout');
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Get Currency List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
//Get Supplier List
//$objSupplier = new Travel_Model_TblSupplier();
//$this->view->arrSupplierTypes = $objSupplier->getSupplierList();
//Get Country List
$objCountry = new Travel_Model_TblCountry();
$this->view->arrCountryList = $objCountry->getCountryList();
}
}
public function viewFlightInventoryBulkEditFormAction() {
$this->_helper->layout->setLayout('newLayout');
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$InvnItemSysId = base64_decode($this->getRequest()->getParam('InvnItemSysId'));
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$FromDateTimeObj = (array) $arrFlightInventoryDetails['FromDate'];
$source_date_time = date("d/m/Y", strtotime($FromDateTimeObj['date']));
//Get flight time
$arrFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryDetails['XRefFlightSysId'], @$arrFlightInventoryDetails['StartPlaceSysId'], @$arrFlightInventoryDetails['DestPlaceSysId']);
if ($arrFlightInventoryDetails['IsItTwoWay'] == 0) {
$IsItTwoWay = 0;
} else {
$IsItTwoWay = 1;
}
//geet flight departure time
$flightDepartureTime = (array) $arrFlightTimeDetails['DepartureTime'];
$flight_start_time = date("H:i", strtotime(@$flightDepartureTime['date']));
//Get flight arrival time
$flightArrivalTime = (array) $arrFlightTimeDetails['ArrivalTime'];
$flight_desti_time = date("H:i", strtotime(@$flightArrivalTime['date']));
$arrFlightInventoryDetailsArr = array('FromDateFormat' => $source_date_time, 'FlightDepartureTime' => $flight_start_time, 'FlightArrivalTime' => $flight_desti_time);
$arrFlightInventoryDetailsArrFinal = array_merge($arrFlightInventoryDetails, $arrFlightInventoryDetailsArr);
$arrFlightInventoryIswayDetailsFinal = array();
if ($arrFlightInventoryDetails['IsItTwoWay'] == 1 && $arrFlightInventoryDetails['PairItemSysId'] != 0) {
$arrFlightInventoryIswayDetails = $objFlight->getAllFlightInventoryDetailsList($arrFlightInventoryDetails['PairItemSysId'], $this->intLoggedinAgencyId);
$FromDateTimeInwardObj = (array) $arrFlightInventoryIswayDetails['FromDate'];
$inward_date_time = date("d/m/Y", strtotime($FromDateTimeInwardObj['date']));
//Get flight time
$arrFlightTimeDetailsIsway = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryIswayDetails['XRefFlightSysId'], @$arrFlightInventoryIswayDetails['StartPlaceSysId'], @$arrFlightInventoryIswayDetails['DestPlaceSysId']);
//get flight departure time
$flightDepartureTimeIsway = (array) $arrFlightTimeDetailsIsway['DepartureTime'];
$flight_start_time_isway = date("H:i", strtotime(@$flightDepartureTimeIsway['date']));
//Get flight arrival time
$flightArrivalTimeIsway = (array) $arrFlightTimeDetailsIsway['ArrivalTime'];
$flight_desti_time_isway = date("H:i", strtotime(@$flightArrivalTimeIsway['date']));
$arrFlightInventoryIswayDetailsArr = array('InwardFromDateFormat' => $inward_date_time, 'InwardFlightDepartureTime' => $flight_start_time_isway, 'InwardFlightArrivalTime' => $flight_desti_time_isway);
$arrFlightInventoryIswayDetailsFinal = array_merge($arrFlightInventoryIswayDetails, $arrFlightInventoryIswayDetailsArr);
//$response = array('IsItTwoWayCheck'=>1, 'parentArr' => $arrFlightInventoryDetailsArrFinal,'isWayArr'=>$arrFlightInventoryIswayDetailsFinal);
//echo "<pre>"; print_r($response);die;
//$this->view->flightDetails = $response;
//echo json_encode($response);
//exit;
}
$response = array('IsItTwoWayCheck' => $IsItTwoWay, 'parentArr' => $arrFlightInventoryDetailsArrFinal, 'isWayArr' => $arrFlightInventoryIswayDetailsFinal);
$this->view->flightDetails = $response;
//echo "<pre>"; print_r($response);die;
}
}
public function getSupplierAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strSupplierName = ($this->getRequest()->getParam('term') != '') ? $this->getRequest()->getParam('term') : $this->getRequest()->getParam('query');
$strtype = $this->getRequest()->getParam('type');
//echo $strFlightNo; exit;
$result = array();
$objSupplier = new Travel_Model_TblSupplier();
$AgentId = $this->intLoggedinUserId;
$SupplierTypeSysId = $this->SupplierTypeSysId;
$agencySysId = $this->intLoggedinAgencyId;
$result = $objSupplier->getSupplierAutoSearchList($strSupplierName, $AgentId, $SupplierTypeSysId, $agencySysId, $strtype);
//echo "<pre>";print_r($result);die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo $this->_helper->json($result);
exit;
}
}
public function getSupplierAutoSearchfullfillmentAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strSupplierName = $this->getRequest()->getParam('term');
$strtype = $this->getRequest()->getParam('type');
//echo $strFlightNo; exit;
$result = array();
$objSupplier = new Travel_Model_TblSupplier();
$AgentId = $this->intLoggedinUserId;
$SupplierTypeSysId = $this->SupplierTypeSysId;
$agencySysId = $this->intLoggedinAgencyId;
$result = $objSupplier->getSupplierAutoSearchListFullfillment($strSupplierName, $AgentId, $SupplierTypeSysId, $agencySysId, $strtype);
//echo "<pre>";print_r($result);die;
// if(count($result) != 1) {
// throw new Exception('There has been a technical error. Please try again later.');
// }
echo $this->_helper->json($result);
exit;
}
}
public function viewFlightInventoryTableAction() {
/* Disable layout */
$this->_helper->layout->disableLayout();
//$this->layout()->headLink()->appendStylesheet('/public/assets/css/style.css');
//$this->view->headScript()->appendFile('/public/assets/css/style.css');
//$this->view->headScript()->appendFile('/public/assets/css/bootstrap.min.css');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getAllFlightInventoryList($this->intLoggedinAgencyId);
$this->view->arrFlightInventoryList = $arrFlightInventoryList;
// echo "<pre>";
// print_r($arrFlightInventoryList);
// exit;
}
public function manageMarkupAction() {
/* Disable layout */
$this->_helper->layout->disableLayout();
$InvnItemSysId = $this->getRequest()->getParam('id');
$key = $this->getRequest()->getParam('key');
$popupType = $this->getRequest()->getParam('popupType');
//echo "dsbfsjdugf sid";
//echo $InvnItemSysId;
//die;
$this->view->key = $key;
$this->view->popupType = $popupType;
$this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('id');
//echo $InvnItemSysId;
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
//echo "<pre>";print_r($arrFlightInventoryList);die;
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
}
public function managePoliciesAction() {
/* Disable layout */
$this->_helper->layout->disableLayout();
$key = $this->getRequest()->getParam('key');
$this->view->key = $key;
$this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('id');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
}
public function manageConnectingAction() {
/* Disable layout */
$this->_helper->layout->disableLayout();
$this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('id');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineList();
$this->view->arrAirlineList = $arrAirlineList;
}
public function getAirportAutoSearchAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strAirport = $this->getRequest()->getParam('term');
//echo $strFlightNo; exit;
$result = array();
$objAirport = new Travel_Model_TblAirport();
$result = $objAirport->getAirportAutoSearchList($strAirport);
//echo "<pre>";print_r($result);die;
if (count($result) != 1) {
throw new Exception('There has been a technical error. Please try again later.');
}
echo $this->_helper->json($result);
exit;
}
}
public function addFlightInventoryAction() {
//Get Currency List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
//Get Supplier List
$objSupplier = new Travel_Model_TblSupplier();
$this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();
if ($this->intLoggedinUserId == ADMIN_ID) {
$this->render('add-flight-inventory-admin');
}
}
public function saveInventoryAction() {
/* Disable layout */
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
/* If ajax request */
if ($this->_request->isXmlHttpRequest()) {
$post = $this->getRequest()->getPost();
//echo "<pre>"; print_r($post); die;
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId') ? $this->getRequest()->getPost('InvnItemSysId') : '';
$is_way = $this->getRequest()->getPost('is_way_flight') ? $this->getRequest()->getPost('is_way_flight') : '';
$is_way_flight_key = $this->getRequest()->getPost('is_way_flight_key') ? $this->getRequest()->getPost('is_way_flight_key') : '';
$intFlightNoOnward = $this->getRequest()->getPost('flight_no_onward') ? $this->getRequest()->getPost('flight_no_onward') : '';
$intFlightId = $this->getRequest()->getPost('onward_flight_id') ? $this->getRequest()->getPost('onward_flight_id') : '';
$intFlightNoInward = $this->getRequest()->getPost('flight_no_inward') ? $this->getRequest()->getPost('flight_no_inward') : '';
$intInWardFlightId = $this->getRequest()->getPost('inward_flight_id') ? $this->getRequest()->getPost('inward_flight_id') : '';
$onward_flight_source_place_id = $this->getRequest()->getPost('onward_flight_source_place_id') ? $this->getRequest()->getPost('onward_flight_source_place_id') : '';
$onward_flight_destination_place_id = $this->getRequest()->getPost('onward_flight_destination_place_id') ? $this->getRequest()->getPost('onward_flight_destination_place_id') : '';
$dateOnward = $this->getRequest()->getPost('date_onward') ? $this->getRequest()->getPost('date_onward') : '';
$dateInward = $this->getRequest()->getPost('date_inward') ? $this->getRequest()->getPost('date_inward') : '';
$strQuantity = $this->getRequest()->getPost('quantity') ? $this->getRequest()->getPost('quantity') : '';
$publish_quantity = $this->getRequest()->getPost('publish_quantity') ? $this->getRequest()->getPost('publish_quantity') : '';
$strCurrencyType = $this->getRequest()->getPost('currency_type') ? $this->getRequest()->getPost('currency_type') : '';
$total_cost = $this->getRequest()->getPost('total_cost') ? $this->getRequest()->getPost('total_cost') : '';
//$supplier_type = $post['supplier_type'] ? $post['supplier_type'] : '';
$intSupplierType = $this->getRequest()->getPost('supplier_type_id') ? $this->getRequest()->getPost('supplier_type_id') : '0';
$inward_flight_source_place_id = $this->getRequest()->getPost('inward_flight_source_place_id') ? $this->getRequest()->getPost('inward_flight_source_place_id') : '';
$inward_flight_destination_place_id = $this->getRequest()->getPost('inward_flight_destination_place_id') ? $this->getRequest()->getPost('inward_flight_destination_place_id') : '';
$strDateOnward = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($dateOnward, 'd/m/y');
$strDateInward = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($dateInward, 'd/m/y');
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$intLoggedinUserId = $this->intLoggedinUserId;
// $agencyDetails = $objAgency->getAgencyUserList($intLoggedinUserId);
// if(!empty($agencyDetails))
// {
// $TrxCurrency = $agencyDetails['TrxCurrency'];
// } else {
// $TrxCurrency = 1;
// }
if ($is_way == 0 && $intFlightId == 0) {
$response = array('success' => false, 'msg' => 'Please enter flight number');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($intFlightId == 0 && $intInWardFlightId == 0)) {
$response = array('success' => false, 'msg' => 'Please enter flight number');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($intFlightId != 0 && $intInWardFlightId == 0)) {
$response = array('success' => false, 'msg' => 'Please enter inward flight number');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($intFlightId == $intInWardFlightId)) {
$response = array('success' => false, 'msg' => 'Flight number should not be same');
echo json_encode($response);
exit;
}
if ($is_way == 0 && $dateOnward == "__/__/____") {
$response = array('success' => false, 'msg' => 'Please enter date');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($dateOnward == "__/__/____" && $dateInward == "__/__/____")) {
$response = array('success' => false, 'msg' => 'Please enter date');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($dateOnward != "__/__/____" && $dateInward == "__/__/____")) {
$response = array('success' => false, 'msg' => 'Please enter inward date');
echo json_encode($response);
exit;
} else if ($is_way == 1 && ($strDateOnward >= $strDateInward)) {
$response = array('success' => false, 'msg' => 'Please select inward date should be greater than onward date');
echo json_encode($response);
exit;
}
if ($is_way == 0) {
if ($is_way == 0 && $onward_flight_source_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select from destination');
echo json_encode($response);
exit;
}
if ($is_way == 0 && $onward_flight_destination_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select to destination');
echo json_encode($response);
exit;
}
if ($is_way == 0 && ($onward_flight_source_place_id == $onward_flight_destination_place_id)) {
$response = array('success' => false, 'msg' => 'Destination should not be same');
echo json_encode($response);
exit;
}
} else if ($is_way == 1) {
if ($is_way == 1 && $onward_flight_source_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select from destination');
echo json_encode($response);
exit;
}
if ($is_way == 1 && $onward_flight_destination_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select to destination');
echo json_encode($response);
exit;
}
if ($is_way == 1 && ($onward_flight_source_place_id == $onward_flight_destination_place_id)) {
$response = array('success' => false, 'msg' => 'Onward flight destination should not be same');
echo json_encode($response);
exit;
}
if ($is_way == 1 && $inward_flight_source_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select inward from destination');
echo json_encode($response);
exit;
}
if ($is_way == 1 && $inward_flight_destination_place_id == "") {
$response = array('success' => false, 'msg' => 'Please select inward to destination');
echo json_encode($response);
exit;
}
if ($is_way == 1 && ($inward_flight_source_place_id == $inward_flight_destination_place_id)) {
$response = array('success' => false, 'msg' => 'Inward flight destination should not be same');
echo json_encode($response);
exit;
}
}
if (empty($strQuantity)) {
$response = array('success' => false, 'msg' => 'Please enter total quantity');
echo json_encode($response);
exit;
}
if (empty($publish_quantity)) {
$response = array('success' => false, 'msg' => 'Please enter publish quantity');
echo json_encode($response);
exit;
} else if ($publish_quantity > $strQuantity) {
$response = array('success' => false, 'msg' => 'Publish Quantity should be less than or equal to total quantity');
echo json_encode($response);
exit;
}
if (empty($total_cost)) {
$response = array('success' => false, 'msg' => 'Please enter total cost');
echo json_encode($response);
exit;
}
if ($intSupplierType == 0) {
$response = array('success' => false, 'msg' => 'Please enter supplier name');
echo json_encode($response);
exit;
}
//echo "<pre>"; print_r($post);die;
if ($is_way_flight_key == "copy") {
if (!empty($InvnItemSysId)) {
$updateCopyData = array(
'PairItemSysId' => '0', 'PurchasedQty' => $strQuantity, 'PurchasedQty' => $strQuantity, 'PublishQty' => $publish_quantity, 'NetInHandQty' => $strQuantity, 'CostCurrency' => $strCurrencyType,
'SupplierSysId' => $intSupplierType, 'TotalCost' => $total_cost, 'StartPlaceSysId' => $onward_flight_source_place_id, 'DestPlaceSysId' => $onward_flight_destination_place_id,
'strDateOnward' => $strDateOnward, 'strDateInward' => $strDateInward, 'inward_flight_source_place_id' => $inward_flight_source_place_id, 'inward_flight_destination_place_id' => $inward_flight_destination_place_id
);
$intNewInvnItemSysId = $objFlight->cloneMPInventoryFlight($InvnItemSysId, $updateCopyData, $intNewInvnItemSysIdMap = 0);
//for the code of inward copy data
if ($is_way == 1) {
$updateFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$PairItemSysId = $updateFlightInventoryDetails['PairItemSysId'];
$intNewInvnItemSysInwardId = $objFlight->cloneMPInventoryFlight($PairItemSysId, $updateCopyData, $intNewInvnItemSysId);
//Get and update is parent id from last insert id
$flightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($intNewInvnItemSysInwardId, $this->intLoggedinAgencyId);
$lastInvnItemSysId = $flightInventoryDetails['PairItemSysId'];
$flightInventoryDetails = $objFlight->updateIsItParentFlight($intNewInvnItemSysInwardId, $lastInvnItemSysId);
}
$response = array('success' => true, 'intLastInsertId' => $intNewInvnItemSysId);
}
} else if ($is_way_flight_key == "edit") {
if (!empty($InvnItemSysId)) {
if ($is_way == 1) {
$updateFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$PairItemSysId = $updateFlightInventoryDetails['PairItemSysId'];
} else {
$PairItemSysId = 0;
}
$updateOnwardData = array(
'InventoryType' => '2', 'XRefFlightSysId' => $intFlightId, 'IsItTwoWay' => $is_way, 'IsItParent' => '0', 'PairItemSysId' => $PairItemSysId,
'AgencySysId' => $this->intLoggedinAgencyId, 'EconomyType' => '1', 'PurchasedQty' => $strQuantity,
'PublishQty' => $publish_quantity, 'BlockQty' => '0', 'SoldQty' => '0',
'ReturnQty' => '0', 'NetInHandQty' => $strQuantity, 'CostCurrency' => $strCurrencyType, 'TrxCurrency' => $this->intLoggedinUserTrxCurrency,
'SupplierSysId' => $intSupplierType, 'TotalCost' => $total_cost, 'SaleAmount' => '0', 'DefaultPrice' => 0,
'Brief' => '', 'IfAnyOffer' => '0', 'OfferMsg' => '', 'OfferImage' => '', 'StartPlaceSysId' => $onward_flight_source_place_id,
'DestPlaceSysId' => $onward_flight_destination_place_id, 'FromDate' => $strDateOnward, 'ToDate' => $strDateOnward, 'SearchTags' => '',
'IxFixedDateInven' => '0', 'CreatorSysId' => $intLoggedinUserId, 'CreateDate' => $currentDate,
'UpdateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDelete' => 0, 'IsApproved' => '1'
);
$objFlight->updateFlightInventory($InvnItemSysId, $updateOnwardData);
if ($is_way == 1) {
$updateFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$PairItemSysId = $updateFlightInventoryDetails['PairItemSysId'];
$updateInwardData = array(
'InventoryType' => '2', 'XRefFlightSysId' => $intInWardFlightId, 'IsItTwoWay' => $is_way, 'IsItParent' => '1', 'PairItemSysId' => $InvnItemSysId,
'AgencySysId' => $this->intLoggedinAgencyId, 'EconomyType' => '1', 'PurchasedQty' => $strQuantity,
'PublishQty' => $publish_quantity, 'BlockQty' => '0', 'SoldQty' => '0',
'ReturnQty' => '0', 'NetInHandQty' => $strQuantity, 'CostCurrency' => $strCurrencyType, 'TrxCurrency' => $this->intLoggedinUserTrxCurrency,
'SupplierSysId' => $intSupplierType, 'TotalCost' => $total_cost, 'SaleAmount' => '0', 'DefaultPrice' => 0,
'Brief' => '', 'IfAnyOffer' => '0', 'OfferMsg' => '', 'OfferImage' => '', 'StartPlaceSysId' => $inward_flight_source_place_id,
'DestPlaceSysId' => $inward_flight_destination_place_id, 'FromDate' => $strDateInward, 'ToDate' => $strDateInward, 'SearchTags' => '',
'IxFixedDateInven' => '0', 'CreatorSysId' => $intLoggedinUserId, 'CreateDate' => $currentDate,
'UpdateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDelete' => 0, 'IsApproved' => '1'
);
$intLastInsertInwardId = $objFlight->updateFlightInventory($PairItemSysId, $updateInwardData);
}
$response = array('success' => true, 'intLastInsertId' => $InvnItemSysId);
}
} else {
//Get Sipplier Masking
if ($intSupplierType != "" && $intSupplierType != 0) {
$objSupplier = new Travel_Model_TblSupplier();
$supplierDetails = $objSupplier->getSupplierList($intSupplierType);
$supplierMasking = $supplierDetails['Services'];
//Get Old Masking Array
$SupplierServicesArrDB = $objSupplier->getSupplierServices(); //Get Supplier Services
$servicesMaskingArr = $objSupplier->getMasking($supplierMasking, $SupplierServicesArrDB, 'SupplierSerSysId');
$ActivitiesSupplierTypeSysIdArr = array($this->SupplierTypeSysId);
$newMaskingArr = array_unique(array_merge($servicesMaskingArr, $ActivitiesSupplierTypeSysIdArr));
//Set new masking string
$supplierServicesNewMasking = $objSupplier->setMasking($newMaskingArr, $SupplierServicesArrDB, 'SupplierSerSysId');
//echo $supplierServicesNewMasking; die;
//Update Masking
$supplierMaskingUpdateArr = array('Services' => $supplierServicesNewMasking);
$objSupplier->updateSupplier($supplierMaskingUpdateArr, $intSupplierType);
}
//Insert data array
$insertOnwardData = array(
'InventoryType' => '2', 'XRefFlightSysId' => $intFlightId, 'IsItTwoWay' => $is_way, 'IsItParent' => '0', 'PairItemSysId' => '0',
'AgencySysId' => $this->intLoggedinAgencyId, 'EconomyType' => '1', 'PurchasedQty' => $strQuantity,
'PublishQty' => $publish_quantity, 'BlockQty' => '0', 'SoldQty' => '0',
'ReturnQty' => '0', 'NetInHandQty' => $strQuantity, 'CostCurrency' => $strCurrencyType, 'TrxCurrency' => $this->intLoggedinUserTrxCurrency,
'SupplierSysId' => $intSupplierType, 'TotalCost' => $total_cost, 'SaleAmount' => '0', 'DefaultPrice' => 0,
'Brief' => '', 'IfAnyOffer' => '0', 'OfferMsg' => '', 'OfferImage' => '', 'StartPlaceSysId' => $onward_flight_source_place_id,
'DestPlaceSysId' => $onward_flight_destination_place_id, 'FromDate' => $strDateOnward, 'ToDate' => $strDateOnward, 'SearchTags' => '',
'IxFixedDateInven' => '0', 'CreatorSysId' => $intLoggedinUserId, 'CreateDate' => $currentDate,
'UpdateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDelete' => 0, 'IsApproved' => '1'
);
//echo "<pre>";print_r($insertOnwardData);
$intLastInsertId = $objFlight->addFlightInventory($insertOnwardData);
//$intLastInsertId = 18;
if ($is_way == 1) {
$insertInwardData = array(
'InventoryType' => '2', 'XRefFlightSysId' => $intInWardFlightId, 'IsItTwoWay' => '1', 'IsItParent' => '1', 'PairItemSysId' => $intLastInsertId,
'AgencySysId' => $this->intLoggedinAgencyId, 'EconomyType' => '1', 'PurchasedQty' => $strQuantity,
'PublishQty' => $publish_quantity, 'BlockQty' => '0', 'SoldQty' => '0',
'ReturnQty' => '0', 'NetInHandQty' => $strQuantity, 'CostCurrency' => $strCurrencyType, 'TrxCurrency' => $this->intLoggedinUserTrxCurrency,
'SupplierSysId' => $intSupplierType, 'TotalCost' => $total_cost, 'SaleAmount' => '0', 'DefaultPrice' => 0,
'Brief' => '', 'IfAnyOffer' => '0', 'OfferMsg' => '', 'OfferImage' => '', 'StartPlaceSysId' => $inward_flight_source_place_id,
'DestPlaceSysId' => $inward_flight_destination_place_id, 'FromDate' => $strDateInward, 'ToDate' => $strDateInward, 'SearchTags' => '',
'IxFixedDateInven' => '0', 'CreatorSysId' => $intLoggedinUserId, 'CreateDate' => $currentDate,
'UpdateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDelete' => 0, 'IsApproved' => '1'
);
//echo "<pre>";print_r($insertInwardData);die;
$intLastInsertInwardId = $objFlight->addFlightInventory($insertInwardData);
//Get and update is parent id from last insert id
$flightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($intLastInsertInwardId, $this->intLoggedinAgencyId);
$lastInvnItemSysId = $flightInventoryDetails['PairItemSysId'];
$flightInventoryDetails = $objFlight->updateIsItParentFlight($intLastInsertInwardId, $lastInvnItemSysId);
}
$response = array('success' => true, 'intLastInsertId' => $intLastInsertId);
}
echo json_encode($response);
exit;
}
}
public function viewMarkupSettingGridAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
$MarkupSetting = $this->getRequest()->getParam('MarkupSetting');
$intAgencySysId = $this->intLoggedinAgencyId;
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
if ($MarkupSetting == 'STANDARD') {
$this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);
$this->view->arrStandardMarkups = $objFlight->getStandardMarkupsAir($intAgencySysId);
//Get Flight Details
$arrFlightInventoryDetailsList = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
//echo "<pre>";print_r($arrFlightInventoryDetailsList);
$arrFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryDetailsList['XRefFlightSysId'], @$arrFlightInventoryDetailsList['StartPlaceSysId'], @$arrFlightInventoryDetailsList['DestPlaceSysId']);
//get flight departure time
$flightDepartureTime = (array) $arrFlightTimeDetails['DepartureTime'];
$this->view->flight_start_time = date("H:i", strtotime(@$flightDepartureTime['date']));
//Get flight arrival time
$flightArrivalTime = (array) $arrFlightTimeDetails['ArrivalTime'];
$this->view->flight_desti_time = date("H:i", strtotime(@$flightArrivalTime['date']));
$this->view->arrFlightInventoryList = $arrFlightInventoryDetailsList;
if ($arrFlightInventoryDetailsList['IsItTwoWay'] == 1 && $arrFlightInventoryDetailsList['PairItemSysId'] != 0) {
$PairItemSysId = $arrFlightInventoryDetailsList['PairItemSysId'];
$arrIsPairFlightInventoryList = $objFlight->getAllFlightInventoryDetailsList($PairItemSysId, $this->intLoggedinAgencyId);
$arrIsPairFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrIsPairFlightInventoryList['XRefFlightSysId'], @$arrIsPairFlightInventoryList['StartPlaceSysId'], @$arrIsPairFlightInventoryList['DestPlaceSysId']);
//get flight departure time
$isPairFlightDepartureTime = (array) $arrIsPairFlightTimeDetails['DepartureTime'];
$this->view->ispair_flight_start_time = date("H:i", strtotime(@$isPairFlightDepartureTime['date']));
//Get flight arrival time
$isPairFlightArrivalTime = (array) $arrIsPairFlightTimeDetails['ArrivalTime'];
$this->view->ispair_flight_desti_time = date("H:i", strtotime(@$isPairFlightArrivalTime['date']));
$this->view->arrIsPairFlightInventoryList = $arrIsPairFlightInventoryList;
//echo "<pre>";print_r($arrIsPairFlightInventoryList);
}
} else if ($MarkupSetting == 'CUSTOMIZE') {
$this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);
$this->view->arrCustomizedMarkups = $objFlight->getCustomizedMarkups($InvnItemSysId);
$arrFlightInventoryDetailsList = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
//echo "<pre>";print_r($arrFlightInventoryDetailsList);
$arrFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryDetailsList['XRefFlightSysId'], @$arrFlightInventoryDetailsList['StartPlaceSysId'], @$arrFlightInventoryDetailsList['DestPlaceSysId']);
//get flight departure time
$flightDepartureTime = (array) $arrFlightTimeDetails['DepartureTime'];
$this->view->flight_start_time = date("H:i", strtotime(@$flightDepartureTime['date']));
//Get flight arrival time
$flightArrivalTime = (array) $arrFlightTimeDetails['ArrivalTime'];
$this->view->flight_desti_time = date("H:i", strtotime(@$flightArrivalTime['date']));
$this->view->arrFlightInventoryList = $arrFlightInventoryDetailsList;
if ($arrFlightInventoryDetailsList['IsItTwoWay'] == 1 && $arrFlightInventoryDetailsList['PairItemSysId'] != 0) {
$PairItemSysId = $arrFlightInventoryDetailsList['PairItemSysId'];
$arrIsPairFlightInventoryList = $objFlight->getAllFlightInventoryDetailsList($PairItemSysId, $this->intLoggedinAgencyId);
$arrIsPairFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrIsPairFlightInventoryList['XRefFlightSysId'], @$arrIsPairFlightInventoryList['StartPlaceSysId'], @$arrIsPairFlightInventoryList['DestPlaceSysId']);
//get flight departure time
$isPairFlightDepartureTime = (array) $arrIsPairFlightTimeDetails['DepartureTime'];
$this->view->ispair_flight_start_time = date("H:i", strtotime(@$isPairFlightDepartureTime['date']));
//Get flight arrival time
$isPairFlightArrivalTime = (array) $arrIsPairFlightTimeDetails['ArrivalTime'];
$this->view->ispair_flight_desti_time = date("H:i", strtotime(@$isPairFlightArrivalTime['date']));
$this->view->arrIsPairFlightInventoryList = $arrIsPairFlightInventoryList;
//echo "<pre>";print_r($arrIsPairFlightInventoryList);
}
} else if ($MarkupSetting == 'STANDARDPOLICIES') {
$this->view->arrStandardMarkupsPolicies = $objFlight->getStandardMarkupsPolicies($intAgencySysId);
} else if ($MarkupSetting == 'CUSTOMIZEPOLICIES') {
$this->view->arrCustomizedMarkupPolicies = $objFlight->getCustomizedMarkupsPolicies($InvnItemSysId);
} else {
throw new Exception('Markup settings not found.');
}
$this->view->InvnItemSysId = $InvnItemSysId;
$this->view->MarkupSetting = $MarkupSetting;
$this->view->arrAirAllocMarketPlaces = $objFlight->getAirMarketPlacesByAgencySysId($intAgencySysId, $InvnItemSysId);
$this->view->arrMarketPlaces = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getMarketPlaces();
$this->view->arrPermissions = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getPermissions();
if ($MarkupSetting == 'STANDARD') {
$this->render('view-standard-fixed-amount-grid');
} else if ($MarkupSetting == 'CUSTOMIZE') {
$this->render('view-customize-fixed-amount-grid');
} else if ($MarkupSetting == 'STANDARDPOLICIES') {
$this->render('view-standard-fixed-policies-grid');
} else if ($MarkupSetting == 'CUSTOMIZEPOLICIES') {
$this->render('view-customize-fixed-policies-grid');
}
}
}
public function calculateNetsalepriceCustomizedMarkupAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
$cost = $post['cost'];
$markup = $post['markup'];
$tax = $post['tax'];
$discount = $post['discount'];
if ($cost) {
$formDataValFinal = $cost;
}
if ($markup != 0) {
$formDataValFinal = $formDataValFinal + $markup;
}
if ($tax != 0) {
$formDataValFinal = $formDataValFinal + $tax;
}
if ($discount != 0) {
$formDataValFinal = $formDataValFinal - $discount;
} else {
$formDataValFinal = $formDataValFinal;
}
$discountPrice = 0;
$response = array('success' => true, 'netSalePrice' => $formDataValFinal, 'discountPrice' => $discountPrice);
echo json_encode($response);
exit;
}
}
public function addCustomizedMarkupAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Call Flight Model
$objFlight = new Travel_Model_TblFlight();
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$intMarkupType = $post['markupType'];
$InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');
if (empty($InvnItemSysId) || empty($intMarkupType) || empty($this->intLoggedinUserId)) {
throw new Exception('There has been an error, Please try again later');
}
/* For Customize Markup Type */
if ($intMarkupType == 'CUSTOMIZE') {
$MarPlace = !empty($post['customized-fixed-amount-market-place']) ? $post['customized-fixed-amount-market-place'] : '0';
$Permission = !empty($post['customized-fixed-amount-permissions']) ? $post['customized-fixed-amount-permissions'] : '0';
$Cost = !empty($post['customized-fixed-amount-cost']) ? $post['customized-fixed-amount-cost'] : '0';
$Markup = !empty($post['customized-fixed-amount-markup']) ? $post['customized-fixed-amount-markup'] : '0';
$tax = !empty($post['customized-fixed-amount-tax']) ? $post['customized-fixed-amount-tax'] : '0';
$Discount = !empty($post['customized-fixed-amount-discount']) ? $post['customized-fixed-amount-discount'] : '0';
$DiscountAmount = !empty($post['customized-fixed-amount-discount-price']) ? $post['customized-fixed-amount-discount-price'] : '0';
$message = !empty($post['customized-fixed-amount-message']) ? $post['customized-fixed-amount-message'] : '';
$netsale_price = !empty($post['customized-fixed-amount-netsale_price']) ? $post['customized-fixed-amount-netsale_price'] : '0';
/* For Fixed Amount Markup Type */
} else {
throw new Exception('There has been an error, Please try again later');
}
if (empty($MarPlace)) {
$response = array('success' => false, 'msg' => 'Please select market place.');
echo json_encode($response);
exit;
}
if ($Permission == "") {
$response = array('success' => false, 'msg' => 'Please select permission.');
echo json_encode($response);
exit;
}
if (empty($Cost)) {
$response = array('success' => false, 'msg' => 'Please enter cost.');
echo json_encode($response);
exit;
}
if (empty($Markup)) {
$response = array('success' => false, 'msg' => 'Please enter markup.');
echo json_encode($response);
exit;
}
if (empty($tax)) {
$response = array('success' => false, 'msg' => 'Please enter tax.');
echo json_encode($response);
exit;
}
if ($message == "") {
$response = array('success' => false, 'msg' => 'Please enter message.');
echo json_encode($response);
exit;
}
$CustGrSysId = $this->intLoggedinUserGroupId;
$ItemType = '0';
$AgencySysId = $this->intLoggedinAgencyId;
$AllocateQty = '0';
$IsVirtualInven = '0';
$SoldQty = '0';
$ReturnQty = '0';
$NetQty = '0';
$BlockQty = '0';
$MarkUpType = FIXED_PERCENTAGE_MARKUP_ID;
$Currency = '0';
$DiscountAmount = $DiscountAmount ? $DiscountAmount : '0';
$DiscountType = FIXED_PERCENTAGE_MARKUP_ID;
$IsPublish = '0';
$PublishDate = '';
$Details = '';
$RateRuleSysId = '0';
$TCDocSysId = '0';
$ValidTill = '';
$ApproveDate = '';
$CreateDate = $currentDate;
$UpdateDate = $currentDate;
$IsApproved = '0';
$IsMarkForDel = '0';
$IsActive = $Permission;
/* Check if markup settings already exists */
$arrMarkupSettings = $objFlight->getCustomizedMarkups($InvnItemSysId, $MarPlace, $this->intLoggedinAgencyId);
if (!empty($arrMarkupSettings)) {
$response = array('success' => false, 'msg' => 'Markup settings of the selected Market Place has already been added.');
echo json_encode($response);
exit;
}
$insert = array(
'InvnItemSysId' => $InvnItemSysId,
'MPType' => $MarPlace,
'CustGrSysId' => $CustGrSysId,
'ItemType' => $ItemType,
'AgencySysId' => $AgencySysId,
'AllocateQnt' => $AllocateQty,
'IsVirtualInven' => $IsVirtualInven,
'SoldQnt' => $SoldQty,
'RetrunQty' => $ReturnQty,
'NetQnt' => $NetQty,
'BlockQnt' => $BlockQty,
'MarkUpType' => $MarkUpType,
'MarkUp' => $Markup,
'Currency' => $Currency,
'Price' => $Cost,
'Tax' => $tax,
'Discount' => $Discount,
'DiscountType' => $DiscountType,
'DiscountAmount' => $DiscountAmount,
'DiscountMsg' => $message,
'NetPrice' => $netsale_price,
'IsPublish' => $IsPublish,
'PublishDate' => $PublishDate,
'Details' => $Details,
'RateRuleSysId' => $RateRuleSysId,
'TCDocSysId' => $TCDocSysId,
'ValidTill' => $ValidTill,
'ApproveDate' => $ApproveDate,
'CreateDate' => $CreateDate,
'UpdateDate' => $UpdateDate,
'IsApproved' => $IsApproved,
'IsMarkForDel' => $IsMarkForDel,
'IsActive' => $IsActive
);
// echo "<pre>";
// print_r($insert);
// exit;
try {
$objFlight->addMarkupSettings($insert);
$response = array('success' => true);
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
}
public function deleteCustomizedMarkupSettingAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
$MPType = $this->getRequest()->getParam('MPType');
$objFlight = new Travel_Model_TblFlight();
$objFlight->deleteCustomizedMarkupSetting($InvnItemSysId, $MPType, $this->intLoggedinAgencyId);
$response = array('success' => true);
echo json_encode($response);
exit;
}
}
public function addCustomizedMarkupPoliciesAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Call Flight Model
$objFlight = new Travel_Model_TblFlight();
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$currentOnlyDate = Zend_Date::now()->toString('yyyy-MM-dd');
$intMarkupType = $post['markupType'];
$InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');
if (empty($InvnItemSysId) || empty($this->intLoggedinUserId)) {
throw new Exception('There has been an error, Please try again later');
}
/* For Customize Markup Type */
if ($intMarkupType == 'CUSTOMIZEPOLICIES') {
$MarPolicies = isset($post['markup_setting_customize_policies']) ? $post['markup_setting_customize_policies'] : '0';
/* For Fixed Amount Markup Type */
} else {
throw new Exception('There has been an error, Please try again later');
}
if (empty($MarPolicies)) {
$response = array('success' => false, 'msg' => 'Please enter Markup Policies.');
echo json_encode($response);
exit;
}
$ArtifectSysId = '1';
$ArtifectType = '0';
$Title = '';
$Breif = '';
$FileName = '';
$XUrl = '';
$CreateDate = $currentDate;
$UpdateDate = $currentDate;
$IsMarkForDel = '0';
$IsActive = '1';
/* Check if markup settings already exists */
$arrMarkupSettings = $objFlight->getCustomizedMarkupsPolicies($InvnItemSysId);
if (!empty($arrMarkupSettings)) {
$update = array(
'Writeup' => $MarPolicies
);
try {
$objFlight->editMarkupPoliciesSettings($update, $InvnItemSysId);
$response = array('success' => true);
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
} else {
$insert = array(
'InvnItemSysId' => $InvnItemSysId,
'ArtifectSysId' => $ArtifectSysId,
'ArtifectType' => $ArtifectType,
'Title' => $Title,
'Breif' => $Breif,
'FileName' => $FileName,
'Writeup' => $MarPolicies,
'XUrl' => $XUrl,
'CreateDate' => $CreateDate,
'UpdateDate' => $UpdateDate,
'IsMarkForDel' => $IsMarkForDel,
'IsActive' => $IsActive
);
// echo "<pre>";
// print_r($insert);
// exit;
try {
$objFlight->addMarkupPoliciesSettings($insert);
$response = array('success' => true);
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
}
}
public function editFlightInventoryBulkFormAction() {
$this->_helper->layout->setLayout('newLayout');
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
//Get Currency List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
//Get Supplier List
$objSupplier = new Travel_Model_TblSupplier();
$this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$this->view->arrFlightInventoryDetails = $arrFlightInventoryDetails;
if ($arrFlightInventoryDetails['IsItTwoWay'] == 1 && $arrFlightInventoryDetails['PairItemSysId'] != 0) {
$arrFlightInventoryIswayDetails = $objFlight->getAllFlightInventoryDetailsList($arrFlightInventoryDetails['PairItemSysId']);
} else {
$arrFlightInventoryIswayDetails = array();
}
$this->view->arrFlightInventoryIswayDetails = $arrFlightInventoryIswayDetails;
//echo "<pre>";print_r($arrFlightInventoryDetails);
//exit;
}
}
public function getFlightInventoryDetailAction() {
$this->_helper->layout->setLayout('newLayout');
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryDetails = $objFlight->getAllFlightInventoryDetailsList($InvnItemSysId, $this->intLoggedinAgencyId);
$FromDateTimeObj = (array) $arrFlightInventoryDetails['FromDate'];
$source_date_time = date("d/m/Y", strtotime($FromDateTimeObj['date']));
//Get flight time
$arrFlightTimeDetails = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryDetails['XRefFlightSysId'], @$arrFlightInventoryDetails['StartPlaceSysId'], @$arrFlightInventoryDetails['DestPlaceSysId']);
//get flight departure time
$flightDepartureTime = (array) $arrFlightTimeDetails['DepartureTime'];
$flight_start_time = date("H:i", strtotime(@$flightDepartureTime['date']));
//Get flight arrival time
$flightArrivalTime = (array) $arrFlightTimeDetails['ArrivalTime'];
$flight_desti_time = date("H:i", strtotime(@$flightArrivalTime['date']));
$arrFlightInventoryDetailsArr = array('FromDateFormat' => $source_date_time, 'FlightDepartureTime' => $flight_start_time, 'FlightArrivalTime' => $flight_desti_time);
$arrFlightInventoryDetailsArrFinal = array_merge($arrFlightInventoryDetails, $arrFlightInventoryDetailsArr);
$arrFlightInventoryIswayDetailsFinal = array();
if ($arrFlightInventoryDetails['IsItTwoWay'] == 1 && $arrFlightInventoryDetails['PairItemSysId'] != 0) {
$arrFlightInventoryIswayDetails = $objFlight->getAllFlightInventoryDetailsList($arrFlightInventoryDetails['PairItemSysId'], $this->intLoggedinAgencyId);
$FromDateTimeInwardObj = (array) $arrFlightInventoryIswayDetails['FromDate'];
$inward_date_time = date("d/m/Y", strtotime($FromDateTimeInwardObj['date']));
//Get flight time
$arrFlightTimeDetailsIsway = $objFlight->getFlightTimeInventoryDetailsByFlightId($arrFlightInventoryIswayDetails['XRefFlightSysId'], @$arrFlightInventoryIswayDetails['StartPlaceSysId'], @$arrFlightInventoryIswayDetails['DestPlaceSysId']);
//get flight departure time
$flightDepartureTimeIsway = (array) $arrFlightTimeDetailsIsway['DepartureTime'];
$flight_start_time_isway = date("H:i", strtotime(@$flightDepartureTimeIsway['date']));
//Get flight arrival time
$flightArrivalTimeIsway = (array) $arrFlightTimeDetailsIsway['ArrivalTime'];
$flight_desti_time_isway = date("H:i", strtotime(@$flightArrivalTimeIsway['date']));
$arrFlightInventoryIswayDetailsArr = array('InwardFromDateFormat' => $inward_date_time, 'InwardFlightDepartureTime' => $flight_start_time_isway, 'InwardFlightArrivalTime' => $flight_desti_time_isway);
$arrFlightInventoryIswayDetailsFinal = array_merge($arrFlightInventoryIswayDetails, $arrFlightInventoryIswayDetailsArr);
$response = array('IsItTwoWayCheck' => true, 'parentArr' => $arrFlightInventoryDetailsArrFinal, 'isWayArr' => $arrFlightInventoryIswayDetailsFinal);
echo json_encode($response);
exit;
}
$response = array('IsItTwoWayCheck' => false, 'parentArr' => $arrFlightInventoryDetailsArrFinal, 'isWayArr' => $arrFlightInventoryIswayDetailsFinal);
echo json_encode($response);
exit;
//$this->view->arrFlightInventoryDetails = $arrFlightInventoryDetails;
//
//
//echo "<pre>";print_r($arrFlightInventoryDetails);
//exit;
}
}
public function getCityDetailsListAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
//Get Country List
$str_city = '';
if ($post['countryId'] != 0) {
$objCity = new Travel_Model_TblCity();
$objCity->intContSysId = $post['countryId'];
$arrCityList = $objCity->getCityList();
if (!empty($arrCityList)) {
foreach ($arrCityList as $arrCity) {
$str_city .= '<option value="' . $arrCity['CityId'] . '">' . $arrCity['Title'] . '</option>';
}
} else {
$str_city = '<option value="0">Select</option>';
}
} else {
$str_city = '<option value="0">Select</option>';
}
echo $str_city;
exit;
}
}
public function addSupplierAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
//Get Country List
$objCountry = new Travel_Model_TblCountry();
$this->view->arrCountryList = $objCountry->getCountryList();
}
public function saveSupplierAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$SupplierName = $this->getRequest()->getPost('SupplierName') ? $this->getRequest()->getPost('SupplierName') : '';
$ContactPerson = $this->getRequest()->getPost('ContactPerson') ? $this->getRequest()->getPost('ContactPerson') : '';
$Designation = $this->getRequest()->getPost('Designation') ? $this->getRequest()->getPost('Designation') : '';
$ContactNo = $this->getRequest()->getPost('ContactNo') ? $this->getRequest()->getPost('ContactNo') : '';
$EmailId = $this->getRequest()->getPost('EmailId') ? $this->getRequest()->getPost('EmailId') : '';
$Address = $this->getRequest()->getPost('Address') ? $this->getRequest()->getPost('Address') : '';
$ContId = $this->getRequest()->getPost('ContId') ? $this->getRequest()->getPost('ContId') : '';
$CitySysId = $this->getRequest()->getPost('CitySysId') ? $this->getRequest()->getPost('CitySysId') : '';
$SupplierTypeSysId = $this->SupplierTypeSysId;
$FacilityMask = 0;
$PrefCurrencyType = 1;
$StateId = 0;
$PlaceSysId = 0;
$IsCreatedByAgent = 1;
$AgentSysId = $this->intLoggedinUserId;
$UpdatedDate = $currentDate;
$CreateDate = $currentDate;
$ApproveDate = '';
$IsApproved = 0;
$IsDelete = 0;
$IsActive = 0;
if (empty($post) || empty($this->intLoggedinUserId)) {
throw new Exception('There has been an error, Please try again later');
}
$insert = array(
'SupplierTypeSysId' => $SupplierTypeSysId,
'FacilityMask' => $FacilityMask,
'SupplierName' => $SupplierName,
'ContactPerson' => $ContactPerson,
'PrefCurrencyType' => $PrefCurrencyType,
'Designation' => $Designation,
'ContactNo' => $ContactNo,
'EmailId' => $EmailId,
'Address' => $Address,
'CitySysId' => $CitySysId,
'ContId' => $ContId,
'StateId' => $StateId,
'PlaceSysId' => $PlaceSysId,
'IsCreatedByAgent' => $IsCreatedByAgent,
'AgentSysId' => $AgentSysId,
'PlaceSysId' => $PlaceSysId,
'UpdatedDate' => $UpdatedDate,
'CreateDate' => $CreateDate,
'ApproveDate' => $ApproveDate,
'IsApproved' => $IsApproved,
'IsDelete' => $IsDelete,
'IsActive' => $IsActive
);
// echo "<pre>";
// print_r($insert);
// exit;
try {
//Call Supplier Model
$objSupplier = new Travel_Model_TblSupplier();
$objSupplier->addSupplier($insert);
//$arrSupplierList = $objSupplier->getSupplierList();
$response = array('success' => 'Supplier saved successfully.');
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
}
public function updateFlightSaleAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
$actionValue = $this->getRequest()->getParam('actionValue');
$manageValue = $this->getRequest()->getParam('manageValue');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
$objFlight->updateFlightSaleInventory($InvnItemSysId, $actionValue, $this->intLoggedinAgencyId);
if ($arrFlightInventoryList[0]['IsItTwoWay'] == 1 && $arrFlightInventoryList[0]['PairItemSysId'] != 0) {
$arrIsPairFlightInventoryList = $arrFlightInventoryList[0]['PairItemSysId'];
$objFlight->updateIsPairFlightSaleInventory($arrIsPairFlightInventoryList, $actionValue, $this->intLoggedinAgencyId);
}
$response = array('success' => true);
echo json_encode($response);
exit;
}
}
public function updateSaleStatusAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$InvnItemSysId = base64_decode($this->getRequest()->getParam('id'));
$actionValue = $this->getRequest()->getParam('status');
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
$objFlight->updateFlightSaleInventory($InvnItemSysId, $actionValue, $this->intLoggedinAgencyId);
if ($arrFlightInventoryList[0]['IsItTwoWay'] == 1 && $arrFlightInventoryList[0]['PairItemSysId'] != 0) {
$arrIsPairFlightInventoryList = $arrFlightInventoryList[0]['PairItemSysId'];
$objFlight->updateIsPairFlightSaleInventory($arrIsPairFlightInventoryList, $actionValue, $this->intLoggedinAgencyId);
}
$this->_helper->flashMessenger->addMessage("Flight sale status updated successfully.");
$this->_helper->redirector('index', 'flight', 'default');
}
public function updateStatusAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$InvnItemSysId = base64_decode($this->getRequest()->getParam('id'));
$actionValue = $this->getRequest()->getParam('status');
if ($actionValue == 0) {
$msg = "Flight deactivated successfully.";
} else {
$msg = "Flight activated successfully.";
}
$objFlight = new Travel_Model_TblFlight();
$arrFlightInventoryList = $objFlight->getFlightInventoryList($InvnItemSysId, $this->intLoggedinAgencyId);
if (count($arrFlightInventoryList) <> 1) {
throw new Exception('There has been an error, Please try again later');
}
$objFlight->updateFlightActivateAndDeactivateInventory($InvnItemSysId, $actionValue, $this->intLoggedinAgencyId);
if ($arrFlightInventoryList[0]['IsItTwoWay'] == 1 && $arrFlightInventoryList[0]['PairItemSysId'] != 0) {
$arrIsPairFlightInventoryList = $arrFlightInventoryList[0]['PairItemSysId'];
$objFlight->updateIsPairFlightActivateAndDeactivateInventory($arrIsPairFlightInventoryList, $actionValue, $this->intLoggedinAgencyId);
}
$this->_helper->flashMessenger->addMessage($msg);
$this->_helper->redirector('index', 'flight', 'default');
}
public function addFlightConnectingAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
//Call Flight Model
$objFlight = new Travel_Model_TblFlight();
//Get Post form data
$post = $this->getRequest()->getPost();
// echo "<pre>";
// print_r($post);
// exit;
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');
if (empty($InvnItemSysId) || empty($this->intLoggedinUserId)) {
throw new Exception('There has been an error, Please try again later');
}
/* For Flight Connecting */
if (!empty($post)) {
$AirlineSysId = isset($post['AirlineSysId']) ? $post['AirlineSysId'] : '0';
$airport_code = isset($post['airport_code']) ? $post['airport_code'] : '';
$arriving_date = isset($post['arriving_date']) ? $post['arriving_date'] : '';
$departure_date = isset($post['departure_date']) ? $post['departure_date'] : '';
} else {
throw new Exception('There has been an error, Please try again later');
}
if ($AirlineSysId != 0) {
$response = array('success' => false, 'msg' => 'Please select airlines.');
echo json_encode($response);
exit;
}
if ($airport_code == "") {
$response = array('success' => false, 'msg' => 'Please select airport.');
echo json_encode($response);
exit;
}
/* Check if connecting flight already exists */
$arrFlightConnecting = $objFlight->getCustomizedMarkups($InvnItemSysId, $this->intLoggedinAgencyId);
if (!empty($arrFlightConnecting)) {
$response = array('success' => false, 'msg' => 'Connecting flight of the selected airlines has already been added.');
echo json_encode($response);
exit;
}
$insert = array(
'AirInvenSysId' => $InvnItemSysId,
'SourcePlaceSysId' => $MarPlace,
'Sequance' => $CustGrSysId,
'DestPlaceSysId' => $ItemType,
'StayDuration' => $AgencySysId,
'IsFlightChange' => $AllocateQty,
'NewFInvenSysId' => $IsVirtualInven,
'ArrivalTime' => $SoldQty,
'RetrunQty' => $ReturnQty,
'DepartureTime' => $NetQty,
'HaultInclusions' => $BlockQty,
'ApproveDate' => $ApproveDate,
'CreateDate' => $CreateDate,
'UpdateDate' => $UpdateDate,
'IsApproved' => $IsApproved,
'IsMarkForDel' => $IsMarkForDel
);
// echo "<pre>";
// print_r($insert);
// exit;
try {
$objFlight->addMarkupSettings($insert);
$response = array('success' => true);
echo json_encode($response);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
}
public function getSearchResultAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$post = $this->getRequest()->getPost();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$sessionFlightSearchParams->params = $post;
$from = $this->getRequest()->getPost('from');
$to = $this->getRequest()->getPost('to');
$departure_dates = $this->getRequest()->getPost('departure_dates');
$adults = $this->getRequest()->getPost('adults');
$flight_class = $this->getRequest()->getPost('flight_class');
$route = $this->getRequest()->getPost('route');
$return_dates = $this->getRequest()->getPost('return_dates');
//$data = array('from' => $from, 'to' => $to, 'departure_dates' => $departure_dates, 'adults' => $adults, 'flight_class' => $flight_class);
if (empty($from)) {
$response = array('success' => false, 'msg' => 'Please select source city.');
echo json_encode($response);
exit;
}
if (empty($to)) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if ($from == $to) {
$response = array('success' => false, 'msg' => 'The \'Departure City\' and \'Destination City\' cannot be same. Please re-type.');
echo json_encode($response);
exit;
}
// if(!empty($from) > 0 ) {
// $arrOrigin = explode("#",$from[0]);
// $intOriginCityId = $arrOrigin[0];
// $originAirportCode = $arrOrigin[1];
// }
//
// if(!empty($to) > 0 ) {
// $arrDestination = explode("#",$to[0]);
// $destinationAirportCode = $arrDestination[1];
// $intDestinationCityId = $arrDestination[0];
// }
// $originAirportCode = $from[0]; // Changed for Single city Search By Pardeep Panchal On 08/08/2016
// $destinationAirportCode = $to[0]; // Changed for Single city Search By Pardeep Panchal On 08/08/2016
$originAirportCode = $from;
$destinationAirportCode = $to;
$objCity = new Travel_Model_TblCity();
// $sourceCityName = $objCity->getCityNameById($intOriginCityId);
// $destinationCityName = $objCity->getCityNameById($intDestinationCityId);
//
//
//
$sourceCityName = $originAirportCode;
$destinationCityName = $destinationAirportCode;
// $sessionFlightSearchParams->params['oneWayIntSourceCityId'] = $intOriginCityId;
// $sessionFlightSearchParams->params['oneWayIntDestinationCityId'] = $intDestinationCityId;
//
$sessionFlightSearchParams->params['oneWaySourceCityName'] = $sourceCityName;
$sessionFlightSearchParams->params['oneWayDestinationCityName'] = $destinationCityName;
$sessionFlightSearchParams->params['sourceCityAirportCode'] = $originAirportCode;
$sessionFlightSearchParams->params['destinationCityAirportCode'] = $destinationAirportCode;
// echo "<pre>";
// print_r($sessionFlightSearchParams->params);
// exit;
//
if (empty($departure_dates) || trim($departure_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select departure date');
echo json_encode($response);
exit;
}
if (empty($adults)) {
$response = array('success' => false, 'msg' => 'Please select the number of adults.');
echo json_encode($response);
exit;
}
if (empty($flight_class)) {
$response = array('success' => false, 'msg' => 'Please select the class.');
echo json_encode($response);
exit;
}
if ($route == 'twoway') {
if (empty($return_dates) || trim($return_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select return date');
echo json_encode($response);
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$result = $objFlight->getSearchResult($post);
if (count($result) == 0) {
$response = array('success' => false, 'msg' => 'Sorry, no records found. Please adjust your search criteria and try again.');
echo json_encode($response);
exit;
}
$sessionFlightSearch = new Zend_Session_Namespace('sessionFlightSearch');
$searchIds = '';
if (!empty($result)) {
foreach ($result as $row) {
$searchIds .= $row['XRefFlightSysId'] . ",";
}
}
$searchIds = Zend_Controller_Action_HelperBroker::getStaticHelper('String')->cleanCommaSepString($searchIds);
$sessionFlightSearch->searchIds = $searchIds;
// echo "<pre>";
// print_r($result);
// exit;
$response = array('success' => true);
echo json_encode($response);
exit;
}
}
public function allAirlinesAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
if (!empty($sessionFlightSearchParams->params)) {
$tokenId = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->authenticateAPI();
$getFlightDetailsURL = 'http://api.tektravels.com/BookingEngineService_Air/AirService.svc/rest/Search/';
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
// $origin = $sessionFlightSearchParams->params['from'];
// $destination = $sessionFlightSearchParams->params['to'];
$origin = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$preferredDepartureTime = $sessionFlightSearchParams->params['departure_dates'];
$preferredArrivalTime = $sessionFlightSearchParams->params['departure_dates'];
$this->view->oneWayDestinationCityName = $sessionFlightSearchParams->params['oneWayDestinationCityName'];
$preferredDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredDepartureTime, 'd/m/y');
$preferredArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredArrivalTime, 'd/m/y');
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "1",
"PreferredAirlines" => NULL,
"Segments" => [array(
'Origin' => $origin, 'Destination' => $destination, 'FlightCabinClass' => "1", "PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
)],
"Sources" => ["6E"]
);
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $getFlightDetailsURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if ($response['Response']['ResponseStatus'] != '1') {
$this->view->ErrorCode = $response['Response']['Error']['ErrorCode'];
$this->view->ErrorMessage = $response['Response']['Error']['ErrorMessage'];
} else if ($response['Response']['ResponseStatus'] == '1') {
$this->view->arrFlightResults = $response['Response']['Results'][0];
$this->view->TraceId = $response['Response']['TraceId'];
}
}
if ($sessionFlightSearchParams->params['route'] == 'twoway') {
$getFlightDetailsURL = 'http://api.tektravels.com/BookingEngineService_Air/AirService.svc/rest/Search/';
$destination = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$origin = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$preferredDepartureTime = $sessionFlightSearchParams->params['return_dates'];
$preferredArrivalTime = $sessionFlightSearchParams->params['return_dates'];
$preferredDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredDepartureTime, 'd/m/y');
$preferredArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredArrivalTime, 'd/m/y');
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "1",
"PreferredAirlines" => NULL,
"Segments" => [array(
'Origin' => $origin, 'Destination' => $destination, 'FlightCabinClass' => "1", "PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
)],
"Sources" => ["6E"]
);
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $getFlightDetailsURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
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(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
if ($response['Response']['ResponseStatus'] != '1') {
$this->view->TwoWayErrorCode = $response['Response']['Error']['ErrorCode'];
$this->view->TwoWayErrorMessage = $response['Response']['Error']['ErrorMessage'];
} else if ($response['Response']['ResponseStatus'] == '1') {
$this->view->arrTwoWayFlightResults = $response['Response']['Results'][0];
}
$this->render('twoway-all-airlines');
}
}
}
public function searchAction() {
Zend_Session::namespaceUnset('sessionFlightSearchParams');
Zend_Session::namespaceUnset('FlightSearchResults');
Zend_Session::namespaceUnset('FlightSearchResultsTBO');
Zend_Session::namespaceUnset('isagencySession');
$SearchTraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
if ($this->_request->isXmlHttpRequest()) {
$objFlight = new Travel_Model_TblFlight();
/* Disable Layout */
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getPost();
$isDevice = Zend_Controller_Action_HelperBroker::getStaticHelper('Device')->deviceType();
//echo "<pre>";print_r($post);exit;
$leadsource = isset($post['lead_source']) ? $post['lead_source'] : 0;
$route = $this->getRequest()->getPost('route');
$from = $this->getRequest()->getPost('from');
$to = $this->getRequest()->getPost('to');
$PreferredAirline = $this->getRequest()->getPost('PreferredAirline');
$sourceCityText = $this->getRequest()->getPost('sourceCityText');
$destinationCityText = $this->getRequest()->getPost('destinationCityText');
$departure_dates = $this->getRequest()->getPost('departure_dates');
$adults = $this->getRequest()->getPost('adults');
$child = $this->getRequest()->getPost('child');
$infant = $this->getRequest()->getPost('infant');
$flight_class = $this->getRequest()->getPost('flight_class');
$return_dates = $this->getRequest()->getPost('return_dates');
$customerID = $this->getRequest()->getPost('customerID');
$flightSearchType = $this->getRequest()->getPost('flightSearchType');
$editLeadId = $this->getRequest()->getPost('editLeadId');
$currentOwnerSysId = $this->getRequest()->getPost('currentOwnerSysId');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$GetCustomerData = $crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$sessionFlightSearchParams->params = $post; // Putting all form data to Session
$Cities__ = [];
$strDepatureDate_ = [];
if ($route == 3) {
$intCountryCode = [];
$intSourceCityId_ = [];
$intDestinationCityId_ = [];
$intOriginCountryCode = 'IN';
$intDestinationCountryCode = 'IN';
if ($from) {
foreach ($from as $key => $value) {
$string = isset($sourceCityText[$key]) ? $sourceCityText[$key] : '';
$sourceCityText__ = substr($string, 0, strpos($string, ','));
$string2 = isset($destinationCityText[$key]) ? $destinationCityText[$key] : '';
$destinationCityText__ = substr($string2, 0, strpos($string2, ','));
$Cities__[] = $sourceCityText__ . '-' . $destinationCityText__;
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $value;
$arrSourceCityId = $objAirport->getAirportList();
if (!empty($arrSourceCityId)) {
$intSourceCityId_[] = $arrSourceCityId[0]['CityId'];
$intCountryCode[] = $arrSourceCityId[0]['CountryCode'];
if (trim($arrSourceCityId[0]['CountryCode']) != 'IN') {
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
}
} else {
$intSourceCityId_ = [];
$intCountryCode = [];
}
$objAirport->strAirportCode = isset($to[$key]) ? $to[$key] : '';
$arrDestinationCityId = $objAirport->getAirportList();
if (!empty($arrDestinationCityId)) {
$intDestinationCityId_[] = $arrDestinationCityId[0]['CityId'];
if (trim($arrDestinationCityId[0]['CountryCode']) != 'IN') {
$intDestinationCountryCode = trim($arrDestinationCityId[0]['CountryCode']);
}
} else {
$intDestinationCityId_ = [];
}
if (isset($departure_dates[$key]) && !empty($departure_dates[$key])) {
$arrDepatureDate = explode("/", $departure_dates[$key]);
if (!empty($arrDepatureDate)) {
$strDepatureDate_[] = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
}
}
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else if ($intDestinationCountryCode != "IN" || empty($intDestinationCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else {
$sessionFlightSearchParams->params['interNationalSearch'] = false;
}
$departure_dates = $departure_dates[0];
//echo "<pre>";print_r($intOriginCountryCode);
// echo "<pre>";print_r($intDestinationCountryCode);
// echo "<pre>";print_r($intDestinationCountryCode);
// echo "<pre>";print_r($intSourceCityId);
// echo "<pre>";print_r($intDestinationCityId);
// echo "<pre>";print_r($Cities__);
// echo "<pre>";print_r($post);
// die;
} else {
if (empty($from)) {
$response = array('success' => false, 'msg' => 'Please select source city.');
echo json_encode($response);
exit;
}
if (empty($to)) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if ($from == $to) {
$response = array('success' => false, 'msg' => 'The \'Departure City\' and \'Destination City\' cannot be same. Please re-type.');
echo json_encode($response);
exit;
}
if (empty($departure_dates) || trim($departure_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select departure date');
echo json_encode($response);
exit;
}
if ($route == 2) {
if (empty($return_dates) || trim($return_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select return date');
echo json_encode($response);
exit;
}
}
if (empty($adults)) {
$response = array('success' => false, 'msg' => 'Please select the number of adults.');
echo json_encode($response);
exit;
}
if (empty($flight_class)) {
$response = array('success' => false, 'msg' => 'Please select the class.');
echo json_encode($response);
exit;
}
}
if (!empty($departure_dates)) {
$arrDepatureDate = explode("/", $departure_dates);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
}
if (!empty($return_dates)) {
$arrReturnDepatureDate = explode("/", $return_dates);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
if (empty((int) $leadsource)) {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($this->intLoggedinAgencyId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$TCurrencyType = trim($this->agencyDetails['TrxCurrency']);
$FCurrencyType = 1;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getCurrencyRate($FCurrencyType, $TCurrencyType, $this->intLoggedinAgencyId);
$CurrencyRate = isset($apiResponse['Rate']) ? $apiResponse['Rate'] : 1;
$CurrencyTitle = isset($apiResponse['Symbol']) ? $apiResponse['Symbol'] : 'INR';
$CurrencyId = isset($apiResponse['CurrencyId']) ? $apiResponse['CurrencyId'] : 1;
//echo "<pre>"; print_r($sessionFlightSearchParams->params); exit;
$sessionFlightSearchParams->params['MasterAgencySysId'] = $this->intLoggedinAgencyId;
$sessionFlightSearchParams->params['AgencySysId'] = $GetCustomerData['AgencySysId'];
$sessionFlightSearchParams->params['CustomerSysId'] = $GetCustomerData['CustomerSysId'];
$sessionFlightSearchParams->params['UserSysId'] = $GetCustomerData['UserSysId'];
$sessionFlightSearchParams->params['B2BType'] = $GetCustomerData['IsB2BAgent'];
$sessionFlightSearchParams->params['CurrencyRate'] = $CurrencyRate;
$sessionFlightSearchParams->params['CurrencyTitle'] = $CurrencyTitle;
$sessionFlightSearchParams->params['CurrencyId'] = $CurrencyId;
$sessionFlightSearchParams->params['SearchTraceId'] = $SearchTraceId;
$sessionFlightSearchParams->params['sourceCityAirportCode'] = $from;
$sessionFlightSearchParams->params['destinationCityAirportCode'] = $to;
$sessionFlightSearchParams->params['strDepatureDate'] = $strDepatureDate_;
$sessionFlightSearchParams->params['sourceCityText'] = $sourceCityText;
$sessionFlightSearchParams->params['destinationCityText'] = $destinationCityText;
$sessionFlightSearchParams->params['lead_source'] = $leadsource;
if ($route == 3) {
$departure_dates = $departure_dates[0];
$intSourceCityId = $intSourceCityId_[0];
$intDestinationCityId = $intDestinationCityId_[0];
$sourceCityText = $sourceCityText[0];
$destinationCityText = $destinationCityText[0];
$from = $from[0];
$to = $to[0];
} else {
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $from;
$arrSourceCityId = $objAirport->getAirportList();
$objAirport->strAirportCode = $to;
$arrdestinationCityId = $objAirport->getAirportList();
if (!empty($arrSourceCityId)) {
$intSourceCityId = $arrSourceCityId[0]['CityId'];
$intCountryCode = trim($arrSourceCityId[0]['CountryCode']);
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
} else {
$intSourceCityId = "";
$intCountryCode = "";
}
if (!empty($arrdestinationCityId)) {
$intdestinationCityId = $arrdestinationCityId[0]['CityId'];
$intdestinationCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
$intDestinaionCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
} else {
$intdestinationCityId = "";
$intdestinationCountryCode = "";
}
if ($intCountryCode == $intdestinationCountryCode) {
$intCountryCode = 'IN';
} else {
$intCountryCode = 'INT';
}
$objAirport->strAirportCode = $to;
$arrDestinationCityId = $objAirport->getAirportList();
if (!empty($arrDestinationCityId)) {
$intDestinationCityId = $arrDestinationCityId[0]['CityId'];
$intDestinationCountryCode = trim($arrDestinationCityId[0]['CountryCode']);
} else {
$intDestinationCityId = "";
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else if ($intDestinationCountryCode != "IN" || empty($intDestinationCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else {
$sessionFlightSearchParams->params['interNationalSearch'] = false;
}
}
$sessionFlightSearchParams->params['sourceCityId'] = ($route == 3) ? $intSourceCityId_ : $intSourceCityId;
$sessionFlightSearchParams->params['destinationCityId'] = ($route == 3) ? $intDestinationCityId_ : $intDestinationCityId;
$sessionFlightSearchParams->params['customerID'] = $customerID;
$sessionFlightSearchParams->params['flightSearchType'] = $flightSearchType;
$sessionFlightSearchParams->params['editLeadId'] = $editLeadId;
$sessionFlightSearchParams->params['currentOwnerSysId'] = (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $this->intLoggedinUserId;
$sessionFlightSearchParams->params['intCountryCode'] = $intCountryCode;
$sessionFlightSearchParams->params['typeQuick'] = $this->getRequest()->getPost('typeQuick');
if ($route == 1) {
$sessionFlightSearchParams->params['from_city_'][0] = '1__' . $from . '-' . $to;
} elseif ($route == 2) {
$sessionFlightSearchParams->params['from_city_'][0] = '2__' . $from . '-' . $to . '-' . $from;
}
// echo "<pre>";print_r($sessionFlightSearchParams->params);exit;
// echo '<pre>';
// print_r($sessionFlightSearchParams->params);die;
/* $sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->leadID = '';
$sessionLogin_lead_customer->FirstName = '';
$sessionLogin_lead_customer->EmailId = ''; */
//create search history for query created by Er Amit Kumar Dubey on 12 april 2017 at 10:52 PM
$createDate = date('Y-m-d H:i:s');
$historyData = array(
'TPSysId' => '',
'AgencySysId' => $this->intLoggedinAgencyId,
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $customerID,
'PlanType' => 1,
'SourcePlaces' => isset($sourceCityText) ? trim($sourceCityText) : '',
'SourcePlaceSysId' => isset($intSourceCityId) ? $intSourceCityId : '',
'DestinationPlaces' => isset($destinationCityText) ? trim($destinationCityText) : '',
'DestinationPlaceSysId' => isset($intDestinationCityId) ? $intDestinationCityId : '',
'PackTypeMask' => '',
'InclusionMark' => '',
'Rooms' => 0,
'TotAdultCount' => $adults,
'TotChildCount' => $child,
'TotInfantCount' => $infant,
'PriceRangeFrom' => '',
'PriceRangeTo' => '',
'AdditionalSrvMark' => '',
'StartDate' => isset($strDepatureDate) ? $strDepatureDate : $createDate,
'ValidTill' => isset($strReturnDate) ? $strReturnDate : $createDate,
'Rating' => $flight_class,
"SearchDate" => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$this->_crmcusttravelplanhistory = new Travel_Model_CRM_CustomerTravelPlanSearchHistory();
$this->_crmcusttravelplanhistory->addCustomerTravelPlanSearchHistory($historyData);
//end of create search history
$arrData['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
$tempData = array(
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
if ($sessionFlightSearchParams->params['interNationalSearch'] == 1) {
$intl = 'true';
} else {
$intl = 'false';
}
if ($sessionFlightSearchParams->params['route'] == 1) {
$tripType = 'O';
} elseif ($sessionFlightSearchParams->params['route'] == 2) {
$tripType = 'R';
} else {
$tripType = '';
}
if ($sessionFlightSearchParams->params['flight_class'] == 1 || $sessionFlightSearchParams->params['flight_class'] == 1) {
$cabinClass = 'E';
} elseif ($sessionFlightSearchParams->params['flight_class'] == 3) {
$cabinClass = 'PE';
} elseif ($sessionFlightSearchParams->params['flight_class'] == 4) {
$cabinClass = 'B';
} elseif ($sessionFlightSearchParams->params['flight_class'] == 5) {
$cabinClass = 'B';
} elseif ($sessionFlightSearchParams->params['flight_class'] == 6) {
$cabinClass = 'F';
}
$paxType = 'A-' . $adults . '_C-' . $child . '_I-' . $infant . '';
if ($sessionFlightSearchParams->params['route'] == 1) {
$makemytrip = $from . '-' . $to . '-' . $departure_dates . '&tripType=' . $tripType . '&paxType=' . $paxType . '&intl=' . $intl . '&cabinClass=' . $cabinClass . '&ccde=IN&lang=eng';
} elseif ($sessionFlightSearchParams->params['route'] == 2) {
$makemytrip = $from . '-' . $to . '-' . $departure_dates . '_' . $to . '-' . $from . '-' . $return_dates . '&tripType=' . $tripType . '&paxType=' . $paxType . '&intl=' . $intl . '&cabinClass=' . $cabinClass . '&ccde=IN&lang=eng';
}
$makemytripurl = 'https://www.makemytrip.com/flight/search?itinerary=' . $makemytrip;
// echo "<pre>"; print_r($makemytripurl);
// echo "<pre>"; print_r($sessionFlightSearchParams->params);
// exit;
$response = array('success' => true,'isDevice'=>$isDevice, 'SearchTraceId' => $SearchTraceId, 'url__' => $makemytripurl, 'route' => $sessionFlightSearchParams->params['route']);
echo json_encode($response);
exit;
}
}
public function getMarkup($intCountryCode) {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$AgencySysId = $this->intLoggedinAgencyId;
$strCountryCode = $intCountryCode;
$PlanType = 1;
if (!empty(trim($strCountryCode)) && trim($strCountryCode) != "IN") {
$intAirType = 2;
} else {
$intAirType = 1;
}
$objFlight = new Travel_Model_TblFlight();
$objHotel = new Travel_Model_TblBuyHotel();
$objMarkup = new Markup_Model_Markup();
$arrGTXMarkups = $objFlight->getGTXMarkups($intAirType, $AgencySysId);
$arrAgencyMarkups = $objFlight->getAgencyMarkups($intAirType, $AgencySysId);
$arrAgencyMarkupsHotel = $objHotel->getAgencyMarkups($intAirType, $AgencySysId);
$whereCharge = array("AgencySysId" => $AgencySysId, "ItemSourceType" => (int) $intAirType);
$arrAgencyMarkupsCancellation = $objMarkup->getCancellationChargeDetail('TB_Agency_Cancellation_Charges', $whereCharge);
$arrAgencyUserDetail = $objMarkup->getAgencyUserDetail(array("AgencySysId" => $AgencySysId, "ItemSourceType" => (int) $intAirType, "PlanType" => $PlanType));
$arrApiServiceTax = $objHotel->getApiServiceTax(0);
try {
if ($arrGTXMarkups || $arrAgencyMarkups) {
$status = array("status" => true, "arrGTXMarkups" => $arrGTXMarkups, "arrAgencyMarkups" => $arrAgencyMarkups, 'arrApiServiceTax' => $arrApiServiceTax, 'arrAgencyMarkupsHotel' => $arrAgencyMarkupsHotel, 'arrAgencyMarkupsCancellation' => $arrAgencyMarkupsCancellation, 'arrAgencyUserDetail' => $arrAgencyUserDetail, "message" => 'Successfully.');
return $status;
}
} catch (Exception $error) {
$status = array("status" => false, "arrGTXMarkups" => [], "arrAgencyMarkups" => [], 'arrApiServiceTax' => [], 'arrAgencyMarkupsHotel' => [], "message" => $error->getMessage());
return $status;
}
}
public function getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType) {
if ($intCountryCode) {
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
if($B2BType){
$crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
$AgencySysId__ = isset($customerDetails['AgencySysId']) ? $customerDetails['AgencySysId'] : 0;
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId__);
$B2CAgencySysIdKey = $arrAgentDetail['SecurityKey'];
$B2BAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$apiDataIV = array(
"B2BAgencySysIdKey" => $B2BAgencySysIdKey,
"B2CAgencySysIdKey" => $B2CAgencySysIdKey,
"MasterAgencySysId" => $this->intLoggedinAgencyId,
"PlanType" => 1,
);
}else{
$apiDataIV = array(
'B2CAgencySysIdKey' => $this->agencyDetails['SecurityKey'],
'PlanType' => 1,
'IsB2C' => 1,
'MasterAgencySysId' => $this->intLoggedinAgencyId,
'IsB2CLoggedIn' => 0,
);
}
$model = new Gtxwebservices_Model_Webservices();
$result = json_decode($model->getMarkupAndServiceTaxNew($apiDataIV), true);
if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
$intAirType = 2;
} else {
$intAirType = 1;
}
$arrAgencyMarkups = [];
if ($result['data']) {
foreach ($result['data'] as $k => $vl) {
$ItemSourceType = $vl['ItemSourceType'];
if ($intAirType == $ItemSourceType) {
$arrAgencyMarkups[$k] = $vl;
$arrAgencyMarkups[$k]['CommssionType'] = 2;
$arrAgencyMarkups[$k]['CommssionVal'] = $vl['Commission'];
$arrAgencyMarkups[$k]['StdMarkUpPer'] = $vl['MarkUpValue'];
}
}
}
$TaxSetting = [];
if ($result['TaxSetting']) {
foreach ($result['TaxSetting'] as $ks => $val) {
$TaxSetting[$k] = $val;
$TaxSetting[$k]['Percentage'] = $val['TaxPercentage'];
}
}
return ['arrAgencyMarkups'=>$arrAgencyMarkups,'arrApiServiceTax'=>array_values($TaxSetting)];
}
}
public function FlightDataTBO($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup) {
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
//
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// echo "<pre>"; print_r($preferredFlightClassType);
// echo "<pre>"; print_r($arrFlightClass);
// echo "<pre>"; print_r($cabinClass); exit;
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = $sessionFlightSearchParams['return_dates'];
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
// echo "<pre>"; print_r($getMarkup);echo "</pre>";
// echo "<pre>"; print_r($AdditionalMarkup);echo "</pre>";
// die;
$getCancelCharge = $this->getCancelCharge($intCountryCode);
$strDepatureDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strDepatureDate, 'd/m/y');
$strReturnDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strReturnDate, 'd/m/y');
$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
if ($intResponseStatus == 1) {
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$arrInsertFlightData = [];
$arrInsertFlightDataNew = [];
$keysIndexes = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltSupplier = [];
$FiltPriceRange = [];
$AttPriceRange = [];
foreach ($apiResponse['OutBoundFlightResults'] as $key => $result) {
//echo "<pre>"; print_r($result); IsMealIncludes
$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
$ResultIndex = $result['ResultIndex'];
$FareClassification = $result['FareClassification']['Type'];
$FareColor = $result['FareClassification']['Color'];
$Source = $result['Source'];
$IsLCC = $result['IsLCC'];
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
$IsRefundable = ($result['IsRefundable']) ? 1 : 0;
$AirlineRemark = $result['AirlineRemark'];
$AirlineCode = $result['AirlineCode'];
$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
$MiniFR = [];
if ($MiniFareRules) {
foreach ($MiniFareRules as $Minivalue) {
if ($Minivalue) {
foreach ($Minivalue as $kk => $Mini) {
$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
if (empty($Mini['To'])) {
$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
} else {
$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
}
//$MiniFR[$Type][$kk] = $Mini;
$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
$MiniFR[$Type][$kk]['policyInfo'] = [];
}
}
}
}
$tripbinfo = [];
if ($result['Segments']) {
foreach ($result['Segments'] as $value) {
if ($value) {
foreach ($value as $kk => $vl) {
$Baggage = $vl['Baggage'];
$CabinBaggage = $vl['CabinBaggage'];
$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
if (!empty($childCount)) {
$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
}
if (!empty($infantCount)) {
$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
}
}
}
}
}
$LastTicketDate = $result['LastTicketDate'];
$TicketAdvisory = $result['TicketAdvisory'];
$AirlineCode = $result['AirlineCode'];
$ValidatingAirline = $result['ValidatingAirline'];
$Currency = $result['Fare']['Currency'];
$currencySysId = $this->CurrencyId;
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$ResultFareType = !empty($result['FareClassification']['Type']) ? $result['FareClassification']['Type'] : $result['ResultFareType'];
$FareBreakdown = $result['FareBreakdown'];
$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
$TotalPassengerCountForDiscount = $adultCount + $childCount;
$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
//$intDiscountPerHead = $totalCommissions;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $totalCommissions,
'TdsOnPLB' => $totalCommissionsOnTds,
'MUFee' => $ServiceFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
//echo "<pre>"; print_r($arrMarkUps);echo "</pre>"; ServiceFee
$intPublishedFare = $arrMarkUps['PublishFare'];
$countBreakUp = count($FareBreakdown);
foreach ($FareBreakdown as $pk => $pax) {
$intBaseFare = $pax['BaseFare'];
$intTax = $pax['Tax'];
$OtherCharges_ = ($OtherCharges / $countBreakUp);
$intDiscountPerHead_ = ($intDiscountPerHead / $countBreakUp);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead_;
$intFareOfferedToPax = $intBaseFareCal + $intTax;
$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
$arrFareBreakdown[$pk]['BaseFare'] = $pax['BaseFare'];
$arrFareBreakdown[$pk]['Tax'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges_);
$arrFareBreakdown[$pk]['ServiceFee'] = ($ServiceFee / $countBreakUp);
$arrFareBreakdown[$pk]['TDS'] = ($arrMarkUps['TripjackTDS'] / $countBreakUp);
$arrFareBreakdown[$pk]['MF'] = 0;
$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
$arrFareBreakdown[$pk]['AGST'] = 0;
$arrFareBreakdown[$pk]['MFT'] = 0;
$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
$arrFareBreakdown[$pk]['MU'] = ($ServiceFee / $countBreakUp);
$arrFareBreakdown[$pk]['YR'] = 0;
$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommisionPass'] = ($arrMarkUps['CommisionPass'] / $countBreakUp);
$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
; //($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTonComm'] = 0;
$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
$arrFareBreakdown[$pk]['PGCharge'] = 0;
$arrFareBreakdown[$pk]['NetFare'] = ($OfferedFare / $countBreakUp);
$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;
}
$arrFairRules[0] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => $PublishedFare,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"PriceID" => $ResultIndex,
"ApiResultIndex" => $ResultIndex,
"IsGSTRequired" => $IsGSTMandatory,
"fareIdentifier" => $fareIdentifier,
"colors" => $fareIdcolor,
"fareremarks" => $fareremarks,
"FareClass" => $cabinClass,
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"CommisionPass" => $arrMarkUps['CommisionPass'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"FareBreakdown" => $arrFareBreakdown,
"tripbinfo" => $tripbinfo,
"arrMarkUps" => $arrMarkUps,
"MiniFR" => $MiniFR,
);
//echo '<pre>';print_r($arrFairRules);die;
$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $result['Segments'][0][0]['Airline']['AirlineName'];
$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
$AccumulatedDuration = 0;
$arrSegments = [];
$FareClassArr = [];
if (!empty($result['Segments'][0])) {
$FlyingMinutes = 0;
$countSeg = count($result['Segments'][0]);
foreach ($result['Segments'][0] as $segmentsResult) {
$Duration = $segmentsResult['Duration'];
if ($countSeg >= 2) {
$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
} else {
$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
}
$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + $segmentsResult['GroundTime']));
$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
$DepTime = $segmentsResult['Origin']['DepTime'];
$ArrTime = $segmentsResult['Destination']['ArrTime'];
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
if (!empty($strBaggage)) {
$IsBaggage = 1;
$IsBagIncludes = true;
} else {
$IsBaggage = 0;
$IsBagIncludes = false;
}
if (!empty($strCabinBaggage)) {
$strCabinBaggage = $strCabinBaggage;
} else {
$strCabinBaggage = '0 KG';
}
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$FareClassArr[] = $FareClass;
$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;
$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
if (!empty($DepTerminal)) {
$DepTerminal = $DepTerminal;
} else {
$DepTerminal = 0;
}
$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
if (!empty($ArrTerminal)) {
$ArrTerminal = $ArrTerminal;
} else {
$ArrTerminal = 0;
}
$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$strAirlineCodeLogo = $strAirlineCode;
$filePath = $this->getflightlogo($strAirlineCodeLogo);
//$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($ArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DepTime);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
// $strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateTotalTime($strArrivalDtTime,$strDepartureDtTime);
$arrSegments[] = array(
"segmentid" => $FlightNumber,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $strAirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => $TripIndicator,
"isReturnSegment" => ($TripIndicator == 1) ? false : true,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"SegmentIndicator" => $SegmentIndicator,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"StopPointDepartureTime" => $StopPointDepartureTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
// FOR FLIGHT SEGMENTS.....
}
}
$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
$FlyingMinutes = $AccumulatedDuration;
if (count($result['Segments'][0]) == 1) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][0]['Destination'];
} elseif (count($result['Segments'][0]) == 2) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][1]['Destination'];
} elseif (count($result['Segments'][0]) == 3) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][2]['Destination'];
}
$strSourceAirportCode = $DepOrigin['Airport']['AirportCode'];
$strDestinationAirportCode = $DepDestination['Airport']['AirportCode'];
if (count($result['Segments'][0]) > 1) {
$SegmentsCount = count($result['Segments'][0]);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
$initialOriginArrTime = $result['Segments'][0][1]['Destination']['ArrTime'];
} else {
$StopOver_ = isset($result['Segments'][0][0]['StopOver']) ? $result['Segments'][0][0]['StopOver'] : false;
$StopCount = ($StopOver_) ? $StopOver_ : '0';
//$StopCount = '0';
$IsDirect = '1';
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
$initialOriginArrTime = $result['Segments'][0][0]['Destination']['ArrTime'];
}
// echo '<pre>';print_r($StopCount);
$strAirlineCodeEX = explode("-", trim($strFlightNumber));
$strAirlineCodeLogo = $strAirlineCodeEX[0];
$filePath = $this->getflightlogo($strAirlineCodeLogo);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($initialOriginArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($initialOriginDepTime);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
if ($StopCount == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $StopCount . " Stop(s)";
}
if ($IsRefundable) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Non Refundable';
}
$classOfBooking = implode(',', $FareClassArr);
$arrFairRules[0]['classOfBooking'] = $classOfBooking;
//$arrFairRules[0]['FareClass'] = $FlightClass;
$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
$arrFairRules[0]['FareKey'] = str_replace('_', ' ', $ResultFareType) . '' . $classOfBooking;
$intJourneyType = 1;
$intTripType = 1;
$localFromDateTime = str_replace(' ', 'T', $initialOriginDepTime); //date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = str_replace(' ', 'T', $initialOriginArrTime); //date("Y-m-d h:i", strtotime($strReturnDate));
$newKey = $initialOriginDepTime . '' . $initialOriginArrTime . '' . $strFlightNumber;
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['ApiSource'] = $Source;
$arrInsertFlightData[$key]['AirlineRemark'] = $AirlineRemark;
$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['TravelDate'] = $localFromDateTime;
$arrInsertFlightData[$key]['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData[$key]['LocalToTime'] = $localToDateTime;
$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
$arrInsertFlightData[$key]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($localFromDateTime));
$arrInsertFlightData[$key]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($localToDateTime));
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($localFromDateTime));
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['FlightClass'] = $FlightClass;
$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$key]['Stops'] = $StopCount;
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $currencySysId;
$arrInsertFlightData[$key]['Currency'] = $this->CurrencyTitle;
$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 2';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 0;
$arrInsertFlightData[$key]['IsNewMigration'] = 1;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['FilterKey'] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $initialOriginArrTime . '' . $initialOriginDepTime;
$arrAirlineName[] = $AirlineCode . '-' . ucwords(strtolower($strAirlineName));
$AttPriceRange[] = $intPublishedFare * $this->CurrencyRate;
$FiltStopCount[] = $StopCountTxt;
$FiltSupplier[] = 'Supplier 2';
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
$value = ($arrInsertFlightData[$key]);
if (!array_key_exists($newKey, $keysIndexes)) {
array_push($arrInsertFlightDataNew, $value);
$keysIndexes[$newKey] = sizeof($keysIndexes);
} else {
array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
}
}
//echo '<pre>';print_r($arrInsertFlightData);
if ($interNationalSearch == 1 && $strFlightRoute == 2) {
$RoundTrip = $this->FlightDataInterRoundTripTBO($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup);
return $RoundTrip;
} else {
$RoundTrip = $this->FlightDataRoundTripTBO($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup);
if (isset($RoundTrip['inbound']) && !empty($RoundTrip['inbound'])) {
$AttPriceRange = array_merge($AttPriceRange, $RoundTrip['AttPriceRange']);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, $RoundTrip['FiltSupplier'])));
}
return ['outbound' => $arrInsertFlightDataNew, 'inbound' => $RoundTrip['inbound'], 'FiltSupplier' => array_values(array_unique($FiltSupplier)), 'AttPriceRange' => array_values(array_unique($AttPriceRange)), 'FiltStopCount' => array_values(array_unique($FiltStopCount)), 'arrAirlineName' => array_values(array_unique($arrAirlineName))];
}
}
}
public function FlightDataRoundTripTBO($apiResponse, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup) {
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
//
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// echo "<pre>"; print_r($preferredFlightClassType);
// echo "<pre>"; print_r($arrFlightClass);
// echo "<pre>"; print_r($cabinClass); exit; DestPlaceName
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = $sessionFlightSearchParams['return_dates'];
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
// $getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
// $getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$getCancelCharge = $this->getCancelCharge($intCountryCode);
$strDepatureDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strDepatureDate, 'd/m/y');
$strReturnDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strReturnDate, 'd/m/y');
$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
if ($intResponseStatus == 1) {
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$arrInsertFlightData = [];
$arrInsertFlightDataNew = [];
$keysIndexes = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltSupplier = [];
$FiltPriceRange = [];
$AttPriceRange = [];
foreach ($apiResponse['InBoundFlightResults'] as $key => $result) {
$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
$ResultIndex = $result['ResultIndex'];
$FareColor = $result['FareClassification']['Color'];
$Source = $result['Source'];
$IsLCC = $result['IsLCC'];
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
$IsRefundable = ($result['IsRefundable']) ? 1 : 0;
$AirlineRemark = $result['AirlineRemark'];
$AirlineCode = $result['AirlineCode'];
$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
$MiniFR = [];
if ($MiniFareRules) {
foreach ($MiniFareRules as $Minivalue) {
if ($Minivalue) {
foreach ($Minivalue as $kk => $Mini) {
$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
if (empty($Mini['To'])) {
$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
} else {
$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
}
//$MiniFR[$Type][$kk] = $Mini;
$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
$MiniFR[$Type][$kk]['policyInfo'] = [];
}
}
}
}
$tripbinfo = [];
if ($result['Segments']) {
foreach ($result['Segments'] as $value) {
if ($value) {
foreach ($value as $kk => $vl) {
$Baggage = $vl['Baggage'];
$CabinBaggage = $vl['CabinBaggage'];
$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
if (!empty($childCount)) {
$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
}
if (!empty($infantCount)) {
$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
}
}
}
}
}
$LastTicketDate = $result['LastTicketDate'];
$TicketAdvisory = $result['TicketAdvisory'];
$AirlineCode = $result['AirlineCode'];
$ValidatingAirline = $result['ValidatingAirline'];
$Currency = $result['Fare']['Currency'];
$currencySysId = $this->CurrencyId;
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
//$ResultFareType = $result['ResultFareType'];
$ResultFareType = !empty($result['FareClassification']['Type']) ? $result['FareClassification']['Type'] : $result['ResultFareType'];
$FareBreakdown = $result['FareBreakdown'];
$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
$TotalPassengerCountForDiscount = $adultCount + $childCount;
$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $totalCommissions,
'TdsOnPLB' => $totalCommissionsOnTds,
'MUFee' => $ServiceFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
$intPublishedFare = $arrMarkUps['PublishFare'];
$countBreakUp = count($FareBreakdown);
foreach ($FareBreakdown as $pk => $pax) {
$intBaseFare = $pax['BaseFare'];
$intTax = $pax['Tax'];
$OtherCharges_ = ($OtherCharges / $countBreakUp);
$intDiscountPerHead_ = ($intDiscountPerHead / $countBreakUp);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead_;
$intFareOfferedToPax = $intBaseFareCal + $intTax;
$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
$arrFareBreakdown[$pk]['BaseFare'] = $pax['BaseFare'];
$arrFareBreakdown[$pk]['Tax'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges_);
$arrFareBreakdown[$pk]['ServiceFee'] = ($ServiceFee / $countBreakUp);
//$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
$arrFareBreakdown[$pk]['TDS'] = ($arrMarkUps['TripjackTDS'] / $countBreakUp);
$arrFareBreakdown[$pk]['MF'] = 0;
$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
$arrFareBreakdown[$pk]['AGST'] = 0;
$arrFareBreakdown[$pk]['MFT'] = 0;
$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
$arrFareBreakdown[$pk]['MU'] = ($ServiceFee / $countBreakUp);
$arrFareBreakdown[$pk]['YR'] = 0;
$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommisionPass'] = ($arrMarkUps['CommisionPass'] / $countBreakUp);
$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
; //($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTonComm'] = 0;
$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
$arrFareBreakdown[$pk]['PGCharge'] = 0;
$arrFareBreakdown[$pk]['NetFare'] = ($OfferedFare / $countBreakUp);
$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;
}
$arrFairRules[0] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => $PublishedFare,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"PriceID" => $ResultIndex,
"ApiResultIndex" => $ResultIndex,
"IsGSTRequired" => $IsGSTMandatory,
"fareIdentifier" => $fareIdentifier,
"colors" => $fareIdcolor,
"FareColor" => $FareColor,
"FareClass" => $cabinClass,
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"CommisionPass" => $arrMarkUps['CommisionPass'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"FareBreakdown" => $arrFareBreakdown,
//"arrMarkUps" => $arrMarkUps,
"tripbinfo" => $tripbinfo,
"MiniFR" => $MiniFR,
);
//echo '<pre>';print_r($arrFairRules);die;
$originCity = $result['Segments'][0][0]['Origin']['Airport']['CityName'];
$DestinationCity = $result['Segments'][0][0]['Destination']['Airport']['CityName'];
$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $result['Segments'][0][0]['Airline']['AirlineName'];
$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
$AccumulatedDuration = 0;
$arrSegments = [];
$FareClassArr = [];
if (!empty($result['Segments'][0])) {
$FlyingMinutes = 0;
$countSeg = count($result['Segments'][0]);
foreach ($result['Segments'][0] as $segmentsResult) {
$Duration = $segmentsResult['Duration'];
if ($countSeg >= 2) {
$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
} else {
$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
}
$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + $segmentsResult['GroundTime']));
$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
$DepTime = $segmentsResult['Origin']['DepTime'];
$ArrTime = $segmentsResult['Destination']['ArrTime'];
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
if (!empty($strBaggage)) {
$IsBaggage = 1;
$IsBagIncludes = true;
} else {
$IsBaggage = 0;
$IsBagIncludes = false;
}
if (!empty($strCabinBaggage)) {
$strCabinBaggage = $strCabinBaggage;
} else {
$strCabinBaggage = '0 KG';
}
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$FareClassArr[] = $FareClass;
$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;
$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
if (!empty($DepTerminal)) {
$DepTerminal = $DepTerminal;
} else {
$DepTerminal = 0;
}
$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
if (!empty($ArrTerminal)) {
$ArrTerminal = $ArrTerminal;
} else {
$ArrTerminal = 0;
}
$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$strAirlineCodeLogo = $strAirlineCode;
$filePath = $this->getflightlogo($strAirlineCodeLogo);
//$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($ArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DepTime);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
// $strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateTotalTime($strArrivalDtTime,$strDepartureDtTime);
$arrSegments[] = array(
"segmentid" => $FlightNumber,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $strAirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => $TripIndicator,
"isReturnSegment" => ($TripIndicator == 1) ? false : true,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"SegmentIndicator" => $SegmentIndicator,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"StopPointDepartureTime" => $StopPointDepartureTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
// FOR FLIGHT SEGMENTS.....
}
}
$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
$FlyingMinutes = $AccumulatedDuration;
if (count($result['Segments'][0]) == 1) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][0]['Destination'];
} elseif (count($result['Segments'][0]) == 2) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][1]['Destination'];
} elseif (count($result['Segments'][0]) == 3) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][2]['Destination'];
}
$strSourceAirportCode = $DepOrigin['Airport']['AirportCode'];
$strDestinationAirportCode = $DepDestination['Airport']['AirportCode'];
if (count($result['Segments'][0]) > 1) {
$SegmentsCount = count($result['Segments'][0]);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
$initialOriginArrTime = $result['Segments'][0][1]['Destination']['ArrTime'];
} else {
$StopOver_ = isset($result['Segments'][0][0]['StopOver']) ? $result['Segments'][0][0]['StopOver'] : false;
$StopCount = ($StopOver_) ? $StopOver_ : '0';
//$StopCount = '0';
$IsDirect = '1';
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
$initialOriginArrTime = $result['Segments'][0][0]['Destination']['ArrTime'];
}
// echo '<pre>';print_r($StopCount);
$strAirlineCodeEX = explode("-", trim($strFlightNumber));
$strAirlineCodeLogo = $strAirlineCodeEX[0];
$filePath = $this->getflightlogo($strAirlineCodeLogo);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($initialOriginArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($initialOriginDepTime);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
if ($StopCount == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $StopCount . " Stop(s)";
}
if ($IsRefundable) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Non Refundable';
}
$classOfBooking = implode(',', $FareClassArr);
$arrFairRules[0]['classOfBooking'] = $classOfBooking;
$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
$arrFairRules[0]['FareKey'] = str_replace('_', ' ', $ResultFareType) . '' . $classOfBooking;
$intJourneyType = 2;
$intTripType = 1;
$localFromDateTime = str_replace(' ', 'T', $initialOriginDepTime); //date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = str_replace(' ', 'T', $initialOriginArrTime); //date("Y-m-d h:i", strtotime($strReturnDate));
$newKey = $initialOriginDepTime . '' . $initialOriginArrTime . '' . $strFlightNumber;
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsTJFlightAPI'] = $this->IsTJFlightAPI;
$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['TravelDate'] = $localFromDateTime;
$arrInsertFlightData[$key]['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData[$key]['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData[$key]['LocalToTime'] = $localToDateTime;
$arrInsertFlightData[$key]['ToUTCTime'] = $initialOriginArrTime;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($localFromDateTime));
$arrInsertFlightData[$key]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($localToDateTime));
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($localFromDateTime));
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['IsDirect'] = $IsDirect;
$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['FlightClass'] = $FlightClass;
$arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$key]['Stops'] = '';
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $currencySysId;
$arrInsertFlightData[$key]['Currency'] = $this->CurrencyTitle;
$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare); // As Discussed with GG
$arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 2';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 0;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['IsNewMigration'] = 1;
$arrInsertFlightData[$key]['FilterKey'] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $initialOriginArrTime . '' . $initialOriginDepTime;
$arrAirlineName[] = $AirlineCode . '-' . ucwords(strtolower($strAirlineName));
$AttPriceRange[] = $intPublishedFare * $this->CurrencyRate;
$FiltStopCount[] = $StopCountTxt;
$FiltSupplier[] = 'Supplier 2';
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
$value = ($arrInsertFlightData[$key]);
if (!array_key_exists($newKey, $keysIndexes)) {
array_push($arrInsertFlightDataNew, $value);
$keysIndexes[$newKey] = sizeof($keysIndexes);
} else {
array_push($arrInsertFlightDataNew[$keysIndexes[$newKey]]['FairRules'], $value['FairRules'][0]);
}
}
return ['inbound' => $arrInsertFlightDataNew, 'FiltSupplier' => array_unique($FiltSupplier), 'AttPriceRange' => array_unique($AttPriceRange), 'FiltStopCount' => array_unique($FiltStopCount), 'arrAirlineName' => array_unique($arrAirlineName)];
}
}
public function FlightDataInterRoundTripTBO($apiResponse, $sessionFlightSearchParams) {
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClasses();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
// echo "<pre>"; print_r($preferredFlightClassType);
// echo "<pre>"; print_r($arrFlightClass);
// echo "<pre>"; print_r($cabinClass); exit;
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'] : '';
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$intTatalPaxCT = $adultCount + $childCount;
$getMarkup = $this->getMarkup($intCountryCode);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
$getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
$getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
//$strDepatureDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strDepatureDate, 'd/m/y');
//$strReturnDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strReturnDate, 'd/m/y');
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strSourceAirportCode = $sessionFlightSearchParams['from'];
$strDestinationAirportCode = $sessionFlightSearchParams['to'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => $strFlightRoute,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
if ($intResponseStatus == 1) {
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$DesFiltStopCount = [];
$FiltSupplier = [];
$AttPriceRange = [];
$FiltPriceRange = [];
$dddddddd = [];
foreach ($apiResponse['InterNationalFlightResults'] as $key => $result) {
$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : 0;
$ResultIndex = $result['ResultIndex'];
$Source = $result['Source'];
$IsLCC = $result['IsLCC'];
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
$AirlineCode = $result['AirlineCode'];
$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
$MiniFR = [];
if ($MiniFareRules) {
foreach ($MiniFareRules as $Minivalue) {
if ($Minivalue) {
foreach ($Minivalue as $kk => $Mini) {
$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
if (empty($Mini['To'])) {
$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
} else {
$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
}
//$MiniFR[$Type][$kk] = $Mini;
$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
$MiniFR[$Type][$kk]['policyInfo'] = [];
}
}
}
}
$tripbinfo = [];
if ($result['Segments']) {
foreach ($result['Segments'] as $value) {
if ($value) {
foreach ($value as $kk => $vl) {
$Baggage = $vl['Baggage'];
$CabinBaggage = $vl['CabinBaggage'];
$SectorsCode = $vl['Origin']['Airport']['AirportCode'] . '-' . $vl['Destination']['Airport']['AirportCode'];
$tripbinfo[$SectorsCode]['ADULT'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
if (!empty($childCount)) {
$tripbinfo[$SectorsCode]['CHILD'] = ['cabin' => $CabinBaggage, 'checkin' => $Baggage];
}
if (!empty($infantCount)) {
$tripbinfo[$SectorsCode]['INFANT'] = ['cabin' => $CabinBaggage, 'checkin' => 'NA'];
}
}
}
}
}
$AirlineCode = isset($result['AirlineCode']) ? $result['AirlineCode'] : '';
if (count($result['Segments'][0]) == 1) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][0]['Destination'];
$DepData = $result['Segments'][0][0];
} elseif (count($result['Segments'][0]) == 2) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][1]['Destination'];
$DepData = $result['Segments'][0][1];
} elseif (count($result['Segments'][0]) == 3) {
$DepOrigin = $result['Segments'][0][0]['Origin'];
$DepDestination = $result['Segments'][0][2]['Destination'];
$DepData = $result['Segments'][0][2];
}
if (count($result['Segments'][1]) == 1) {
$ArrOrigin = $result['Segments'][1][0]['Origin'];
$ArrDestination = $result['Segments'][1][0]['Destination'];
$ArrData = $result['Segments'][1][0];
} elseif (count($result['Segments'][1]) == 2) {
$ArrOrigin = $result['Segments'][1][0]['Origin'];
$ArrDestination = $result['Segments'][1][1]['Destination'];
$ArrData = $result['Segments'][1][1];
} elseif (count($result['Segments'][1]) == 3) {
$ArrOrigin = $result['Segments'][1][0]['Origin'];
$ArrDestination = $result['Segments'][1][2]['Destination'];
$ArrData = $result['Segments'][1][1];
}
$Currency = $result['Fare']['Currency'];
$currencySysId = $this->CurrencyId;
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
if (count($result['Segments'][0]) > 1) {
$SegmentsCount = count($result['Segments'][0]);
$OriginStopCount = $SegmentsCount - 1;
} else {
$OriginStopCount = '0';
}
if (count($result['Segments'][1]) > 1) {
$SegmentsCountDe = count($result['Segments'][1]);
$DestinationStopCount = $SegmentsCountDe - 1;
} else {
$DestinationStopCount = '0';
}
if ($OriginStopCount == 0) {
$OrStopCountTxt = "Non-stop";
} else {
$OrStopCountTxt = $OriginStopCount . " Stop(s)";
}
if ($DestinationStopCount == 0) {
$DeStopCountTxt = "Non-stop";
} else {
$DeStopCountTxt = $DestinationStopCount . " Stop(s)";
}
if ($result['IsRefundable']) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Non Refundable';
}
$Refundable = ($result['IsRefundable']) ? 1 : 0;
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$FareColor = $result['FareClassification']['Color'];
//$ResultFareType = $result['ResultFareType'];
$ResultFareType = !empty($result['FareClassification']['Type']) ? $result['FareClassification']['Type'] : $result['ResultFareType'];
$FareBreakdown = $result['FareBreakdown'];
$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
$TotalPassengerCountForDiscount = $adultCount + $childCount;
$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $totalCommissions,
'TdsOnPLB' => $totalCommissionsOnTds,
'MUFee' => $ServiceFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
$intPublishedFare = $arrMarkUps['PublishFare'];
$countBreakUp = count($FareBreakdown);
foreach ($FareBreakdown as $pk => $pax) {
$intBaseFare = $pax['BaseFare'];
$intTax = $pax['Tax'];
$OtherCharges_ = ($OtherCharges / $countBreakUp);
$intDiscountPerHead_ = ($intDiscountPerHead / $countBreakUp);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead_;
$intFareOfferedToPax = $intBaseFareCal + $intTax;
$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
$arrFareBreakdown[$pk]['Currency'] = $pax['Currency'];
$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
$arrFareBreakdown[$pk]['BaseFare'] = $pax['BaseFare'];
$arrFareBreakdown[$pk]['Tax'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges_);
$arrFareBreakdown[$pk]['ServiceFee'] = ($ServiceFee / $countBreakUp);
//$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
$arrFareBreakdown[$pk]['TDS'] = ($arrMarkUps['TripjackTDS'] / $countBreakUp);
$arrFareBreakdown[$pk]['MF'] = 0;
$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
$arrFareBreakdown[$pk]['AGST'] = 0;
$arrFareBreakdown[$pk]['MFT'] = 0;
$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
$arrFareBreakdown[$pk]['MU'] = ($ServiceFee / $countBreakUp);
$arrFareBreakdown[$pk]['YR'] = 0;
$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommisionPass'] = ($arrMarkUps['CommisionPass'] / $countBreakUp);
$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
; //($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTonComm'] = 0;
$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
$arrFareBreakdown[$pk]['PGCharge'] = 0;
$arrFareBreakdown[$pk]['NetFare'] = ($OfferedFare / $countBreakUp);
$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;
}
$arrFairRules[0] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => $PublishedFare,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"PriceID" => $ResultIndex,
"ApiResultIndex" => $ResultIndex,
"IsGSTRequired" => $IsGSTMandatory,
"fareIdentifier" => $fareIdentifier,
"colors" => $fareIdcolor,
"FareColor" => $FareColor,
"FareClass" => $cabinClass,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"classOfBooking" => $strFareClass,
"SeatAvailable" => $SeatAvailable,
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"CommisionPass" => $arrMarkUps['CommisionPass'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"FareBreakdown" => $arrFareBreakdown,
"FareKey" => str_replace('_', ' ', $ResultFareType) . '' . $strFareClass,
"tripbinfo" => $tripbinfo,
"MiniFR" => $MiniFR,
//"arrMarkUps" => $arrMarkUps,
);
$AccumulatedDuration = 0;
$AccumulatedDurationD = 0;
$arrSegments = [];
$FareClassArr = [];
$SegFlightNumberArr = [];
$DestSegFlightNumberArr = [];
if (!empty($result['Segments'])) {
foreach ($result['Segments'] as $skey => $segment) {
if ($segment) {
$FlyingMinutes = 0;
$countSeg = count($segment);
foreach ($segment as $segkey => $segmentsResult) {
$TripIndicator = $segmentsResult['TripIndicator'];
if ($TripIndicator == 2) {
$isReturnSegment = true;
} else {
$isReturnSegment = false;
}
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : ($segmentsResult['Duration'] + $segmentsResult['GroundTime']));
$LAYOVERMinutes = ((isset($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : 0));
$DepTime = $segmentsResult['Origin']['DepTime'];
$ArrTime = $segmentsResult['Destination']['ArrTime'];
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
if (!empty($strBaggage)) {
$IsBaggage = 1;
$IsBagIncludes = true;
} else {
$IsBaggage = 0;
$IsBagIncludes = false;
}
if (!empty($strCabinBaggage)) {
$strCabinBaggage = $strCabinBaggage;
} else {
$strCabinBaggage = '0 KG';
}
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$FareClassArr[] = $FareClass;
$SegFlightNumber = $strAirlineCode . "-" . $FlightNumber;
$DepTerminal = $segmentsResult['Origin']['Airport']['Terminal'];
if (!empty($DepTerminal)) {
$DepTerminal = $DepTerminal;
} else {
$DepTerminal = 0;
}
$ArrTerminal = $segmentsResult['Destination']['Airport']['Terminal'];
if (!empty($ArrTerminal)) {
$ArrTerminal = $ArrTerminal;
} else {
$ArrTerminal = 0;
}
$originAirportName = $segmentsResult['Origin']['Airport']['AirportName'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originCityName = $segmentsResult['Origin']['Airport']['CityName'];
$originCountryName = $segmentsResult['Origin']['Airport']['CountryName'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportName = $segmentsResult['Destination']['Airport']['AirportName'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationCityName = $segmentsResult['Destination']['Airport']['CityName'];
$destinationCountryName = $segmentsResult['Destination']['Airport']['CountryName'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$strAirlineCodeLogo = $strAirlineCode;
$filePath = $this->getflightlogo($strAirlineCodeLogo);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->convertMinutesToHoursFormat((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0));
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($ArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DepTime);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
if ($skey == 1) {
$SegFlightNumberArr[] = $SegFlightNumber;
if ($countSeg >= 2) {
$AccumulatedDuration += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
} else {
$AccumulatedDuration += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
}
} else {
$DestSegFlightNumberArr[] = $SegFlightNumber;
if ($countSeg >= 2) {
$AccumulatedDurationD += isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : (0);
} else {
$AccumulatedDurationD += ($segmentsResult['Duration'] + $segmentsResult['GroundTime']);
}
}
$arrSegments[] = array(
"isReturnSegment" => $isReturnSegment,
"segmentid" => $FlightNumber,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $strAirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => $TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"SegmentIndicator" => $SegmentIndicator,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"StopPointDepartureTime" => $StopPointDepartureTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
}
}
}
}
$classOfBooking = implode(',', array_values(array_unique($FareClassArr)));
$arrFairRules[0]['classOfBooking'] = $classOfBooking;
$arrFairRules[0]['IsRefundableTxt'] = $IsRefundableTxt;
$arrFairRules[0]['SeatAvailable'] = $NoOfSeatAvailable;
//echo "<pre>===="; print_r($DepOrigin);
$OrDepTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DepOrigin['DepTime']);
$OrArrTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DepDestination['ArrTime']);
//echo "<pre>-----"; print_r($OrDepTime);
$DeDepTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($ArrOrigin['DepTime']);
$DeArrTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($ArrDestination['ArrTime']);
$arrCommonInsVariables['localFromDateTime'] = $DepOrigin['DepTime'];
$arrCommonInsVariables['localToDateTime'] = $DepDestination['ArrTime'];
$OriFlyingMinutes = ($AccumulatedDuration);
$OriFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($OriFlyingMinutes);
$OrFlightNumber = $DepData['Airline']['AirlineCode'] . "-" . $DepData['Airline']['FlightNumber'];
$DeFlightNumber = $ArrData['Airline']['AirlineCode'] . "-" . $ArrData['Airline']['FlightNumber'];
$strAirlineCodeLogo = $DepData['Airline']['AirlineCode'];
$DesAirlineCodeLogo = $ArrData['Airline']['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$DepData['Airline']['AirlineCode']]) ? $arrAirlineList[$DepData['Airline']['AirlineCode']] : '0';
$DeFlyingMinutes = ($AccumulatedDurationD);
$DesFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($DeFlyingMinutes);
$OrifilePath = $this->getflightlogo($strAirlineCodeLogo);
$DesfilePath = $this->getflightlogo($DesAirlineCodeLogo);
//DepartureTime DestPlaceSysId
$arrInsertFlightData[$key]['origin']['FlightNumber'] = $DepData['Airline']['FlightNumber'];
$arrInsertFlightData[$key]['origin']['AirlineName'] = $strAirlineName = $DepData['Airline']['AirlineName'];
$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode = $DepData['Airline']['AirlineCode'];
$arrInsertFlightData[$key]['origin']['FareClass'] = $AirlineCode = $DepData['Airline']['FareClass'];
$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $OrFlightNumber;
$arrInsertFlightData[$key]['origin']['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
$arrInsertFlightData[$key]['origin']['Currency'] = $Currency;
$arrInsertFlightData[$key]['origin']['ResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['origin']['IsLCC'] = $result['IsLCC'];
$arrInsertFlightData[$key]['origin']['IsGSTMandatory'] = $IsGSTMandatory;
$arrInsertFlightData[$key]['origin']['IsRefundable'] = $result['IsRefundable'];
$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['origin']['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['origin']['DepatureDate'] = date('d M Y', strtotime($strDepatureDate));
$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($strDepatureDate));
$arrInsertFlightData[$key]['origin']['DepartureTime'] = $OrDepTime;
$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $OrArrTime;
$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $DepOrigin['Airport']['AirportCode'];
$arrInsertFlightData[$key]['origin']['SourceCityName'] = $DepOrigin['Airport']['CityName'];
$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $DepDestination['Airport']['AirportCode'];
$arrInsertFlightData[$key]['origin']['DestCityName'] = $DepDestination['Airport']['CityName'];
$arrInsertFlightData[$key]['origin']['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localFromDateTime'])) : '';
$arrInsertFlightData[$key]['origin']['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData[$key]['origin']['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localToDateTime'])) : '';
$arrInsertFlightData[$key]['origin']['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
$arrInsertFlightData[$key]['origin']['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($arrCommonInsVariables['localFromDateTime']));
$arrInsertFlightData[$key]['origin']['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($arrCommonInsVariables['localToDateTime']));
$arrInsertFlightData[$key]['origin']['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['origin']['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['origin']['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['origin']['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['origin']['StopCount'] = $OrStopCountTxt;
$arrInsertFlightData[$key]['origin']['Stops'] = $OriginStopCount;
$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = $DepData['NoOfSeatAvailable'];
$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['origin']['FlyingMinutes'] = $OriFlyingMinutes;
$arrInsertFlightData[$key]['origin']['FlightDuration'] = $OriFlightDuration;
$arrInsertFlightData[$key]['origin']['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['origin']['logo'] = $OrifilePath;
$arrCommonInsVariables['localFromDateTime'] = $ArrOrigin['DepTime'];
$arrCommonInsVariables['localToDateTime'] = $ArrDestination['ArrTime'];
$airlineSysId = !empty($arrAirlineList[$ArrData['Airline']['AirlineCode']]) ? $arrAirlineList[$ArrData['Airline']['AirlineCode']] : '0';
$arrInsertFlightData[$key]['destination']['FlightNumber'] = $ArrData['Airline']['FlightNumber'];
$arrInsertFlightData[$key]['destination']['AirlineName'] = $ArrData['Airline']['AirlineName'];
$arrInsertFlightData[$key]['destination']['AirlineCode'] = $ArrData['Airline']['AirlineCode'];
$arrInsertFlightData[$key]['destination']['SegFlightNumberArr'] = implode(', ', $DestSegFlightNumberArr);
$arrInsertFlightData[$key]['destination']['DeFlightNumber'] = $DeFlightNumber;
$arrInsertFlightData[$key]['destination']['FareClass'] = $ArrData['Airline']['FareClass'];
$arrInsertFlightData[$key]['destination']['Currency'] = $Currency;
$arrInsertFlightData[$key]['destination']['ResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['destination']['IsLCC'] = $result['IsLCC'];
$arrInsertFlightData[$key]['destination']['IsGSTMandatory'] = $IsGSTMandatory;
$arrInsertFlightData[$key]['destination']['IsRefundable'] = $result['IsRefundable'];
$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['destination']['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['destination']['ReturnDate'] = date('d M Y', strtotime($strReturnDate));
$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($strReturnDate));
$arrInsertFlightData[$key]['destination']['DepartureTime'] = $DeDepTime;
$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $DeArrTime;
$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $ArrOrigin['Airport']['AirportCode'];
$arrInsertFlightData[$key]['destination']['SourceCityName'] = $ArrOrigin['Airport']['CityName'];
$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $ArrDestination['Airport']['AirportCode'];
$arrInsertFlightData[$key]['destination']['DestCityName'] = $ArrDestination['Airport']['CityName'];
$arrInsertFlightData[$key]['destination']['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['destination']['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['destination']['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['destination']['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['destination']['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localFromDateTime'])) : '';
$arrInsertFlightData[$key]['destination']['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData[$key]['destination']['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localToDateTime'])) : '';
$arrInsertFlightData[$key]['destination']['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
$arrInsertFlightData[$key]['destination']['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($arrCommonInsVariables['localFromDateTime']));
$arrInsertFlightData[$key]['destination']['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($arrCommonInsVariables['localToDateTime']));
$arrInsertFlightData[$key]['destination']['StopCount'] = $DeStopCountTxt;
$arrInsertFlightData[$key]['destination']['Stops'] = $DestinationStopCount;
$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = $ArrData['NoOfSeatAvailable'];
$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['destination']['FlyingMinutes'] = $DeFlyingMinutes;
$arrInsertFlightData[$key]['destination']['FlightDuration'] = $DesFlightDuration;
$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['destination']['logo'] = $DesfilePath;
$fln = $arrInsertFlightData[$key]['origin']['FlightNumber'] . '' . $arrInsertFlightData[$key]['destination']['FlightNumber'];
$fcls = $arrInsertFlightData[$key]['origin']['FareClass'] . '' . $arrInsertFlightData[$key]['destination']['FareClass'];
$fromtime = $arrInsertFlightData[$key]['origin']['FromUTCTime'] . '' . $arrInsertFlightData[$key]['destination']['FromUTCTime'];
$totime = $arrInsertFlightData[$key]['origin']['ToUTCTime'] . '' . $arrInsertFlightData[$key]['destination']['ToUTCTime'];
$arrInsertFlightData[$key]['FilterKey'] = $fln . '' . $fcls . '' . $fromtime . '' . $totime;
$arrInsertFlightData[$key]['FlightNumber'] = $DepData['Airline']['AirlineCode'] . '-' . $DepData['Airline']['FlightNumber'];
$arrInsertFlightData[$key]['AirlineCode'] = $DepData['Airline']['AirlineCode'];
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
$arrInsertFlightData[$key]['DestAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['PublishedFare'] = $intPublishedFare; // As Discussed with GG LocalFromTime
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($intPublishedFare);
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['IsTJFlightAPI'] = !empty($this->IsTJFlightAPI) ? $this->IsTJFlightAPI : 0;
$arrInsertFlightData[$key]['strFlightRoute'] = $strFlightRoute;
$arrInsertFlightData[$key]['JourneyType'] = $strFlightRoute;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['IsLCC'] = $result['IsLCC'];
$arrInsertFlightData[$key]['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localFromDateTime'])) : '';
$arrInsertFlightData[$key]['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData[$key]['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? str_replace('T', ' ', ($arrCommonInsVariables['localToDateTime'])) : '';
$arrInsertFlightData[$key]['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
$arrInsertFlightData[$key]['IsGSTMandatory'] = $IsGSTMandatory;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['FlightClass'] = $cabinClass;
$arrInsertFlightData[$key]['FairRules'] = $arrFairRules;
$arrInsertFlightData[$key]['Stops'] = $OriginStopCount;
$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['IsRefundable'] = $Refundable;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['FlyingMinutes'] = ($OriFlyingMinutes + $DeFlyingMinutes);
$arrInsertFlightData[$key]['DepartureTime'] = $OrDepTime;
$arrInsertFlightData[$key]['ArrivalTime'] = $OrArrTime;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['IsNewMigration'] = 1;
$arrInsertFlightData[$key]['TripType'] = 2;
$arrInsertFlightData[$key]['JourneyType'] = 2;
$arrInsertFlightData[$key]['ICSourceSysId'] = 3;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 2';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 0;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $OrDepTime);
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[] = $Fare['PublishedFare'];
}
}
$AttPriceRange[] = $PublishedFare;
$arrAirlineName[] = $DepData['Airline']['AirlineCode'] . '-' . ucwords(strtolower($strAirlineName));
$FiltStopCount[] = $OrStopCountTxt;
$DesFiltStopCount[] = $DeStopCountTxt;
$FiltSupplier[] = 'Supplier 2';
}
sort($dddddddd);
$FiltPriceRangeU = (array_unique($FiltPriceRange));
$ArrPriceUnique = array_filter(array_values($FiltPriceRangeU));
$arrAirlineName = array_values(array_unique($arrAirlineName));
$FiltStopCount = array_unique($FiltStopCount);
$AttPriceRange = array_unique($AttPriceRange);
//echo "<pre>"; print_r($arrInsertFlightData); exit;
$data = array('outbound' => $arrInsertFlightData, 'dddddddd' => $dddddddd, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $ArrPriceUnique, 'AttPriceRange' => $AttPriceRange, 'FiltSupplier' => $FiltSupplier);
return $data;
} else {
return false;
}
}
public function FlightDataSeriesFare($response, $sessionFlightSearchParams, $intJourneyType = null) {
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$objFlight = new Travel_Model_TblFlight();
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$SearchTraceId = trim($sessionFlightSearchParams['SearchTraceId']);
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$FlightTraceId = trim($sessionFlightSearchParams['FlightTraceId']);
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$source_city = isset($sessionFlightSearchParams['source_city']) ? $sessionFlightSearchParams['source_city'] : '';
$destination_city = isset($sessionFlightSearchParams['destination_city']) ? $sessionFlightSearchParams['destination_city'] : '';
$source = isset($sessionFlightSearchParams['sourceCityAirportCode']) ? $sessionFlightSearchParams['sourceCityAirportCode'] : '';
$destination = isset($sessionFlightSearchParams['destinationCityAirportCode']) ? $sessionFlightSearchParams['destinationCityAirportCode'] : '';
if ($intJourneyType) {
$intJourneyType = $intJourneyType;
} else {
$intJourneyType = 1;
}
if ($infantCount > 0) {
$isIdobrMandatory = true;
} else {
$isIdobrMandatory = false;
}
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
//
// echo '<pre>';print_r($destinationAirportCodeData);die;
$intTripType = 1;
if ($intJourneyType == 2) {
$intTripType = 2;
}
$$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltPriceRange = [];
$AttPriceRange = [];
if ($response && !empty($response)) {
$key = 0;
foreach ($response as $result) {
$strTraceId = $result['id'] . '-' . $FlightTraceId;
$SupplierSysId = $result['Supplier'];
$SecurityKey = $result['SecurityKey'];
$CheckInLuggage = $result['CheckInLuggage'];
$InCabinLuggage = $result['InCabinLuggage'];
$FareRules = $result['Fare'];
$CancellationPolicy = $result['CancellationPolicy'];
$InternalRemarks = $result['InternalRemarks'];
$SegmentInformation = $result['airlineinventories'];
$airlineprices = $result['airlineprices'];
$CurrentAirlineprices = current($airlineprices);
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
$FNEX = explode('-', $OriginSegments['FlightNumber']);
$AirlineCode = substr($OriginSegments['FlightNumber'], 0, 2);//$FNEX[0];
$FlightNumber = $FNEX[1];
$strFlightNumber = $OriginSegments['FlightNumber'];
$strAirlineName = $OriginSegments['AirLines'];
$strDepartureDtTime = date('H:i', strtotime($OriginSegments['DepartureTime']));
$strArrivalDtTime = $OriginSegments['ArrivalTime'];
$FlightDuration = $OriginSegments['EstimateHours'];
$FlightDurationArr = explode(':', $FlightDuration);
$hours = isset($FlightDurationArr[0]) ? $FlightDurationArr[0] : 0;
$minutes = isset($FlightDurationArr[1]) ? $FlightDurationArr[1] : 0;
$strSourceAirportCode = $OriginSegments['FromCityCode'];
$strDestinationAirportCode = $DestinationSegments['ToCityCode'];
$Stops = $OriginSegments['Stops'];
$IsLCC = true;
$Currency = $result['Markup'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$filePath = $this->getflightlogo($AirlineCode);
if (!empty($CheckInLuggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$totalMarkup = 0;
$arrSegments = [];
if ($airlineprices) {
foreach ($airlineprices as $price) {
$arrSegments = array();
if ((int) $price['CurrentSeat'] > 0) {
if ($SegmentInformation) {
foreach ($SegmentInformation as $segments) {
// echo '<pre>';
// print_r($segments);
$FNEX = explode('-', $segments['FlightNumber']);
$AirlineCode = substr($segments['FlightNumber'], 0, 2);
$FlightNumber = $FNEX[1];
$FromTerminal = $segments['FromTerminal'];
$ToTerminal = $segments['ToTerminal'];
$SegFlightNumber = $segments['FlightNumber'];
$AirlineName = $segments['AirLines'];
$strDepartureDtTime = $segments['DepartureTime'];
$strArrivalDtTime = $segments['ArrivalTime'];
$strDuration = $segments['EstimateHours'];
$FlightDurationArr = explode(':', $strDuration);
$hours = isset($FlightDurationArr[0]) ? (int) $FlightDurationArr[0] : 0;
$minutes = isset($FlightDurationArr[1]) ? (int) $FlightDurationArr[1] : 0;
$FlightDurationTxt = $hours . ($hours > 1 ? ' hours' : 'hour') . ' ' . $minutes . ($minutes > 1 ? ' minutes' : ' minute');
$FromDate = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
$LocalToTime = date('Y-m-d H:i:s', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
$destinationArrTime = date('Y-m-d', strtotime('+' . $hours . ' hour +' . $minutes . ' minutes', strtotime($FromDate)));
//echo "<pre>";print_r($cenvertedTime);die;
$originAirportCode = $segments['FromCityCode'];
$destinationAirportCode = $segments['ToCityCode'];
$Stops = $segments['Stops'];
$filePathS = $this->getflightlogo($AirlineCode);
$condCity = "AirportCode = '" . $originAirportCode . "'";
$originAirportCodeData = $objFlight->getAirPortAutoSuggest($condCity);
$DescondCity = "AirportCode = '" . $destinationAirportCode . "'";
$destinationAirportCodeData = $objFlight->getAirPortAutoSuggest($DescondCity);
//$originAirportCodeData = $objFlight->getflightAirportData($originAirportCode);
//$destinationAirportCodeData = $objFlight->getflightAirportData($destinationAirportCode);
$originCityName = isset($originAirportCodeData[0]['label']) ? explode(',', $originAirportCodeData[0]['label']) : '';
$destinationCityName = isset($destinationAirportCodeData[0]['label']) ? explode(',', $destinationAirportCodeData[0]['label']) : '';
$arrSegments[] = array(
"destinationAirportCode" => $destinationAirportCode,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"originAirportCode" => $originAirportCode,
"Baggage" => $CheckInLuggage,
"CabinBaggage" => $InCabinLuggage,
"IsBaggage" => $IsBaggage,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $FlightDurationTxt,
"filePath" => $filePathS,
"originAirportName" => isset($originAirportCodeData[0]['label']) ? $originAirportCodeData[0]['label'] : '',
"destinationAirportName" => isset($destinationAirportCodeData[0]['label']) ? $destinationAirportCodeData[0]['label'] : '',
"originCityName" => isset($originCityName[0]) ? $originCityName[0] : '',
"originCountryName" => '',
"destinationCityName" => isset($destinationCityName[0]) ? $destinationCityName[0] : '',
"destinationCountryName" => '',
"destinationArrTime" => $destinationArrTime . 'T' . $strArrivalDtTime,
"FareClass" => '',
"originDepTime" => $price['FromDate'] . 'T' . $strDepartureDtTime,
"TripIndicator" => '', //$TripIndicator,
"IsMealIncludes" => 0,
"Duration" => '',
"GroundTime" => '',
"LAYOVERDuration" => '',
"LAYOVERCity" => '',
"DepTerminal" => $FromTerminal,
"ArrTerminal" => $ToTerminal,
);
//echo '<pre>';print_r($arrSegments);
}
}
$BaseFare = $price['Fare'];
$InfantFare = $price['InfantFare'];
$Taxes = $price['Taxes'];
$Markup = $price['Markup'];
$MarkupType = $price['MarkupType'];
$InfantMarkup = $price['InfantMarkup'];
if ($MarkupType == 1) {
$totalMarkup = $Markup;
} else {
$totalMarkup = ((($BaseFare + $Taxes) * $Markup) / 100);
}
$PublishedFareReverseAdultChild = ($BaseFare + $Taxes + $totalMarkup) * ($adultCount + $childCount);
$OfferedFare = ($BaseFare + $Taxes) * ($adultCount + $childCount);
$PublishedFareReverseInfant = ($InfantFare + $InfantMarkup) * $infantCount;
$PublishedFareReverse = $PublishedFareReverseAdultChild + $PublishedFareReverseInfant;
$NoOfSeatAvailable = $price['CurrentSeat'];
$BaseFareIN = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
$PriceID = $result['id'] . '_' . $price['id'];
$ADULT = array();
$ADULT = array('TAF' => 0, 'TF' => 0, 'BF' => $BaseFare, 'NCM' => 0);
$AD_MF = $AD_YQ = $AD_AGST = $AD_MFT = $AD_OT = $AD_MU = $AD_YR = $TdsOnPLBCal = $ADULTNCMTDS = $PLBEarned = $IncentiveEarned = 0;
$FareBreakdown = $FairRulesArr = [];
$FareBreakdown[0]['Currency'] = 'INR';
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $intMemberCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $intMemberCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $intMemberCount);
$FareBreakdown[0]['BaseFareCal'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
$FareBreakdown[0]['BaseFare'] = ($BaseFare * ($adultCount + $childCount)) + ($InfantFare * $infantCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $intMemberCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $intMemberCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $intMemberCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $intMemberCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $intMemberCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $intMemberCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $intMemberCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $intMemberCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $intMemberCount);
$FareBreakdown[0]['intTotalGST'] = 0;
$FareBreakdown[0]['apiMarkup'] = $Taxes * ($adultCount + $childCount);
$FareBreakdown[0]['IntCommission'] = 0;
$FareBreakdown[0]['apiTaxOnMarkup'] = 0;
$FareBreakdown[0]['FixedMarkUp'] = ($totalMarkup * ($adultCount + $childCount)) + ($InfantMarkup * $infantCount);
$FareBreakdown[0]['GSTOnMarkUp'] = 0;
$FareBreakdown[0]['CommEarned'] = 0;
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = 0;
$FareBreakdown[0]['GTXMarkUpGST'] = 0;
$FareBreakdown[0]['AgentMarkUp'] = 0;
$FareBreakdown[0]['GSTOnAgentMarkUp'] = 0;
$FareBreakdown[0]['Agencycommission'] = 0;
$FareBreakdown[0]['TotalCommssionVal_ag'] = 0;
$FareBreakdown[0]['AdminComminAmount_ag'] = 0;
$FareBreakdown[0]['AgentB2CEarning'] = 0;
$FareBreakdown[0]['CostToAgentCustomer'] = (int) ($PublishedFareReverse * $this->CurrencyRate);
$FareBreakdown[0]['CostToAgent'] = 0;
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['Baggage'] = $CheckInLuggage; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = $InCabinLuggage; //Cabin Baggage ;
$FairRulesArr[] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => '',
"YQTax" => '',
"OtherCharges" => 0,
"Discount" => 0, //$Discount,
"ServiceFee" => 0,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => $PublishedFareReverse,
"PublishedFare" => ($PublishedFareReverse * $this->CurrencyRate),
"PublishedFareAgent" => (int) ($PublishedFareReverse * $this->CurrencyRate),
"OfferedFareAgent" => (int) ($PublishedFareReverse * $this->CurrencyRate),
"OfferedFare" => (int) ($OfferedFare * $this->CurrencyRate),
"PLBEarned" => 0,
"IncentiveEarned" => 0,
"TdsOnPLB" => 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"OnwardAutoTicket" => $price['OnwardAutoTicket'],
"Refundable" => $price['IsRefundable'],
"IsRefundableTxt" => ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable',
"PriceID" => $PriceID,
"ApiResultIndex" => $PriceID,
"IsGSTRequired" => 0,
"fareIdentifier" => 'Special Deal',
"SeatAvailable" => $NoOfSeatAvailable,
"classOfBooking" => 0,
"FareClass" => '',
"intTotalGST" => 0,
"apiMarkup" => 0,
"IntCommission" => 0,
"apiTaxOnMarkup" => 0,
"FixedMarkUp" => ($totalMarkup * ($adultCount + $childCount)) + ($InfantMarkup * $infantCount),
"GSTOnMarkUp" => 0,
"CommEarned" => 0,
"CommEarnedAgent" => 0,
"GSTonComm" => 0,
"intGTXMarkUp" => (int) 0,
"GTXMarkUpGST" => 0,
"AgentMarkUp" => 0,
"GSTOnAgentMarkUp" => 0,
'Agencycommission' => 0,
'TotalCommssionVal_ag' => 0,
'AdminComminAmount_ag' => 0,
'AgentB2CEarning' => 0,
'CostToAgentCustomer' => (int) ($PublishedFareReverse * $this->CurrencyRate),
'CostToAgent' => 0,
"FareBreakdown" => $FareBreakdown,
"newFare" => 0,
"oldFare" => 0,
"arrMarkUps" => 0,
);
$arrInsertFlightData[$key]['Currency'] = $this->CurrencyTitle;
$arrInsertFlightData[$key]['CurrencyRate'] = $this->CurrencyRate;
$arrInsertFlightData[$key]['currencySysId'] = $this->CurrencyId;
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsRefundable'] = $price['IsRefundable'];
$arrInsertFlightData[$key]['OnwardAutoTicket'] = $price['OnwardAutoTicket'];
$arrInsertFlightData[$key]['IsRefundableTxt'] = ($price['IsRefundable'] == 1) ? 'Refundable' : 'Non-Refundable';
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['TravelDate'] = date('Y-m-d', strtotime($price['FromDate']));
$arrInsertFlightData[$key]['LocalFromTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
$arrInsertFlightData[$key]['FromUTCTime'] = date('Y-m-d', strtotime($price['FromDate'])) . ' ' . $strDepartureDtTime;
$arrInsertFlightData[$key]['LocalToTime'] = $LocalToTime;
$arrInsertFlightData[$key]['ToUTCTime'] = $LocalToTime;
$arrInsertFlightData[$key]['IsDirect'] = 0;
$arrInsertFlightData[$key]['FareClass'] = '';
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDurationTxt;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['StopCount'] = ($Stops > 0) ? $Stops . ' Stop(s)' : '0 Stop(s)';
$arrInsertFlightData[$key]['StopCountShow'] = ($Stops > 0) ? $Stops . ' Stop(s)' : 'Non Stop';
$arrInsertFlightData[$key]['Stops'] = $Stops;
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = (int) ($NoOfSeatAvailable);
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate));
$arrInsertFlightData[$key]['ApiResultIndex'] = $strTraceId;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['FareRules'] = strip_tags(html_entity_decode($FareRules));
$arrInsertFlightData[$key]['CancellationPolicy'] = strip_tags(html_entity_decode($CancellationPolicy));
$arrInsertFlightData[$key]['InternalRemarks'] = strip_tags(html_entity_decode($InternalRemarks));
$arrInsertFlightData[$key]['FromDate'] = date('d/m/Y', strtotime($price['FromDate']));
$arrInsertFlightData[$key]['FromDateSort'] = strtotime($price['FromDate']);
$arrInsertFlightData[$key]['IsRefundable'] = $price['IsRefundable'];
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($price['FromDate']));
$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($price['FromDate']));
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
$arrInsertFlightData[$key]['OnwardGroupPNR'] = ($price['OnwardAutoTicket'] == 1) ? $price['OnwardGroupPNR'] : '';
$arrInsertFlightData[$key]['OnwardGroupPNRDummy'] = $price['OnwardGroupPNR'];
$arrInsertFlightData[$key]['IsSeriesFareData'] = true;
$arrInsertFlightData[$key]['IsTJFlightAPI'] = false;
$arrInsertFlightData[$key]['isIdobrMandatory'] = $isIdobrMandatory;
$arrInsertFlightData[$key]['ICSourceSysId'] = 8;
$arrInsertFlightData[$key]['supplier'] = 'Series Fare';
$arrInsertFlightData[$key]['SupplierSysId'] = $SupplierSysId;
$arrInsertFlightData[$key]['IsSupplierInv'] = trim($sessionFlightSearchParams['SecurityKey']) != trim($SecurityKey) ? 1 : 0;
$key++;
//$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
$arrAirlineName[] = '-' . $strAirlineName;
$AttPriceRange[] = $PublishedFareReverse * $this->CurrencyRate;
$FiltStopCount[] = $Stops . ' Stop(s)';
$FiltSupplier[] = 'Series Fare';
}
}
}
}
$arrAirlineName = array_values(array_unique($arrAirlineName));
$FiltStopCount = array_values(array_unique($FiltStopCount));
$FiltSupplier = array_values(array_unique($FiltSupplier));
//$MinriceRange = (min($AttPriceRange));
//$MaxriceRange = (max($AttPriceRange));
$data = array('ResponseStatus' => true, 'outbound' => $arrInsertFlightData, 'inbound' => '', 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'AttPriceRange' => $AttPriceRange, 'FiltSupplier' => $FiltSupplier);
return $data;
} else {
$data = array('ResponseStatus' => false, 'outbound' => [], 'inbound' => [], 'AttPriceRange' => [], 'FiltStopCount' => [], 'arrAirlineName' => [], 'FiltSupplier' => []);
return $data;
}
}
private function getMarketPlace($MarketPlaceSysId,$filterData = array())
{
$URLMarketPlace = 'https://admin.globaltravelexchange.com/api/v1/agency/air-fare-type-b2b-market-place/?market_place_sys_id=' . $MarketPlaceSysId;
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyMarketPlace([], $URLMarketPlace, $this->agencyDetails['SecurityKey']); ///'F38C55F4-5771-4EED-AAB2-D1CE094AEB4E'
// $AgencyMarketPlaceSysId = $this->_session->data['AgencyMarketPlaceSysId'];
// $url = $this->baseUrl . "public/logs/AgencyMarketPlace/".$this->MasterAgencySysId.'_'.$AgencyMarketPlaceSysId."/response.json";
// $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);
// $str = curl_exec($ch);
// $response = json_decode($str, true);
// echo "<pre>";
// print_r($response);die;
$Market_Wise = isset($response['data']['Market_Wise']) ? $response['data']['Market_Wise'] : [];
$Flight_Full_API = isset($response['data']['Flight_Full_API']) ? $response['data']['Flight_Full_API'] : [];
$Flight_Series_Fare = isset($response['data']['Flight_Series_Fare']) ? $response['data']['Flight_Series_Fare'] : [];
if ($filterData['ApiSourceSysId'] == 1 || $filterData['ApiSourceSysId'] == 3) {
$new = array_filter($Market_Wise, function ($var) use ($filterData) {
return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']);
});
$newFullAPI = array_filter($Flight_Full_API, function ($var) use ($filterData) {
return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']);
});
$finalArr = [];
$faretypeArr = [];
if ($new) {
foreach ($new as $value) {
$markup_b2b = $value['mark_up_value'];
$color = $value['color_code'];
$faretype = $value['old_title'];
$faretype_rename = $value['title'];
$showhide_b2b = $value['is_display'];
$B2BRemark = $value['B2CRemark'];
$faretypeArr[] = $faretype;
$finalArr[$faretype] = array(
'faretype' => $faretype,
'faretype_rename' => $faretype_rename,
'fareIdentifier' => $faretype_rename,
'markup_b2c' => $markup_b2b,
'showhide_b2c' => $showhide_b2b,
'color' => $color,
'remarks' => $B2BRemark,
'ApiRoundTrip' => 0,
);
}
}
$AirlineWiseMarkup = [];
if ($newFullAPI) {
foreach ($newFullAPI as $value) {
$Code = trim($value['Code']);
$AirlineWiseMarkup[$Code]['MarkUpType'] = $value['MarkUpType'];
$AirlineWiseMarkup[$Code]['MarkUpValue'] = $value['MarkUpValue'];
}
}
$DataSet = ['finalArr' => $finalArr, 'faretypeArr' => $faretypeArr, 'AirlineWiseMarkup' => $AirlineWiseMarkup];
return $DataSet;
} else {
$new = array_filter($Flight_Series_Fare, function ($var) use ($filterData) {
return ($var['ApiSourceSysId'] == $filterData['ApiSourceSysId']
&& trim($var['Code']) == $filterData['FlightCode']
&& trim($var['FromAirportCode']) == $filterData['FromAirportCode']
&& trim($var['ToAirportCode']) == $filterData['ToAirportCode']
);
});
$Series_Fare = [];
if (!empty(array_values($new))) {
$fareNode = array_values($new);
$MarkUpType = isset($fareNode[0]['MarkUpType']) ? $fareNode[0]['MarkUpType'] : 0;
$MarkUpValue = isset($fareNode[0]['MarkUpValue']) ? $fareNode[0]['MarkUpValue'] : 0;
$Series_Fare = ['MarkUpValue' => $MarkUpValue, 'MarkUpType' => $MarkUpType];
}
$DataSet = ['Series_Fare' => $Series_Fare];
return $DataSet;
}
}
public function getflightsearchAction() {
error_reporting(1);
$getData = $this->getRequest()->getParams();
$forPackageSearch = isset($getData['forPackageSearch']) ? $getData['forPackageSearch'] : 0;
$post = json_decode(file_get_contents('php://input'), true);
if ($forPackageSearch == 1) {
$post = $getData;
}
$SearchID = $post['SearchID'];
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
// echo $isDevice;die('sss');
$objTempFlight = new Travel_Model_TblFlight();
$checkOptModel = new Payment_Model_Checkotp();
$FlightTempData = $objTempFlight->GetFlightTempData($SearchID);
$APIBookingData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$SecurityKey = $arrAgentDetail['SecurityKey'];
$sessionFlightSearchParams['SecurityKey'] = $SecurityKey;
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// $sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$typeQuick = trim($sessionFlightSearchParams['typeQuick']);
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = $sessionFlightSearchParams['return_dates'];
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$strDepatureDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strDepatureDate, 'd/m/y');
$strReturnDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strReturnDate, 'd/m/y');
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
$getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
$getMarkup = $getMarkupB2B;
$MarketPlaceSysId = isset($getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId']) ? $getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId'] : 0;
$MasterId = isset($getMarkup['arrAgencyMarkups'][0]['MasterId']) ? $getMarkup['arrAgencyMarkups'][0]['MasterId'] : 0;
if(empty($MasterId) || $MasterId == 0){
$MarketPlaceSysId = $MarketPlaceSysId;
}else{
$MarketPlaceSysId = $MasterId;
}
//$MarketPlaceSysId = 1158;
// $filterData = ['ApiSourceSysId' => 1];
// $getMarketPlace =$this->getMarketPlace($MarketPlaceSysId,$filterData);
// echo "<pre>"; print_r($getMarketPlace);
// echo "<pre>"; print_r($intCountryCode);
// echo "<pre>"; print_r($getMarkup);
// die;
$isagencySession = new Zend_Session_Namespace('isagencySession');
$isagency = $isagencySession->params;
$fareIdentifier = [];
$FlightNumber = [];
$FromUTCTime = [];
$ToUTCTime = [];
$fareIdentifier = [];
$classOfBooking = [];
$ExtraMarkupShare = [];
$AirlineCode = [];
$FareClassArr = [];
$FilterKey_ = [];
$FareKey_ = [];
$ISourceSysIdSelected = 0;
if ($isagency == 1) {
$addMarkupArr = $APIBookingData['postData']['addMarkup'];
$DiscountValueArr = $APIBookingData['postData']['discountvalue'];
$mobilenumber = $APIBookingData['postData']['mobilenumber'];
$countrycode = $APIBookingData['postData']['countrycode'];
$emailId = $APIBookingData['postData']['emailId'];
$leadId = $APIBookingData['postData']['leadId'];
$customername = $APIBookingData['postData']['customername'];
$senderEmailID = $APIBookingData['postData']['senderEmailID'];
$remarks = $APIBookingData['postData']['remarks'];
$FlightBookingData = ($APIBookingData['postData']['item']);
$ISourceSysIdSelected = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
$index = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $bk => $val) {
$addMarkup = $addMarkupArr[$index];
$discount = isset($DiscountValueArr[$index]) ? $DiscountValueArr[$index] : 0;
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax(($addMarkup - $discount), "F", 0);
$MarkupArrayServiceTax = (!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) && $arrServiceTaxOnNetPayable['serviceTaxAmount'] > 0) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$TotalMarkupWithTax = $addMarkup + $MarkupArrayServiceTax;
if ($interNationalSearch == '1' && $strFlightRoute == '2') {
if ($val['FairRules']) {
foreach ($val['FairRules'] as $kk => $Fare) {
$fareIdentifier[$val['JourneyType']][] = $Fare['fareIdentifier'];
$classOfBooking[$val['JourneyType']][] = $Fare['classOfBooking'];
}
}
$FareClassArr[$val['JourneyType']][] = $val['origin']['FareClass'] . '' . $val['destination']['FareClass'];
$FlightNumber[$val['JourneyType']][] = $val['origin']['FlightNumber'] . '' . $val['destination']['FlightNumber'];
$FromUTCTime[$val['JourneyType']][] = $val['origin']['FromUTCTime'] . '' . $val['destination']['FromUTCTime'];
$ToUTCTime[$val['JourneyType']][] = $val['origin']['ToUTCTime'] . '' . $val['destination']['ToUTCTime'];
} else {
if ($val['FairRules']) {
foreach ($val['FairRules'] as $kk => $Fare) {
$fareIdentifier[$val['JourneyType']][] = $Fare['fareIdentifier'];
$classOfBooking[$val['JourneyType']][] = $Fare['classOfBooking'];
}
}
if ($interNationalSearch == '1' && $strFlightRoute == '3') {
if ($val['FairRules']) {
foreach ($val['FairRules'] as $kk => $Fare) {
$FareKey_[$val['JourneyType']][] = $Fare['FareKey'];
}
}
$FilterKey_[$val['JourneyType']][] = $val['FilterKey'];
foreach ($val['FlightData'] as $kkg => $valFD) {
// echo "<pre>FlightData"; print_r($valFD['FilterKey']);
// $FareClassArr[$val['JourneyType']][$kkg][] = $valFD['FareClass'];
// $FlightNumber[$val['JourneyType']][$kkg][] = $valFD['FlightNumber'];
// $FromUTCTime[$val['JourneyType']][$kkg][] = isset($valFD['FromUTCTime'])?$valFD['FromUTCTime']:'';
// $ToUTCTime[$val['JourneyType']][$kkg][] = isset($valFD['ToUTCTime'])?$valFD['ToUTCTime']:'';
}
} else {
$FareClassArr[$val['JourneyType']][] = $val['FareClass'];
$FlightNumber[$val['JourneyType']][] = $val['FlightNumber'];
$FromUTCTime[$val['JourneyType']][] = $val['FromUTCTime'];
$ToUTCTime[$val['JourneyType']][] = $val['ToUTCTime'];
}
}
$ExtraMarkupShare[$val['JourneyType']][] = ['addMarkup' => $addMarkup, 'addMarkupTax' => $MarkupArrayServiceTax, 'discount' => $discount];
$index++;
$AirlineCode[] = $val['AirlineCode'];
}
}
}
$share_proposal_data = [
'FilterKey' => $FilterKey_,
'FareKey' => $FareKey_,
'fareIdentifier' => $fareIdentifier,
'classOfBooking' => $classOfBooking,
'ExtraMarkupShare' => $ExtraMarkupShare,
'FareClassArr' => $FareClassArr,
'FlightNumber' => $FlightNumber,
'FromUTCTime' => $FromUTCTime,
'ToUTCTime' => $ToUTCTime,
];
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
// echo "<pre>"; print_r($share_proposal_data);
// echo "<pre>"; print_r($FlightBookingData);
// exit;
$intJourneyType = 1;
$intTripType = $strFlightRoute;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltSupplier = [];
$FiltPriceRange = [];
$AttPriceRange = [];
$inbound = [];
$dddddddd = [];
$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
$FlightSearchResultsTBO = new Zend_Session_Namespace('FlightSearchResultsTBO');
// if (!empty($FlightSearchResults->params) || !empty($FlightSearchResultsTBO->params)) {
// $apiResponseTBO = $FlightSearchResultsTBO->params;
// $intResponseStatusTBO = !empty($apiResponseTBO['ResponseStatus']) ? $apiResponseTBO['ResponseStatus'] : '0';
// $FlightDataTBO = $this->FlightDataTBO($apiResponseTBO,$sessionFlightSearchParams);
// $apiResponse = $FlightSearchResults->params;
// } else {
if ($typeQuick == 'SeriesFare') {
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams, null, $this->intLoggedinAgencyId);
$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponse, $sessionFlightSearchParams, $intJourneyType);
if ($interNationalSearch == '' && $strFlightRoute == 2) {
$apiResponseRound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams, 'roundtrip', $this->intLoggedinAgencyId);
$FlightDataSeriesFareRound = $this->FlightDataSeriesFare($apiResponseRound, $sessionFlightSearchParams, 2);
}
if (isset($FlightDataSeriesFareRound['arrAirlineName']) && !empty($FlightDataSeriesFareRound['arrAirlineName'])) {
$arrAirlineName = array_values(array_unique(array_merge($FlightDataSeriesFare['arrAirlineName'], $FlightDataSeriesFareRound['arrAirlineName'])));
} else {
$arrAirlineName = array_values(array_unique($FlightDataSeriesFare['arrAirlineName']));
}
if (isset($FlightDataSeriesFareRound['FiltStopCount']) && !empty($FlightDataSeriesFareRound['FiltStopCount'])) {
$FiltStopCount = array_values(array_unique(array_merge($FlightDataSeriesFare['FiltStopCount'], $FlightDataSeriesFareRound['FiltStopCount'])));
} else {
$FiltStopCount = array_values(array_unique($FlightDataSeriesFare['FiltStopCount']));
}
if (isset($FlightDataSeriesFareRound['FiltSupplier']) && !empty($FlightDataSeriesFareRound['FiltSupplier'])) {
$FiltSupplier = array_values(array_unique(array_merge($FlightDataSeriesFare['FiltSupplier'], $FlightDataSeriesFareRound['FiltSupplier'])));
} else {
$FiltSupplier = array_values(array_unique($FlightDataSeriesFare['FiltSupplier']));
}
if (isset($FlightDataSeriesFareRound['AttPriceRange']) && !empty($FlightDataSeriesFareRound['AttPriceRange'])) {
$MinriceRange = (min(array_merge($FlightDataSeriesFare['AttPriceRange'], $FlightDataSeriesFareRound['AttPriceRange'])));
$MaxriceRange = (max(array_merge($FlightDataSeriesFare['AttPriceRange'], $FlightDataSeriesFareRound['AttPriceRange'])));
} else {
$MinriceRange = (min($FlightDataSeriesFare['AttPriceRange']));
$MaxriceRange = (max($FlightDataSeriesFare['AttPriceRange']));
}
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots(round($MinriceRange), round($MaxriceRange));
$FiltPrice = [];
if ($arrSearchedAirlinesPriceSlots) {
foreach ($arrSearchedAirlinesPriceSlots as $k => $val) {
$arrResSlots = explode("-", $val);
if ($k == 0) {
//$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($MinriceRange) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
} else if ($k == (count($arrSearchedAirlinesPriceSlots) - 1)) {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]) . ' and Above ';
} else {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[0]) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
}
}
}
$inbound = isset($FlightDataSeriesFareRound['outbound']) ? $FlightDataSeriesFareRound['outbound'] : [];
$data = array('outbound' => $FlightDataSeriesFare['outbound'], 'inbound' => $inbound, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'FiltPrice' => $FiltPrice, 'AttPriceRange' => $AttPriceRange, 'FiltSupplier' => $FiltSupplier, 'FlightRoute' => $strFlightRoute);
echo json_encode($data);
exit;
}
// if($strFlightRoute == 3){
// $this->FlightDataMultiCity($FlightSearchResults->params, $sessionFlightSearchParams, $share_proposal_data);
// }
// echo "<pre>"; print_r($share_proposal_data);die;
$apiResponseSF = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams, null, $this->intLoggedinAgencyId);
$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponseSF, $sessionFlightSearchParams, $intJourneyType);
$CheckApiActive = $objTempFlight->checkActiveAPI($this->intLoggedinAgencyId, 1);
$CheckApiActiveTJ = $objTempFlight->checkActiveAPI($this->intLoggedinAgencyId, 3);
$APISourceSysId = (isset($CheckApiActive['APISourceSysId']) && !empty($CheckApiActive['APISourceSysId'])) ? $CheckApiActive['APISourceSysId'] : '';
$APISourceSysIdTJ = (isset($CheckApiActiveTJ['APISourceSysId']) && !empty($CheckApiActiveTJ['APISourceSysId'])) ? $CheckApiActiveTJ['APISourceSysId'] : '';
$apiResponse = $FlightDataTBO = [];
if ($ISourceSysIdSelected == 7) {
$APISourceSysIdTJ = 0;
$APISourceSysId = 0;
}
if ($ISourceSysIdSelected == 3) {
$APISourceSysIdTJ = 0;
$APISourceSysId = 1;
}
if ($APISourceSysId == 1 && $APISourceSysIdTJ == 3) {
$filterData = ['ApiSourceSysId' => 1];
$AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->intLoggedinAgencyId);
$intResponseStatusTBO = !empty($apiResponseTBO['ResponseStatus']) ? $apiResponseTBO['ResponseStatus'] : '0';
$FlightDataTBO = $this->FlightDataTBO($apiResponseTBO, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup);
$sessionFlightSearchParams['preferredAirline'] = $AirlineCode;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripJack($sessionFlightSearchParams, $this->intLoggedinAgencyId);
} else if ($APISourceSysId == 1) {
$filterData = ['ApiSourceSysId' => 1];
$AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
$apiResponseTBO = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams, $this->intLoggedinAgencyId);
$intResponseStatusTBO = !empty($apiResponseTBO['ResponseStatus']) ? $apiResponseTBO['ResponseStatus'] : '0';
$FlightDataTBO = $this->FlightDataTBO($apiResponseTBO, $sessionFlightSearchParams, $getMarkup, $AdditionalMarkup);
} else if ($APISourceSysIdTJ == 3) {
$sessionFlightSearchParams['preferredAirline'] = $AirlineCode;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripJack($sessionFlightSearchParams, $this->intLoggedinAgencyId);
} else {
$sessionFlightSearchParams['preferredAirline'] = $AirlineCode;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsTripJack($sessionFlightSearchParams, $this->intLoggedinAgencyId);
}
if ($strFlightRoute == 3) {
$this->FlightDataMultiCity($apiResponse, $sessionFlightSearchParams, $share_proposal_data);
}
//echo "<pre>"; print_r($sessionFlightSearchParams);die;
$intResponseStatus = $apiResponse['ResponseStatus'];
$ONWARD = isset($apiResponse['OutBoundFlightResults']) ? $apiResponse['OutBoundFlightResults'] : '';
$FlightNumber__ = isset($share_proposal_data['FlightNumber'][1]) ? $share_proposal_data['FlightNumber'][1] : [];
$FareClass__ = isset($share_proposal_data['FareClassArr'][1]) ? $share_proposal_data['FareClassArr'][1] : [];
$FromUTCTime__ = isset($share_proposal_data['FromUTCTime'][1]) ? $share_proposal_data['FromUTCTime'][1] : [];
$ToUTCTime__ = isset($share_proposal_data['ToUTCTime'][1]) ? $share_proposal_data['ToUTCTime'][1] : [];
$classOfBooking__ = isset($share_proposal_data['classOfBooking'][1]) ? $share_proposal_data['classOfBooking'][1] : [];
$fareIdentifier__ = isset($share_proposal_data['fareIdentifier'][1]) ? $share_proposal_data['fareIdentifier'][1] : [];
$ExtraMarkupShare__ = isset($share_proposal_data['ExtraMarkupShare'][1]) ? $share_proposal_data['ExtraMarkupShare'][1] : [];
$SelectedFilter = [];
if (!empty($FlightNumber__)) {
foreach ($FlightNumber__ as $k => $flnum) {
$FareClass_ = $FareClass__[$k];
$ToUTCTime_ = $ToUTCTime__[$k];
$FromUTCTime_ = $FromUTCTime__[$k];
$fareIdentifier_ = $fareIdentifier__[$k];
$classOfBooking_ = $classOfBooking__[$k];
$ExtraMarkupShare_ = $ExtraMarkupShare__[$k];
$SelectedFilter[$k]['Flight'] = $flnum . '' . $FareClass_ . '' . $ToUTCTime_ . '' . $FromUTCTime_;
$SelectedFilter[$k]['Fare'] = $fareIdentifier_ . '' . $classOfBooking_;
$SelectedFilter[$k]['Markup'] = $ExtraMarkupShare_;
}
}
// echo '<pre>';print_r($SelectedFilter);echo '</pre> ============';die;
// echo '<pre>';print_r($apiResponse);echo '</pre>';
// die;
if ($intResponseStatus == 1 || $intResponseStatusTBO == 1) {
$filterData = ['ApiSourceSysId' => 3];
$AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
if (!empty($ONWARD)) {
foreach ($ONWARD as $key => $result) {
$SegmentInformation = $result['sI'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
$IsMealIncludes = isset($totalPriceList['fd']['ADULT']['mI']) ? $totalPriceList['fd']['ADULT']['mI'] : false;
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
$strTraceId = $totalPriceList['id'];
$ResultIndex = $totalPriceList['id'];
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
//
$arrSegments = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$PublishedFareReverse = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$intYQTaxToT = 0;
$intTotalOfferedForAllPax = 0;
$intBaseFareAllPax = 0;
$intTaxAllPax = 0;
$TotalLAYOVERMinutes = 0;
$segmentSector = [];
if ($SegmentInformation) {
foreach ($SegmentInformation as $seg => $segments) {
//echo '<pre>';print_r($segments);
$segmentid = $segments['id'];
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segmentid,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => ($seg + 1),
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
//echo '<pre>';print_r($arrSegments);
}
}
$AirlineCode = $OriginSegments['fD']['aI']['code'];
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
$tripbinfo = [];
if ($price['tai']['tbi']) {
foreach ($price['tai']['tbi'] as $keyss => $tbi) {
$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
$sectorKey = $segc['origin'] . '-' . $segc['destination'];
if ($tbi) {
foreach ($tbi as $kgk => $pbi) {
if ($pbi) {
foreach ($pbi as $gk => $vll) {
$tripbinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
}
}
}
}
}
}
$SeatAvailable = $fareDetail['ADULT']['sR'];
$classOfBooking = $fareDetail['ADULT']['cB'];
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
if (empty($fareIdentifier)) {
$fareIdentifier = $price['fareIdentifier'];
}
// echo '<pre>';print_r($AirlineCode);echo '</pre>';
// echo '<pre>';print_r($AddMarkup);echo '</pre>';
// die;
$IsMealIncludes = $fareDetail['ADULT']['mI'];
$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsCabinBaggage = true;
} else {
$IsCabinBaggage = false;
}
if (!empty($strBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = 0; //isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = ($NetFare - $TdsOnPLBCal);
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo '<pre>';print_r($markUpArr);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
if ($kp == 0) {
$PublishedFareReverse += ($arrMarkUps['PublishFare']);
}
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $adultCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = (float) str_replace('-', '', ($CHILDNCMTDS * $childCount));
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = (float) str_replace('-', '', ($INFANTNCMTDS * $infantCount));
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
//echo '<pre>';print_r($price);
$FairRulesArr[$kp] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => (float) isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"colors" => $colors,
"SeatAvailable" => $SeatAvailable,
"classOfBooking" => $classOfBooking,
"FareClass" => ucfirst($fareDetail['ADULT']['cc']),
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"IsBaggage" => $IsBaggage,
"IsCabinBaggage" => $IsCabinBaggage,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsMealIncludes" => $IsMealIncludes,
"FareBreakdown" => $FareBreakdown,
//"arrMarkUps" => $arrMarkUps,
"tripbinfo" => $tripbinfo,
"FareKey" => str_replace('_', ' ', $fareIdentifier) . '' . $classOfBooking,
);
// echo '<pre>';
// print_r($FairRulesArr[$kp]);
// echo '</pre>';
}
}
$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);
$AirlineCode = $OriginSegments['fD']['aI']['code'];
$FlightNumber = $OriginSegments['fD']['fN'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $OriginSegments['fD']['aI']['name'];
$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginSegments['da']['code'];
$strDestinationAirportCode = $DestinationSegments['aa']['code'];
$Stops = $DestinationSegments['sN'];
if ($Stops == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $Stops . " Stop(s)";
}
$filePath = $this->getflightlogo($AirlineCode);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DestinationSegments['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginSegments['dt']);
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['AgencySysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
$arrInsertFlightData[$key]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$key]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
$arrInsertFlightData[$key]['IsDirect'] = 0;
$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $destinationCityText[0];
// $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$key]['Stops'] = $Stops;
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate)); // As Discussed with GG
// $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['FilterKey'] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $DestinationSegments['at'] . '' . $OriginSegments['dt'];
$arrAirlineName[] = $AirlineCode . '-' . ucwords(strtolower($strAirlineName));
$AttPriceRange[] = $PublishedFareReverse;
$FiltStopCount[] = $StopCountTxt;
$FiltSupplier[] = 'Supplier 1';
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[] = $Fare['PublishedFare'];
}
}
}
}
$SelectedFilterRound = [];
if ($interNationalSearch == '' && $strFlightRoute == 2) {
$FlightNumber__ = isset($share_proposal_data['FlightNumber'][2]) ? $share_proposal_data['FlightNumber'][2] : [];
$FareClass__ = isset($share_proposal_data['FareClassArr'][2]) ? $share_proposal_data['FareClassArr'][2] : [];
$FromUTCTime__ = isset($share_proposal_data['FromUTCTime'][2]) ? $share_proposal_data['FromUTCTime'][2] : [];
$ToUTCTime__ = isset($share_proposal_data['ToUTCTime'][2]) ? $share_proposal_data['ToUTCTime'][2] : [];
$classOfBooking__ = isset($share_proposal_data['classOfBooking'][2]) ? $share_proposal_data['classOfBooking'][2] : [];
$fareIdentifier__ = isset($share_proposal_data['fareIdentifier'][2]) ? $share_proposal_data['fareIdentifier'][2] : [];
$ExtraMarkupShare__ = isset($share_proposal_data['ExtraMarkupShare'][2]) ? $share_proposal_data['ExtraMarkupShare'][2] : [];
if (!empty($FlightNumber__)) {
foreach ($FlightNumber__ as $k => $flnum) {
$FareClass_ = $FareClass__[$k];
$ToUTCTime_ = $ToUTCTime__[$k];
$FromUTCTime_ = $FromUTCTime__[$k];
$fareIdentifier_ = $fareIdentifier__[$k];
$classOfBooking_ = $classOfBooking__[$k];
$ExtraMarkupShare_ = $ExtraMarkupShare__[$k];
$SelectedFilterRound[$k]['Flight'] = $flnum . '' . $FareClass_ . '' . $ToUTCTime_ . '' . $FromUTCTime_;
$SelectedFilterRound[$k]['Fare'] = $fareIdentifier_ . '' . $classOfBooking_;
$SelectedFilterRound[$k]['Markup'] = $ExtraMarkupShare_;
}
}
}
$RoundTrip = $this->FlightDataRoundTripJack($apiResponse, $sessionFlightSearchParams,$getMarkup, $AdditionalMarkup);
if (isset($FlightDataTBO['AttPriceRange']) && !empty($FlightDataTBO['AttPriceRange'])) {
$dddddddd = array_merge($dddddddd, isset($RoundTrip['dddddddd']) ? $RoundTrip['dddddddd'] : [], $FlightDataTBO['AttPriceRange']);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, isset($RoundTrip['arrAirlineName']) ? $RoundTrip['arrAirlineName'] : [], $FlightDataTBO['arrAirlineName'])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, isset($RoundTrip['FiltStopCount']) ? $RoundTrip['FiltStopCount'] : [], $FlightDataTBO['FiltStopCount'])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, isset($RoundTrip['FiltSupplier']) ? $RoundTrip['FiltSupplier'] : [], $FlightDataTBO['FiltSupplier'])));
} else {
$dddddddd = array_merge($dddddddd, $RoundTrip['dddddddd']);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $RoundTrip['arrAirlineName'])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $RoundTrip['FiltStopCount'])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, $RoundTrip['FiltSupplier'])));
}
if (isset($FlightDataSeriesFare['FiltSupplier']) && !empty($FlightDataSeriesFare['FiltSupplier'])) {
$dddddddd = array_merge($dddddddd, $FlightDataSeriesFare['AttPriceRange']);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $FlightDataSeriesFare['arrAirlineName'])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $FlightDataSeriesFare['FiltStopCount'])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, $FlightDataSeriesFare['FiltSupplier'])));
} else {
$dddddddd = array_values(array_unique($dddddddd));
$arrAirlineName = array_values(array_unique($arrAirlineName));
$FiltStopCount = array_values(array_unique($FiltStopCount));
$FiltSupplier = array_values(array_unique($FiltSupplier));
}
sort($dddddddd);
$MaxriceRange = $this->getMax($dddddddd);
$MinriceRange = $this->getMin($dddddddd);
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots(round($MinriceRange), round($MaxriceRange));
$FiltPrice = [];
if ($arrSearchedAirlinesPriceSlots) {
foreach ($arrSearchedAirlinesPriceSlots as $k => $val) {
$arrResSlots = explode("-", $val);
if ($k == 0) {
//$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($MinriceRange) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
} else if ($k == (count($arrSearchedAirlinesPriceSlots) - 1)) {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]) . ' and Above ';
} else {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[0]) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
}
}
}
if ($interNationalSearch == 1 && $strFlightRoute == 2) {
$SelectedFilter = [];
$FlightNumber__ = isset($share_proposal_data['FlightNumber'][2]) ? $share_proposal_data['FlightNumber'][2] : [];
$FareClass__ = isset($share_proposal_data['FareClassArr'][2]) ? $share_proposal_data['FareClassArr'][2] : [];
$FromUTCTime__ = isset($share_proposal_data['FromUTCTime'][2]) ? $share_proposal_data['FromUTCTime'][2] : [];
$ToUTCTime__ = isset($share_proposal_data['ToUTCTime'][2]) ? $share_proposal_data['ToUTCTime'][2] : [];
$classOfBooking__ = isset($share_proposal_data['classOfBooking'][2]) ? $share_proposal_data['classOfBooking'][2] : [];
$fareIdentifier__ = isset($share_proposal_data['fareIdentifier'][2]) ? $share_proposal_data['fareIdentifier'][2] : [];
$ExtraMarkupShare__ = isset($share_proposal_data['ExtraMarkupShare'][2]) ? $share_proposal_data['ExtraMarkupShare'][2] : [];
if (!empty($FlightNumber__)) {
foreach ($FlightNumber__ as $k => $flnum) {
$FareClass_ = $FareClass__[$k];
$ToUTCTime_ = $ToUTCTime__[$k];
$FromUTCTime_ = $FromUTCTime__[$k];
$fareIdentifier_ = $fareIdentifier__[$k];
$classOfBooking_ = $classOfBooking__[$k];
$ExtraMarkupShare_ = $ExtraMarkupShare__[$k];
$SelectedFilter[$k]['Flight'] = $flnum . '' . $FareClass_ . '' . $FromUTCTime_ . '' . $ToUTCTime_;
$SelectedFilter[$k]['Fare'] = $fareIdentifier_ . '' . $classOfBooking_;
$SelectedFilter[$k]['Markup'] = $ExtraMarkupShare_;
}
}
$RoundInterTrip = $this->FlightDataRoundTripInternational($apiResponse, $getMarkup, $AdditionalMarkup);
$dddddddd = array_merge($dddddddd, isset($RoundInterTrip['dddddddd']) ? $RoundInterTrip['dddddddd'] : []);
$arrAirlineName = array_values(array_unique(isset($RoundInterTrip['arrAirlineName']) ? $RoundInterTrip['arrAirlineName'] : []));
$FiltStopCount = array_values(array_unique(isset($RoundInterTrip['FiltStopCount']) ? $RoundInterTrip['FiltStopCount'] : []));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, isset($RoundInterTrip['FiltSupplier']) ? $RoundInterTrip['FiltSupplier'] : [])));
if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound'])) {
$dddddddd = array_merge($dddddddd, isset($FlightDataTBO['AttPriceRange']) ? $FlightDataTBO['AttPriceRange'] : []);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, isset($FlightDataTBO['arrAirlineName']) ? $FlightDataTBO['arrAirlineName'] : [])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, isset($FlightDataTBO['FiltStopCount']) ? $FlightDataTBO['FiltStopCount'] : [])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, isset($FlightDataTBO['FiltSupplier']) ? $FlightDataTBO['FiltSupplier'] : [])));
}
sort($dddddddd);
$MaxriceRange = $this->getMax($dddddddd);
$MinriceRange = $this->getMin($dddddddd);
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots(round($MinriceRange), round($MaxriceRange));
$FiltPrice = [];
if ($arrSearchedAirlinesPriceSlots) {
foreach ($arrSearchedAirlinesPriceSlots as $k => $val) {
$arrResSlots = explode("-", $val);
if ($k == 0) {
//$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($MinriceRange) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
} else if ($k == (count($arrSearchedAirlinesPriceSlots) - 1)) {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]) . ' and Above ';
} else {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[0]) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
}
}
}
if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound'])) {
$outboundINT = array_values(array_merge(isset($RoundInterTrip['outbound']) ? $RoundInterTrip['outbound'] : [], $FlightDataTBO['outbound']));
} else {
$outboundINT = $RoundInterTrip['outbound'];
}
$data = array('outbound' => $outboundINT, 'inbound' => [], 'SelectedFilter' => $SelectedFilter, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'FiltPrice' => $FiltPrice, 'FiltSupplier' => $FiltSupplier, 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch);
} else {
if (isset($FlightDataTBO['outbound']) && !empty($FlightDataTBO['outbound'])) {
$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataTBO['outbound']));
}
if (isset($FlightDataTBO['inbound']) && !empty($FlightDataTBO['inbound']) && $strFlightRoute == 2 && isset($RoundTrip['inbound'])) {
$inbound = array_values(array_merge($RoundTrip['inbound'], $FlightDataTBO['inbound']));
} elseif (isset($FlightDataTBO['inbound'])) {
$inbound = $FlightDataTBO['inbound'];
} else {
$inbound = $RoundTrip['inbound'];
}
if (isset($FlightDataSeriesFare['outbound']) && !empty($FlightDataSeriesFare['outbound'])) {
$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataSeriesFare['outbound']));
}
//echo '<pre>';print_r($inbound);die;
if ($strFlightRoute == 2) {
$inbound = $inbound;
} else {
$inbound = [];
}
$data = array('outbound' => $arrInsertFlightData, 'inbound' => $inbound, 'SelectedFilter' => $SelectedFilter, 'SelectedFilterRound' => $SelectedFilterRound, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'FiltPrice' => $FiltPrice, 'FiltSupplier' => $FiltSupplier, 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch);
}
echo json_encode($data);
exit;
} else {
$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'FiltStopCount' => [], 'FiltPrice' => [], 'FiltSupplier' => [], 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch);
echo json_encode($data);
exit;
}
}
public function FlightDataRoundTripJack($apiResponse, $sessionFlightSearchParams, $getMarkup,$AdditionalMarkup) {
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = explode(',', $sessionFlightSearchParams['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams['destinationCityText']);
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$intJourneyType = 2;
$intTripType = $strFlightRoute;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltPriceRange = [];
$FiltSupplier = [];
$AttPriceRange = [];
$dddddddd = [];
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$apiResponseRound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlightsSeriesFare($sessionFlightSearchParams, 'roundtrip', $this->intLoggedinAgencyId);
$FlightDataSeriesFare = $this->FlightDataSeriesFare($apiResponseRound, $sessionFlightSearchParams, $intJourneyType);
// echo "<pre>";
// print_r($FlightDataSeriesFare);
// exit;
$intResponseStatus = $apiResponse['ResponseStatus'];
$RETURN = $apiResponse['InBoundFlightResults'];
if ($intResponseStatus == 1) {
if ($RETURN) {
foreach ($RETURN as $key => $result) {
$SegmentInformation = $result['sI'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
$strTraceId = $totalPriceList['id'];
$ResultIndex = $totalPriceList['id'];
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
$arrSegments = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$PublishedFareReverse = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$segmentSector = [];
if ($SegmentInformation) {
foreach ($SegmentInformation as $segments) {
//echo '<pre>';print_r($segments);
$segmentid = $segments['id'];
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segmentid,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => '', //$TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
}
}
$AirlineCode = $OriginSegments['fD']['aI']['code'];
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
$tripbinfo = [];
if ($price['tai']['tbi']) {
foreach ($price['tai']['tbi'] as $keyss => $tbi) {
$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
$sectorKey = $segc['origin'] . '-' . $segc['destination'];
if ($tbi) {
foreach ($tbi as $kgk => $pbi) {
if ($pbi) {
foreach ($pbi as $gk => $vll) {
$tripbinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
}
}
}
}
}
}
// echo '<pre>';
// print_r($fareDetail);
// echo '</pre>';
$SeatAvailable = $fareDetail['ADULT']['sR'];
$classOfBooking = $fareDetail['ADULT']['cB'];
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
if (empty($fareIdentifier)) {
$fareIdentifier = $price['fareIdentifier'];
}
$IsMealIncludes = $fareDetail['ADULT']['mI'];
$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsCabinBaggage = true;
} else {
$IsCabinBaggage = false;
}
if (!empty($strBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = 0; //isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = ($NetFare - $TdsOnPLBCal);
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo '<pre>';print_r($markUpArr);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
if ($kp == 0) {
$PublishedFareReverse += ($arrMarkUps['PublishFare']);
}
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $adultCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = (float) str_replace('-', '', ($CHILDNCMTDS * $childCount));
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = (float) str_replace('-', '', ($INFANTNCMTDS * $infantCount));
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
//echo '<pre>';print_r($price);
$FairRulesArr[$kp] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => (float) isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"colors" => $colors,
"SeatAvailable" => $SeatAvailable,
"classOfBooking" => $classOfBooking,
"FareClass" => $fareDetail['ADULT']['cc'],
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"IsBaggage" => $IsBaggage,
"IsCabinBaggage" => $IsCabinBaggage,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsMealIncludes" => $IsMealIncludes,
"FareBreakdown" => $FareBreakdown,
"FareKey" => str_replace('_', ' ', $fareIdentifier) . '' . $classOfBooking,
//"arrMarkUps" => $arrMarkUps,
"tripbinfo" => $tripbinfo,
);
// echo '<pre>';
// print_r($FairRulesArr[$kp]);
// echo '</pre>';
}
}
$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);
$AirlineCode = $OriginSegments['fD']['aI']['code'];
$FlightNumber = $OriginSegments['fD']['fN'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $OriginSegments['fD']['aI']['name'];
$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginSegments['da']['code'];
$strDestinationAirportCode = $DestinationSegments['aa']['code'];
$Stops = $DestinationSegments['sN'];
if ($Stops == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $Stops . " Stop(s)";
}
$filePath = $this->getflightlogo($AirlineCode);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
//$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DestinationSegments['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginSegments['dt']);
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$key]['AgencySysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
// $arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
$arrInsertFlightData[$key]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$key]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$key]['IsDirect'] = 0;
$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
// $arrInsertFlightData[$key]['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['SourcePlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['DestPlaceName'] = $sourceCityText[0];
// $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$key]['Stops'] = $Stops;
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate)); // As Discussed with GG
// $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['FilterKey'] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $DestinationSegments['at'] . '' . $OriginSegments['dt'];
$arrAirlineName[] = $AirlineCode . '-' . $strAirlineName;
$AttPriceRange[] = $PublishedFareReverse;
$FiltStopCount[] = $StopCountTxt;
$FiltSupplier[] = 'Supplier 1';
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[] = $Fare['PublishedFare'];
}
}
//$FiltPriceRange[] =
//$FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_5000), ($PublishedFare * $this->CurrencyRate));
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
// if ($FilterPrice) {
// $arrInsertFlightData[$key]['FilterPrice'] = $FilterPrice;
// }
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
}
}
sort($dddddddd);
$FiltPriceRangeU = (array_unique($FiltPriceRange));
$arrAirlineName = array_unique($arrAirlineName);
$FiltStopCount = array_unique($FiltStopCount);
$AttPriceRange = array_unique($AttPriceRange);
if (isset($FlightDataSeriesFare['FiltSupplier']) && !empty($FlightDataSeriesFare['FiltSupplier'])) {
$dddddddd = array_merge($dddddddd, $FlightDataSeriesFare['AttPriceRange']);
$arrAirlineName = array_values(array_unique(array_merge($arrAirlineName, $FlightDataSeriesFare['arrAirlineName'])));
$FiltStopCount = array_values(array_unique(array_merge($FiltStopCount, $FlightDataSeriesFare['FiltStopCount'])));
$FiltSupplier = array_values(array_unique(array_merge($FiltSupplier, $FlightDataSeriesFare['FiltSupplier'])));
} else {
$dddddddd = array_values(array_unique($dddddddd));
$arrAirlineName = array_values(array_unique($arrAirlineName));
$FiltStopCount = array_values(array_unique($FiltStopCount));
$FiltSupplier = array_values(array_unique($FiltSupplier));
}
if (isset($FlightDataSeriesFare['outbound']) && !empty($FlightDataSeriesFare['outbound'])) {
$arrInsertFlightData = array_values(array_merge($arrInsertFlightData, $FlightDataSeriesFare['outbound']));
}
$data = array('inbound' => $arrInsertFlightData, 'dddddddd' => $dddddddd, 'FiltSupplier' => $FiltSupplier, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $FiltPriceRangeU, 'AttPriceRange' => $AttPriceRange);
return ($data);
} else {
return false;
}
}
public function FlightDataRoundTripInternational($apiResponse, $getMarkup, $AdditionalMarkup) {
$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
if ($intResponseStatus == 1) {
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
//$arrCurrencyList = $this->getCurrencyIdsAndSymbolList();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
// echo '<pre>';print_r($sessionFlightSearchParams->params);die('s');
$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
$SearchTraceId = $sessionFlightSearchParams->params['SearchTraceId'];
$sourceCityText = explode(',', $sessionFlightSearchParams->params['sourceCityText']);
$destinationCityText = explode(',', $sessionFlightSearchParams->params['destinationCityText']);
$flight_class = trim($sessionFlightSearchParams->params['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => $strFlightRoute,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$DesFiltStopCount = [];
$FiltSupplier = [];
$AttPriceRange = [];
$FiltPriceRange = [];
$dddddddd = [];
// echo json_encode(current($apiResponse['OutBoundFlightResults']));die;
foreach ($apiResponse['OutBoundFlightResults'] as $key => $result) {
$SegmentInformation = $result['sI'];
$totalPriceList = $result['totalPriceList'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB']; //Cabin Baggage
$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Check In Baggage
$strTraceId = $totalPriceList['id'];
$ResultIndex = $totalPriceList['id'];
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$TempArr = [];
if ($SegmentInformation) {
$tp = 0;
foreach ($SegmentInformation as $k => $Segmentsss) {
$isReturnSegment = isset($Segmentsss['isRs']) ? $Segmentsss['isRs'] : false;
if (!$isReturnSegment) {
$TempArr['onward'][$k] = $Segmentsss;
} else {
$TempArr['return'][$k] = $Segmentsss;
}
}
}
//echo '<pre>';print_r($TempArr['onward']);
$OriginOnward = current($TempArr['onward']);
$DestinationOnward = end($TempArr['onward']);
$arrSegments = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$segmentSector = [];
$TotalDurationReturn = 0;
$TotalDurationOnward = 0;
$TotalLAYOVERMinutes = 0;
if ($SegmentInformation) {
foreach ($SegmentInformation as $segments) {
//echo '<pre>';print_r($segments);
$duration = $segments['duration'];
$segmentid = $segments['id'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
if (isset($segments['isRs']) && $segments['isRs'] == true) {
$isReturnSegment = true;
$TotalDurationReturn += ($duration + $LAYOVERMinutes);
} else {
$isReturnSegment = false;
$TotalDurationOnward += ($duration + $LAYOVERMinutes);
}
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segmentid,
"isReturnSegment" => $isReturnSegment,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => '', //$TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
}
}
$AirlineCode = $OriginOnward['fD']['aI']['code'];
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
$tripbinfo = [];
if ($price['tai']['tbi']) {
foreach ($price['tai']['tbi'] as $keyss => $tbi) {
$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
$sectorKey = $segc['origin'] . '-' . $segc['destination'];
if ($tbi) {
foreach ($tbi as $kgk => $pbi) {
if ($pbi) {
foreach ($pbi as $gk => $vll) {
$tripbinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
}
}
}
}
}
}
// echo '<pre>';
// print_r($fareDetail);
// echo '</pre>';
$SeatAvailable = $fareDetail['ADULT']['sR'];
$classOfBooking = $fareDetail['ADULT']['cB'];
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
if (empty($fareIdentifier)) {
$fareIdentifier = $price['fareIdentifier'];
}
$IsMealIncludes = $fareDetail['ADULT']['mI'];
$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsCabinBaggage = true;
} else {
$IsCabinBaggage = false;
}
if (!empty($strBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = 0; //isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = ($NetFare - $TdsOnPLBCal);
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo '<pre>';print_r($markUpArr);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
if ($kp == 0) {
$PublishedFareReverse += ($arrMarkUps['PublishFare']);
}
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[0]['Currency'] = 'INR';
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $adultCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[1]['Currency'] = 'INR';
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = (float) str_replace('-', '', ($CHILDNCMTDS * $childCount));
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[2]['Currency'] = 'INR';
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = (float) str_replace('-', '', ($INFANTNCMTDS * $infantCount));
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
//echo '<pre>';print_r($price);
$FairRulesArr[$kp] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => (float) isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"colors" => $colors,
"SeatAvailable" => $SeatAvailable,
"classOfBooking" => $classOfBooking,
"FareClass" => ucfirst($fareDetail['ADULT']['cc']),
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"IsBaggage" => $IsBaggage,
"IsCabinBaggage" => $IsCabinBaggage,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsMealIncludes" => $IsMealIncludes,
"FareBreakdown" => $FareBreakdown,
//"arrMarkUps" => $arrMarkUps,
"tripbinfo" => $tripbinfo,
"FareKey" => str_replace('_', ' ', $fareIdentifier) . '' . $classOfBooking,
);
// echo '<pre>';
// print_r($FairRulesArr[$kp]);
// echo '</pre>';
}
}
$TotalLAYOVERMinutesO = 0;
$FlyingMinutesO = 0;
$LAYOVERCityArrO = [];
if ($TempArr['onward']) {
foreach ($TempArr['onward'] as $onwd) {
$duration = isset($segments['duration']) ? $segments['duration'] : 0;
$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArrO[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
$FlyingMinutesO += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutesO += $LAYOVERMinutes;
}
}
//echo '<pre>';print_r($OriginOnward['dt'].$DestinationOnward['at']);echo '</pre>';
//echo $TotalLAYOVERMinutesO.'=='.$FlyingMinutesO.'<br>';
$LAYOVERTimeO = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutesO);
$AirlineCode = $OriginOnward['fD']['aI']['code'];
$FlightNumber = $OriginOnward['fD']['fN'];
//$strFlightNumber = $OriginOnward . "-" . $FlightNumber;
$strAirlineName = $OriginOnward['fD']['aI']['name'];
$OrFlightNumber = $AirlineCode . '-' . $FlightNumber;
$IsLCC = $OriginOnward['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginOnward['da']['code'];
$strDestinationAirportCode = $DestinationOnward['aa']['code'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$filePath = $this->getflightlogo($AirlineCode);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationOnward);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DestinationOnward['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginOnward['dt']);
$Stops = $DestinationOnward['sN'];
if ($Stops == 0) {
$OrStopCountTxt = "Non-stop";
} else {
$OrStopCountTxt = $Stops . " Stop(s)";
}
$arrCommonInsVariables['localFromDateTime'] = $OriginOnward['dt'];
$arrInsertFlightData[$key]['origin']['FlightNumber'] = $FlightNumber;
$arrInsertFlightData[$key]['origin']['AirlineName'] = $strAirlineName;
$arrInsertFlightData[$key]['origin']['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['origin']['OrFlightNumber'] = $OrFlightNumber;
$arrInsertFlightData[$key]['origin']['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['origin']['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['origin']['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$key]['origin']['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['origin']['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['origin']['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['origin']['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['origin']['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['origin']['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['origin']['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['origin']['TravelDate'] = $OriginOnward['dt'];
$arrInsertFlightData[$key]['origin']['LocalFromTime'] = str_replace('T', ' ', $OriginOnward['dt']);
$arrInsertFlightData[$key]['origin']['FromUTCTime'] = $OriginOnward['dt'];
$arrInsertFlightData[$key]['origin']['LocalToTime'] = str_replace('T', ' ', $DestinationOnward['at']);
$arrInsertFlightData[$key]['origin']['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginOnward['dt']));
$arrInsertFlightData[$key]['origin']['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationOnward['at']));
$arrInsertFlightData[$key]['origin']['ToUTCTime'] = $DestinationOnward['at'];
$arrInsertFlightData[$key]['origin']['IsDirect'] = 0;
$arrInsertFlightData[$key]['origin']['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['origin']['LAYOVERCity'] = isset($LAYOVERCityArrO[0]) ? $LAYOVERCityArrO[0] : '';
$arrInsertFlightData[$key]['origin']['GroundTime'] = $TotalLAYOVERMinutesO;
$arrInsertFlightData[$key]['origin']['LAYOVERDuration'] = $LAYOVERTimeO;
$arrInsertFlightData[$key]['origin']['FlyingMinutes'] = $FlyingMinutesO;
$arrInsertFlightData[$key]['origin']['DepartureDateTxt'] = date('D, d M', strtotime($OriginOnward['dt']));
$arrInsertFlightData[$key]['origin']['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationOnward['at']));
$arrInsertFlightData[$key]['origin']['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['origin']['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['origin']['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['origin']['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['origin']['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['origin']['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['origin']['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['origin']['StopCount'] = $OrStopCountTxt;
$arrInsertFlightData[$key]['origin']['Stops'] = $Stops;
$arrInsertFlightData[$key]['origin']['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['origin']['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['origin']['CurrencyType'] = 1;
$arrInsertFlightData[$key]['origin']['JourneyType'] = 1;
$arrInsertFlightData[$key]['origin']['TripType'] = $intTripType;
$arrInsertFlightData[$key]['origin']['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['origin']['logo'] = $filePath;
//// Rrturn variable
$TotalLAYOVERMinutesD = 0;
$FlyingMinutesD = 0;
$LAYOVERCityArrD = [];
if ($TempArr['return']) {
foreach ($TempArr['return'] as $onwd) {
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($onwd['cT']) ? $onwd['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArrD[] = isset($onwd['cT']) ? $onwd['aa']['city'] : '';
$FlyingMinutesD += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutesD += $LAYOVERMinutes;
}
}
$OriginReturn = current($TempArr['return']);
$DestinationReturn = end($TempArr['return']);
$arrCommonInsVariables['localToDateTime'] = $DestinationReturn['at'];
$AirlineCode = $OriginReturn['fD']['aI']['code'];
$FlightNumber = $OriginReturn['fD']['fN'];
//$strFlightNumber = $OriginReturn . "-" . $FlightNumber;
$strAirlineName = $OriginReturn['fD']['aI']['name'];
$DeFlightNumber = $AirlineCode . '-' . $FlightNumber;
$IsLCC = $OriginReturn['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginReturn['da']['code'];
$strDestinationAirportCode = $DestinationReturn['aa']['code'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERTimeD = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutesD);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationReturn);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DestinationReturn['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginReturn['dt']);
//// end return variable.
$Stops = $DestinationReturn['sN'];
if ($Stops == 0) {
$DeStopCountTxt = "Non-stop";
} else {
$DeStopCountTxt = $Stops . " Stop(s)";
}
$arrInsertFlightData[$key]['destination']['FlightNumber'] = $FlightNumber;
$arrInsertFlightData[$key]['destination']['AirlineName'] = $strAirlineName;
$arrInsertFlightData[$key]['destination']['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['destination']['DeFlightNumber'] = $DeFlightNumber;
$arrInsertFlightData[$key]['destination']['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['destination']['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['destination']['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$key]['destination']['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['destination']['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['destination']['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['destination']['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['destination']['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['destination']['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['destination']['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['destination']['TravelDate'] = $OriginReturn['dt'];
$arrInsertFlightData[$key]['destination']['LocalFromTime'] = str_replace('T', ' ', $OriginReturn['dt']);
$arrInsertFlightData[$key]['destination']['FromUTCTime'] = $OriginReturn['dt'];
$arrInsertFlightData[$key]['destination']['LocalToTime'] = str_replace('T', ' ', $DestinationReturn['at']);
$arrInsertFlightData[$key]['destination']['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginReturn['dt']));
$arrInsertFlightData[$key]['destination']['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationReturn['at']));
$arrInsertFlightData[$key]['destination']['ToUTCTime'] = $DestinationReturn['at'];
$arrInsertFlightData[$key]['destination']['IsDirect'] = 0;
$arrInsertFlightData[$key]['destination']['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['destination']['LAYOVERCity'] = isset($LAYOVERCityArrD[0]) ? $LAYOVERCityArrD[0] : '';
$arrInsertFlightData[$key]['destination']['GroundTime'] = $TotalLAYOVERMinutesD;
$arrInsertFlightData[$key]['destination']['LAYOVERDuration'] = $LAYOVERTimeD;
$arrInsertFlightData[$key]['destination']['FlyingMinutes'] = $FlyingMinutesD;
$arrInsertFlightData[$key]['destination']['DepartureDateTxt'] = date('D, d M', strtotime($OriginReturn['dt']));
$arrInsertFlightData[$key]['destination']['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationReturn['at']));
$arrInsertFlightData[$key]['destination']['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['destination']['SourcePlaceName'] = $sourceCityText[0];
$arrInsertFlightData[$key]['destination']['DestPlaceName'] = $destinationCityText[0];
$arrInsertFlightData[$key]['destination']['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData[$key]['destination']['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData[$key]['destination']['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['destination']['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$key]['destination']['StopCount'] = $DeStopCountTxt;
$arrInsertFlightData[$key]['destination']['Stops'] = $Stops;
$arrInsertFlightData[$key]['destination']['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['destination']['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['destination']['CurrencyType'] = 1;
$arrInsertFlightData[$key]['destination']['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['destination']['TripType'] = $intTripType;
$arrInsertFlightData[$key]['destination']['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['destination']['logo'] = $filePath;
$fln = $arrInsertFlightData[$key]['origin']['FlightNumber'] . '' . $arrInsertFlightData[$key]['destination']['FlightNumber'];
$fcls = $arrInsertFlightData[$key]['origin']['FareClass'] . '' . $arrInsertFlightData[$key]['destination']['FareClass'];
$fromtime = $arrInsertFlightData[$key]['origin']['FromUTCTime'] . '' . $arrInsertFlightData[$key]['destination']['FromUTCTime'];
$totime = $arrInsertFlightData[$key]['origin']['ToUTCTime'] . '' . $arrInsertFlightData[$key]['destination']['ToUTCTime'];
$arrInsertFlightData[$key]['FilterKey'] = $fln . '' . $fcls . '' . $fromtime . '' . $totime;
$arrInsertFlightData[$key]['AirlineName'] = ucwords(strtolower($strAirlineName)); // As Discussed with GG
$arrInsertFlightData[$key]['FlightNumber'] = $DeFlightNumber; // As Discussed with GG
$arrInsertFlightData[$key]['AirlineCode'] = $OriginReturn['fD']['aI']['code'];
$arrInsertFlightData[$key]['AgencySysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFare; // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFare);
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['StopCount'] = $OrStopCountTxt;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['TripType'] = 2;
$arrInsertFlightData[$key]['JourneyType'] = 2;
$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$key]['dataKey'] = $key.''.$intJourneyType;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData[$key]['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData[$key]['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
$arrInsertFlightData[$key]['DestAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
$arrInsertFlightData[$key]['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData[$key]['FromUTCTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData[$key]['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
$arrInsertFlightData[$key]['ToUTCTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[] = $Fare['PublishedFare'];
}
}
// $arrInsertFlightData[$key]['fffffffffffff'] = $arrFairRules;
//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_AED), ($PublishedFare * $this->CurrencyRate));
$AttPriceRange[] = $PublishedFare;
$arrAirlineName[] = $OriginReturn['fD']['aI']['code'] . '-' . ucwords(strtolower($strAirlineName));
;
$FiltStopCount[] = $OrStopCountTxt;
$DesFiltStopCount[] = $DeStopCountTxt;
$FiltSupplier[] = 'Supplier 1';
//$FiltPriceRange[] = $FilterPrice = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_PRICE_RANGE_5000), ($PublishedFare));
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
// echo '<pre>';
// print_r($FilterDepartureDtTime);
// echo '</pre>';
$arrInsertFlightData[$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
}
sort($dddddddd);
$FiltPriceRangeU = (array_unique($FiltPriceRange));
$ArrPriceUnique = array_filter(array_values($FiltPriceRangeU));
$arrAirlineName = array_values(array_unique($arrAirlineName));
$FiltStopCount = array_unique($FiltStopCount);
$AttPriceRange = array_unique($AttPriceRange);
$data = array('outbound' => $arrInsertFlightData, 'dddddddd' => $dddddddd, 'arrAirlineName' => $arrAirlineName, 'FiltStopCount' => $FiltStopCount, 'ArrPriceUnique' => $ArrPriceUnique, 'AttPriceRange' => $AttPriceRange, 'FiltSupplier' => $FiltSupplier);
return $data;
} else {
return false;
}
}
public function FlightDataMultiCity($apiResponse, $sessionFlightSearchParams, $share_proposal_data = null) {
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intSourceCityId = ($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = ($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$editLeadId = $sessionFlightSearchParams['editLeadId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = $sessionFlightSearchParams['sourceCityText'];
$destinationCityText = $sessionFlightSearchParams['destinationCityText'];
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$SelectedFilter = isset($share_proposal_data['FilterKey']) ? $share_proposal_data['FilterKey'] : [];
$SelectedFilter = isset($share_proposal_data['FilterKey']) ? $share_proposal_data['FilterKey'] : [];
$SelectedFilter = [];
$FlightNumber__ = isset($share_proposal_data['FlightNumber'][2]) ? $share_proposal_data['FlightNumber'][2] : [];
$FareClass__ = isset($share_proposal_data['FareClassArr'][2]) ? $share_proposal_data['FareClassArr'][2] : [];
$FromUTCTime__ = isset($share_proposal_data['FromUTCTime'][2]) ? $share_proposal_data['FromUTCTime'][2] : [];
$ToUTCTime__ = isset($share_proposal_data['ToUTCTime'][2]) ? $share_proposal_data['ToUTCTime'][2] : [];
$classOfBooking__ = isset($share_proposal_data['classOfBooking'][2]) ? $share_proposal_data['classOfBooking'][2] : [];
$fareIdentifier__ = isset($share_proposal_data['fareIdentifier'][2]) ? $share_proposal_data['fareIdentifier'][2] : [];
$ExtraMarkupShare__ = isset($share_proposal_data['ExtraMarkupShare'][2]) ? $share_proposal_data['ExtraMarkupShare'][2] : [];
if (!empty($FlightNumber__)) {
foreach ($FlightNumber__ as $k => $flnum) {
$FareClass_ = $FareClass__[$k];
$ToUTCTime_ = $ToUTCTime__[$k];
$FromUTCTime_ = $FromUTCTime__[$k];
$fareIdentifier_ = $fareIdentifier__[$k];
$classOfBooking_ = $classOfBooking__[$k];
$ExtraMarkupShare_ = $ExtraMarkupShare__[$k];
$SelectedFilter[$k]['Flight'] = $flnum . '' . $FareClass_ . '' . $ToUTCTime_ . '' . $FromUTCTime_;
$SelectedFilter[$k]['Fare'] = $fareIdentifier_ . '' . $classOfBooking_;
$SelectedFilter[$k]['Markup'] = $ExtraMarkupShare_;
}
}
if ($interNationalSearch && $strFlightRoute == '3') {
$this->FlightDataMultiCityInternational($apiResponse, $sessionFlightSearchParams, $share_proposal_data);
}
$intTatalPaxCT = $adultCount + $childCount;
$getMarkup = $this->getMarkup(($interNationalSearch) ? 'INT' : 'IN');
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
$getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
$getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$intJourneyType = 2;
$intTripType = $strFlightRoute;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltPriceRange = [];
$FiltSupplier = [];
$AttPriceRange = [];
$dddddddd = [];
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$intResponseStatus = $apiResponse['ResponseStatus'];
$RETURN = $apiResponse['OutBoundFlightResults'];
if ($intResponseStatus == 1) {
if ($RETURN) {
foreach ($RETURN as $keys => $tripInfos) {
foreach ($tripInfos as $key => $result) {
$SegmentInformation = $result['sI'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
$strTraceId = $totalPriceList['id'];
$ResultIndex = $totalPriceList['id'];
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
$arrSegments = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$PublishedFareReverse = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$segmentSector = [];
if ($SegmentInformation) {
foreach ($SegmentInformation as $segments) {
//echo '<pre>';print_r($segments);
$segmentid = $segments['id'];
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segmentid,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => '', //$TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
}
}
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
$tripbinfo = [];
if ($price['tai']['tbi']) {
foreach ($price['tai']['tbi'] as $keyss => $tbi) {
$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
$sectorKey = $segc['origin'] . '-' . $segc['destination'];
if ($tbi) {
foreach ($tbi as $kgk => $pbi) {
if ($pbi) {
foreach ($pbi as $gk => $vll) {
$tripbinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
}
}
}
}
}
}
// echo '<pre>';
// print_r($fareDetail);
// echo '</pre>';
$SeatAvailable = $fareDetail['ADULT']['sR'];
$classOfBooking = $fareDetail['ADULT']['cB'];
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
$IsMealIncludes = $fareDetail['ADULT']['mI'];
$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsCabinBaggage = true;
} else {
$IsCabinBaggage = false;
}
if (!empty($strBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = ($NetFare - $TdsOnPLBCal);
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
//echo '<pre>';print_r($markUpArr);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
if ($kp == 0) {
$PublishedFareReverse += ($arrMarkUps['PublishFare']);
}
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $adultCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = (float) str_replace('-', '', ($CHILDNCMTDS * $childCount));
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = (float) str_replace('-', '', ($INFANTNCMTDS * $infantCount));
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
//echo '<pre>';print_r($price);
$FairRulesArr[$kp] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => (float) isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"SeatAvailable" => $SeatAvailable,
"classOfBooking" => $classOfBooking,
"FareClass" => $fareDetail['ADULT']['cc'],
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"IsBaggage" => $IsBaggage,
"IsCabinBaggage" => $IsCabinBaggage,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsMealIncludes" => $IsMealIncludes,
"FareBreakdown" => $FareBreakdown,
"tripbinfo" => $tripbinfo,
"FareKey" => str_replace('_', ' ', $fareIdentifier) . '' . $classOfBooking,
//"arrMarkUps" => $arrMarkUps,
);
// echo '<pre>';
// print_r($FairRulesArr[$kp]);
// echo '</pre>';
}
}
$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalLAYOVERMinutes);
$AirlineCode = $OriginSegments['fD']['aI']['code'];
$FlightNumber = $OriginSegments['fD']['fN'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $OriginSegments['fD']['aI']['name'];
$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginSegments['da']['code'];
$strDestinationAirportCode = $DestinationSegments['aa']['code'];
$Stops = $DestinationSegments['sN'];
if ($Stops == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $Stops . " Stop(s)";
}
$filePath = $this->getflightlogo($AirlineCode);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
//$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($FlyingMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($DestinationSegments['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($OriginSegments['dt']);
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData[$keys][$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$keys][$key]['AirlineName'] = ucwords(strtolower($strAirlineName));
$arrInsertFlightData[$keys][$key]['AgencySysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData[$keys][$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$keys][$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$keys][$key]['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$keys][$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$keys][$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$keys][$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$keys][$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$keys][$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$keys][$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$keys][$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$keys][$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$keys][$key]['TravelDate'] = $OriginSegments['dt'];
$arrInsertFlightData[$keys][$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
$arrInsertFlightData[$keys][$key]['FromUTCTime'] = $OriginSegments['dt'];
$arrInsertFlightData[$keys][$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
$arrInsertFlightData[$keys][$key]['ToUTCTime'] = $DestinationSegments['at'];
$arrInsertFlightData[$keys][$key]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$keys][$key]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$keys][$key]['IsDirect'] = 0;
$arrInsertFlightData[$keys][$key]['FareClass'] = $strFareClass;
$arrInsertFlightData[$keys][$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
$arrInsertFlightData[$keys][$key]['GroundTime'] = $TotalLAYOVERMinutes;
$arrInsertFlightData[$keys][$key]['LAYOVERDuration'] = $LAYOVERTime;
$arrInsertFlightData[$keys][$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$keys][$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$keys][$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$keys][$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$keys][$key]['SourcePlaceSysId'] = $intSourceCityId[$keys];
$arrInsertFlightData[$keys][$key]['DestPlaceSysId'] = $intDestinationCityId[$keys];
$arrInsertFlightData[$keys][$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$keys][$key]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$keys][$key]['SourcePlaceName'] = substr($sourceCityText[$keys], 0, strpos($sourceCityText[$keys], ','));
$arrInsertFlightData[$keys][$key]['DestPlaceName'] = substr($destinationCityText[$keys], 0, strpos($destinationCityText[$keys], ','));
;
$arrInsertFlightData[$keys][$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$keys][$key]['Stops'] = $Stops;
$arrInsertFlightData[$keys][$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$keys][$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$keys][$key]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$keys][$key]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate); // As Discussed with GG
$arrInsertFlightData[$keys][$key]['PublishedFareTxt'] = number_format(($PublishedFareReverse * $this->CurrencyRate)); // As Discussed with GG
$arrInsertFlightData[$keys][$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$keys][$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$keys][$key]['TripType'] = $intTripType;
$arrInsertFlightData[$keys][$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$keys][$key]['logo'] = $filePath;
$arrInsertFlightData[$keys][$key]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$keys][$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$keys][$key]['ICSourceSysId'] = 7;
$arrInsertFlightData[$keys][$key]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$keys][$key]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$keys][$key]['FilterKey'] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $DestinationSegments['at'] . '' . $OriginSegments['dt'];
$arrAirlineName[$keys][$key] = ucwords(strtolower($strAirlineName));
$AttPriceRange[$keys][$key] = ($PublishedFareReverse * $this->CurrencyRate);
$FiltStopCount[$keys][$key] = $StopCountTxt;
$FiltSupplier[$keys][$key] = 'Supplier 1';
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[$keys][$key] = $Fare['PublishedFare'];
}
}
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$arrInsertFlightData[$keys][$key]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
}
}
}
sort($dddddddd);
$arrAirlineName = ($arrAirlineName);
$FiltStopCount = ($FiltStopCount);
$AttPriceRange = ($AttPriceRange);
$arrAirlineName__ = [];
if ($arrAirlineName) {
foreach ($arrAirlineName as $key => $value) {
$arrAirlineName__[] = array_values(array_unique($value));
}
}
$FiltStopCount__ = [];
if ($FiltStopCount) {
foreach ($FiltStopCount as $key => $value) {
$FiltStopCount__[] = array_values(array_unique($value));
}
}
$FiltSupplier__ = [];
if ($FiltSupplier) {
foreach ($FiltSupplier as $key => $value) {
$FiltSupplier__[] = array_values(array_unique($value));
}
}
$FiltPrice__ = [];
if ($dddddddd) {
foreach ($dddddddd as $key => $value) {
$UniquePrice = array_values(array_unique($value));
$MaxriceRange = $this->getMax($UniquePrice);
$MinriceRange = $this->getMin($UniquePrice);
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots(round($MinriceRange), round($MaxriceRange));
$FiltPrice = [];
if ($arrSearchedAirlinesPriceSlots) {
foreach ($arrSearchedAirlinesPriceSlots as $k => $val) {
$arrResSlots = explode("-", $val);
if ($k == 0) {
//$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($MinriceRange) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
} else if ($k == (count($arrSearchedAirlinesPriceSlots) - 1)) {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]) . ' and Above ';
} else {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[0]) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
}
}
}
$FiltPrice__[] = $FiltPrice;
}
}
$MultiHead = [];
$outboundArray = [];
if ($sessionFlightSearchParams['sourceCityText']) {
foreach ($sessionFlightSearchParams['sourceCityText'] as $sk => $source_) {
$destination_ = isset($sessionFlightSearchParams['destinationCityText'][$sk]) ? explode(',', $sessionFlightSearchParams['destinationCityText'][$sk]) : '';
$source_ = isset($source_) ? explode(',', $source_) : '';
$departure_date_ = isset($sessionFlightSearchParams['departure_dates'][$sk]) ? $sessionFlightSearchParams['departure_dates'][$sk] : '';
//$strDepatureDate__ = isset($sessionFlightSearchParams['strDepatureDate'][$sk]) ? $sessionFlightSearchParams['strDepatureDate'][$sk] : '';
$MultiHead[] = array(
'source' => $source_[0],
'destination' => $destination_[0],
'departure_date' => $departure_date_,
//'strDepatureDate' => $strDepatureDate__,
);
$outboundArray[$sk] = array(
'source' => $source_[0],
'destination' => $destination_[0],
'departure_date' => $departure_date_,
'FD' => isset($arrInsertFlightData[$sk]) ? $arrInsertFlightData[$sk] : [],
);
}
}
// echo '<pre>';print_r(($SelectedFilter));
// echo '<pre>';print_r(($outboundArray));
// die;
$data = array('SelectedFilter' => $SelectedFilter, 'outbound' => $outboundArray, 'inbound' => [], 'MultiHead' => $MultiHead, 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'FiltPrice' => $FiltPrice__, 'FiltSupplier' => $FiltSupplier__, 'arrAirlineName' => $arrAirlineName__, 'FiltStopCount' => $FiltStopCount__);
echo json_encode($data);
exit;
} else {
$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'MultiHead' => [], 'FiltStopCount' => [], 'FiltPrice' => [], 'FiltSupplier' => [], 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch);
echo json_encode($data);
exit;
}
}
public function FlightDataMultiCityInternational($apiResponse, $sessionFlightSearchParams, $share_proposal_data = null) {
$intSourceCityId = ($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = ($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
$editLeadId = $sessionFlightSearchParams['editLeadId'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$sourceCityText = $sessionFlightSearchParams['sourceCityText'];
$destinationCityText = $sessionFlightSearchParams['destinationCityText'];
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$SelectedFilter = [];
$FilterKey__ = isset($share_proposal_data['FilterKey'][2]) ? $share_proposal_data['FilterKey'][2] : [];
$FareKey__ = isset($share_proposal_data['FareKey'][2]) ? $share_proposal_data['FareKey'][2] : [];
$FlightNumber__ = isset($share_proposal_data['FlightNumber'][2]) ? $share_proposal_data['FlightNumber'][2] : [];
$FareClass__ = isset($share_proposal_data['FareClassArr'][2]) ? $share_proposal_data['FareClassArr'][2] : [];
$FromUTCTime__ = isset($share_proposal_data['FromUTCTime'][2]) ? $share_proposal_data['FromUTCTime'][2] : [];
$ToUTCTime__ = isset($share_proposal_data['ToUTCTime'][2]) ? $share_proposal_data['ToUTCTime'][2] : [];
$classOfBooking__ = isset($share_proposal_data['classOfBooking'][2]) ? $share_proposal_data['classOfBooking'][2] : [];
$fareIdentifier__ = isset($share_proposal_data['fareIdentifier'][2]) ? $share_proposal_data['fareIdentifier'][2] : [];
$ExtraMarkupShare__ = isset($share_proposal_data['ExtraMarkupShare'][2]) ? $share_proposal_data['ExtraMarkupShare'][2] : [];
if (!empty($FilterKey__)) {
foreach ($FilterKey__ as $k => $flnum) {
$fareIdentifier_ = $fareIdentifier__[$k];
$classOfBooking_ = $classOfBooking__[$k];
$ExtraMarkupShare_ = $ExtraMarkupShare__[$k];
$SelectedFilter[$k]['Flight'] = $flnum;
$SelectedFilter[$k]['Fare'] = $fareIdentifier_ . '' . $classOfBooking_;
$SelectedFilter[$k]['Markup'] = $ExtraMarkupShare_;
}
}
// echo '<pre>';print_r(($SelectedFilter));
// die;
$intTatalPaxCT = $adultCount + $childCount;
$getMarkup = $this->getMarkup(($interNationalSearch) ? 'INT' : 'IN');
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
$getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
$getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$intJourneyType = 2;
$intTripType = $strFlightRoute;
$arrInsertFlightData = [];
$arrAirlineName = [];
$FiltStopCount = [];
$FiltPriceRange = [];
$FiltSupplier = [];
$AttPriceRange = [];
$dddddddd = [];
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$intResponseStatus = $apiResponse['ResponseStatus'];
$ONWARD = $apiResponse['OutBoundFlightResults']['COMBO'];
if ($intResponseStatus == 1) {
if ($ONWARD) {
foreach ($ONWARD as $keys => $result) {
$SegmentInformation = $result['sI'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
$strTraceId = $totalPriceList['id'];
$ResultIndex = $totalPriceList['id'];
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
$arrSegments = [];
$ArrivalArr = [];
$departureArr = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$PublishedFareReverse = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$segmentSector = [];
if ($SegmentInformation) {
foreach ($SegmentInformation as $k => $segments) {
//echo '<pre>';print_r($segments);
$segmentid = $segments['id'];
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segmentid,
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => '', //$TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
);
$segmentSector[$segmentid] = ['origin' => $originAirportCode, 'destination' => $destinationAirportCode];
$Segmentsss = $segments;
$ConectingTime = isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0;
$SegmentNumber = isset($Segmentsss['sN']) ? $Segmentsss['sN'] : false;
if ($ConectingTime == 0 && $SegmentNumber == 1) {
$ArrivalArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
//'da' => $Segmentsss['da'],
'aa' => $Segmentsss['aa'],
//'dt' => $Segmentsss['dt'],
'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
} elseif ($ConectingTime == 0 && $SegmentNumber == 2) {
$ArrivalArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
//'da' => $Segmentsss['da'],
'aa' => $Segmentsss['aa'],
//'dt' => $Segmentsss['dt'],
'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
} elseif ($ConectingTime == 0 && $SegmentNumber == 3) {
$ArrivalArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
//'da' => $Segmentsss['da'],
'aa' => $Segmentsss['aa'],
//'dt' => $Segmentsss['dt'],
'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
} elseif ($ConectingTime == 0 && $SegmentNumber == 4) {
$ArrivalArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
//'da' => $Segmentsss['da'],
'aa' => $Segmentsss['aa'],
//'dt' => $Segmentsss['dt'],
'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
} elseif ($ConectingTime == 0 && $SegmentNumber == 0) {
$ArrivalArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
//'da' => $Segmentsss['da'],
'aa' => $Segmentsss['aa'],
//'dt' => $Segmentsss['dt'],
'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
}
if ($SegmentNumber == 0) { // departure
$departureArr[$k] = array(
'fD' => $Segmentsss['fD'],
'oB' => $Segmentsss['oB'],
'stops' => $Segmentsss['stops'],
'so' => $Segmentsss['so'],
'duration' => $Segmentsss['duration'],
'da' => $Segmentsss['da'],
//'aa' => $Segmentsss['aa'],
'dt' => $Segmentsss['dt'],
//'at' => $Segmentsss['at'],
'iand' => $Segmentsss['iand'],
'cT' => isset($Segmentsss['cT']) ? $Segmentsss['cT'] : 0,
'sN' => $Segmentsss['sN'],
);
}
}
}
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
$tripbinfo = [];
if ($price['tai']['tbi']) {
foreach ($price['tai']['tbi'] as $keyss => $tbi) {
$segc = isset($segmentSector[$keyss]) ? $segmentSector[$keyss] : '';
$sectorKey = $segc['origin'] . '-' . $segc['destination'];
if ($tbi) {
foreach ($tbi as $kgk => $pbi) {
if ($pbi) {
foreach ($pbi as $gk => $vll) {
$tripbinfo[$sectorKey][$gk] = ['cabin' => isset($vll['cB']) ? $vll['cB'] : 'NA', 'checkin' => isset($vll['iB']) ? $vll['iB'] : 'NA'];
}
}
}
}
}
}
// echo '<pre>';
// print_r($fareDetail);
// echo '</pre>';
$SeatAvailable = $fareDetail['ADULT']['sR'];
$classOfBooking = $fareDetail['ADULT']['cB'];
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
$IsMealIncludes = $fareDetail['ADULT']['mI'];
$strBaggage = $price['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $price['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsCabinBaggage = true;
} else {
$IsCabinBaggage = false;
}
if (!empty($strBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = ($NetFare - $TdsOnPLBCal);
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
//echo '<pre>';print_r($markUpArr);
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr);
if ($kp == 0) {
$PublishedFareReverse += ($arrMarkUps['PublishFare']);
}
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['TotalBaseFare'] = ($ADULT['TF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = (float) str_replace('-', '', ($ADULTNCMTDS * $adultCount));
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['TotalBaseFare'] = ($CHILD['TF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = (float) str_replace('-', '', ($CHILDNCMTDS * $childCount));
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR);
$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['TotalBaseFare'] = ($INFANT['TF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = (float) str_replace('-', '', ($INFANTNCMTDS * $infantCount));
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
//echo '<pre>';print_r($price);
$FairRulesArr[$kp] = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => (float) isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"SeatAvailable" => $SeatAvailable,
"classOfBooking" => $classOfBooking,
"FareClass" => $fareDetail['ADULT']['cc'],
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"IsBaggage" => $IsBaggage,
"IsCabinBaggage" => $IsCabinBaggage,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsMealIncludes" => $IsMealIncludes,
"FareBreakdown" => $FareBreakdown,
"tripbinfo" => $tripbinfo,
"FareKey" => str_replace('_', ' ', $fareIdentifier) . '' . $classOfBooking,
//"arrMarkUps" => $arrMarkUps,
);
// echo '<pre>';
// print_r($FairRulesArr[$kp]);
// echo '</pre>';
}
}
$arrv = array_values($ArrivalArr);
$depa = array_values($departureArr);
$FlightData = [];
$FilterKey = [];
if ($depa) {
foreach ($depa as $sk => $depval) {
$arrival = isset($arrv[$sk]) ? $arrv[$sk] : '';
$LAYOVERMinutes = $GroundTime = isset($arrival['cT']) ? $depval['cT'] : 0;
$LAYOVERTimeO = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($LAYOVERMinutes);
if ($depval['cT']) {
$TotalDurationOnward = $FlyingMinutesO = ($depval['cT'] + $arrival['cT'] + $depval['duration'] + $arrival['duration']);
} else {
$TotalDurationOnward = $FlyingMinutesO = ($depval['duration']);
}
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($TotalDurationOnward);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($arrival['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($depval['dt']);
//echo "<pre>departureArr"; print_r($depval);
$Stops = $arrival['sN'];
if ($Stops == 0) {
$OrStopCountTxt = "Non-stop";
} else {
$OrStopCountTxt = $Stops . " Stop(s)";
}
$AirlineCode = $depval['fD']['aI']['code'];
$FlightNumber = $depval['fD']['fN'];
$strAirlineName = $depval['fD']['aI']['name'];
$OrFlightNumber = $AirlineCode . '-' . $FlightNumber;
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$IsLCC = $depval['fD']['aI']['isLcc'];
$strSourceAirportCode = $depval['da']['code'];
$strDestinationAirportCode = $arrival['aa']['code'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$filePath = $this->getflightlogo($AirlineCode);
$deFlightNumber = $arrival['fD']['aI']['code'] . '-' . $arrival['fD']['fN'];
if ($depval['cT']) {
$SegFlightNumberArr = [$OrFlightNumber, $deFlightNumber];
} else {
$SegFlightNumberArr = [$OrFlightNumber];
}
$FlightData[$sk]['FlightNumber'] = $FlightNumber;
$FlightData[$sk]['SegFlightNumberArr'] = implode(', ', $SegFlightNumberArr);
$FlightData[$sk]['AirlineName'] = $strAirlineName;
$FlightData[$sk]['AirlineCode'] = $AirlineCode;
$FlightData[$sk]['OrFlightNumber'] = $OrFlightNumber;
$FlightData[$sk]['AirInvenSysId'] = 0;
$FlightData[$sk]['IsLCC'] = $IsLCC;
//$FlightData[$sk]['SearchTraceId'] = $FlightTraceId;
$FlightData[$sk]['apiTraceId'] = $strTraceId;
$FlightData[$sk]['AirlineSysId'] = $airlineSysId;
$FlightData[$sk]['DepartureTime'] = $strDepartureDtTime;
$FlightData[$sk]['ArrivalTime'] = $strArrivalDtTime;
$FlightData[$sk]['IsDirect'] = 0;
$FlightData[$sk]['FareClass'] = $strFareClass;
$FlightData[$sk]['FromUTCTime'] = $depval['dt'];
$FlightData[$sk]['ToUTCTime'] = $arrival['at'];
$FlightData[$sk]['DepartureDateTxt'] = date('D, d M', strtotime($depval['dt']));
$FlightData[$sk]['ArrivalDateTxt'] = date('D, d M', strtotime($arrival['at']));
$FlightData[$sk]['FlightDuration'] = $FlightDuration;
$FlightData[$sk]['SourcePlaceSysId'] = $intSourceCityId[$sk];
$FlightData[$sk]['DestPlaceSysId'] = $intDestinationCityId[$sk];
$FlightData[$sk]['SourceAirportCode'] = $strSourceAirportCode;
$FlightData[$sk]['DestAirportCode'] = $strDestinationAirportCode;
$FlightData[$sk]['SourcePlaceName'] = $sourceCityText[$sk];
$FlightData[$sk]['DestPlaceName'] = $destinationCityText[$sk];
$FlightData[$sk]['StopCount'] = $OrStopCountTxt;
$FlightData[$sk]['Stops'] = $Stops;
$FlightData[$sk]['JourneyType'] = 1;
$FlightData[$sk]['TripType'] = $intTripType;
$FlightData[$sk]['ICSourceSysId'] = 7;
$FlightData[$sk]['logo'] = $filePath;
$FilterKey[] = trim($strFlightNumber) . '' . trim($strFareClass) . '' . $arrival['at'] . '' . $depval['dt'];
// echo "<pre>departureArr"; print_r($FlightData);
$FilterDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strDepartureDtTime);
$FilterArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->getRangeByValue(unserialize(CONST_DEPARTURETIME), $strArrivalDtTime);
$FlightData[$sk]['FilterDepartureDtTime'] = $FilterDepartureDtTime;
$FlightData[$sk]['FilterArrivalDtTime'] = $FilterArrivalDtTime;
$arrAirlineName[$sk][] = $strAirlineName;
;
$FiltStopCount[$sk][] = $OrStopCountTxt;
if ($FairRulesArr) {
foreach ($FairRulesArr as $Fare) {
$dddddddd[$sk][] = $Fare['PublishedFare'];
}
}
$FiltSupplier[$sk][] = 'Supplier 1';
}
}
// echo "<pre>departureArr"; print_r($FlightData);
$arrInsertFlightData[$keys]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$keys]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$keys]['PublishedFare'] = ($PublishedFareReverse * $this->CurrencyRate);
$arrInsertFlightData[$keys]['AirlineName'] = $strAirlineName;
$arrInsertFlightData[$keys]['FlightNumber'] = implode(', ', $SegFlightNumberArr);
$arrInsertFlightData[$keys]['SourcePlaceSysId'] = $intSourceCityId[$keys];
$arrInsertFlightData[$keys]['DestPlaceSysId'] = $intDestinationCityId[$keys];
$arrInsertFlightData[$keys]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$keys]['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData[$keys]['SourcePlaceName'] = substr($sourceCityText[$keys], 0, strpos($sourceCityText[$keys], ','));
$arrInsertFlightData[$keys]['DestPlaceName'] = substr($destinationCityText[$keys], 0, strpos($destinationCityText[$keys], ','));
;
$arrInsertFlightData[$keys]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$keys]['TravelDate'] = $OriginSegments['dt'];
$arrInsertFlightData[$keys]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
$arrInsertFlightData[$keys]['FromUTCTime'] = $OriginSegments['dt'];
$arrInsertFlightData[$keys]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
$arrInsertFlightData[$keys]['ToUTCTime'] = $DestinationSegments['at'];
$arrInsertFlightData[$keys]['LocalFromTimeDMY'] = date('d/m/Y H:i', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$keys]['LocalToTimeDMY'] = date('d/m/Y H:i', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$keys]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$keys]['FlyingMinutes'] = $FlightDuration;
$arrInsertFlightData[$keys]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$keys]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$keys]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$keys]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$keys]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$keys]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$keys]['TripType'] = $intTripType;
$arrInsertFlightData[$keys]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$keys]['FairRules'] = $FairRulesArr;
$arrInsertFlightData[$keys]['Segments'] = $arrSegments;
$arrInsertFlightData[$keys]['FlightData'] = $FlightData;
$arrInsertFlightData[$keys]['ICSourceSysId'] = 7;
$arrInsertFlightData[$keys]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$keys]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$keys]['FilterKey'] = implode('-', $FilterKey);
}
}
$MultiHead = [];
if ($sessionFlightSearchParams['sourceCityText']) {
foreach ($sessionFlightSearchParams['sourceCityText'] as $sk => $source_) {
$destination_ = isset($sessionFlightSearchParams['destinationCityText'][$sk]) ? explode(',', $sessionFlightSearchParams['destinationCityText'][$sk]) : '';
$source_ = isset($source_) ? explode(',', $source_) : '';
$departure_date_ = isset($sessionFlightSearchParams['departure_dates'][$sk]) ? $sessionFlightSearchParams['departure_dates'][$sk] : '';
//$strDepatureDate__ = isset($sessionFlightSearchParams['strDepatureDate'][$sk]) ? $sessionFlightSearchParams['strDepatureDate'][$sk] : '';
$MultiHead[] = array(
'source' => $source_[0],
'destination' => $destination_[0],
'departure_date' => $departure_date_,
//'strDepatureDate' => $strDepatureDate__,
);
}
}
$arrAirlineName__ = [];
if ($arrAirlineName) {
foreach ($arrAirlineName as $key => $value) {
$arrAirlineName__[] = array_values(array_unique($value));
}
}
$FiltStopCount__ = [];
if ($FiltStopCount) {
foreach ($FiltStopCount as $key => $value) {
$FiltStopCount__[] = array_values(array_unique($value));
}
}
$FiltSupplier__ = [];
if ($FiltSupplier) {
foreach ($FiltSupplier as $key => $value) {
$FiltSupplier__[] = array_values(array_unique($value));
}
}
$FiltPrice__ = [];
if ($dddddddd) {
foreach ($dddddddd as $key => $value) {
$UniquePrice = array_values(array_unique($value));
$MaxriceRange = $this->getMax($UniquePrice);
$MinriceRange = $this->getMin($UniquePrice);
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots(round($MinriceRange), round($MaxriceRange));
$FiltPrice = [];
if ($arrSearchedAirlinesPriceSlots) {
foreach ($arrSearchedAirlinesPriceSlots as $k => $val) {
$arrResSlots = explode("-", $val);
if ($k == 0) {
//$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($MinriceRange) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
} else if ($k == (count($arrSearchedAirlinesPriceSlots) - 1)) {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]) . ' and Above ';
} else {
$FiltPrice[$val] = $this->CurrencyTitle . ' ' . number_format($arrResSlots[0]) . ' To ' . $this->CurrencyTitle . ' ' . number_format($arrResSlots[1]);
}
}
}
$FiltPrice__[] = $FiltPrice;
}
}
// echo "<pre>arrAirlineName"; print_r($arrAirlineName__);
// echo "<pre>arrAirlineName"; print_r($FiltStopCount__);
// echo "<pre>FiltStopCount"; print_r($FiltSupplier__);
// echo "<pre>departureArr"; print_r($FiltPrice__);
// echo "<pre>departureArr"; print_r($MultiHead);
// die('wwww');
$data = array('SelectedFilter' => $SelectedFilter, 'outbound' => $arrInsertFlightData, 'inbound' => [], 'MultiHead' => $MultiHead, 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch, 'FiltPrice' => $FiltPrice__, 'FiltSupplier' => $FiltSupplier__, 'arrAirlineName' => $arrAirlineName__, 'FiltStopCount' => $FiltStopCount__);
echo json_encode($data);
exit;
} else {
$data = array('outbound' => [], 'inbound' => [], 'arrAirlineName' => [], 'MultiHead' => [], 'FiltStopCount' => [], 'FiltPrice' => [], 'FiltSupplier' => [], 'FlightRoute' => $strFlightRoute, 'interNationalSearch' => $interNationalSearch);
echo json_encode($data);
exit;
}
}
public function viewmoreAction() {
$post = json_decode(file_get_contents('php://input'), true);
if ($post['item']) {
$PriceID = $post['PriceID'];
$FairRules = [];
if ($post['item']['FairRules']) {
foreach ($post['item']['FairRules'] as $price) {
if ($price['PriceID'] == $PriceID) {
$FairRules = $price;
}
}
}
$post['item']['FairRules'] = $FairRules;
$ArrayData[0] = $post['item'];
// echo '<pre>';
// print_r($post);
// die;
$this->view->CurrencyRate = $this->CurrencyRate;
$this->view->CurrencyTitle = $this->CurrencyTitle;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $ArrayData, 'DataInbound' => [], 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle));
$bodyText = $html->render('viewmore.phtml');
$response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'failed', 'html' => '');
echo json_encode($response);
exit;
}
}
public function hoursTodays($hours) {
$hid = 24; // Hours in a day - could be 24, 8, etc
if ($hours > $hid) {
$days = round($hours / $hid);
} else {
$days = -1;
}
$Final = '';
if ($days < 0) {
$Final = "$hours hrs";
} else {
$Final = "$days days";
}
return $Final;
}
public function getflightfarerulesAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
$supplier = $getData['supplier'];
$SearchTraceId = $getData['SearchTraceId'];
$ApiResultIndexRequest = isset($getData['ApiResultIndex'])?$getData['ApiResultIndex']:$getData['TraceId'];
$objTempFlight = new Travel_Model_TblFlight();
// echo '<pre>';
// print_r($getData);
// echo '<pre>';die;
$FlightTempData = $objTempFlight->GetFlightTempData($SearchTraceId);
$APIBookingData = json_decode($FlightTempData['APIBookingData'], true);
$intOutBoundId = json_decode($getData['intOutBoundId'], true);
$ICSourceSysId_ = isset($intOutBoundId['ICSourceSysId']) ? $intOutBoundId['ICSourceSysId'] : 0;
$apiTraceId_ = isset($intOutBoundId['apiTraceId']) ? $intOutBoundId['apiTraceId'] : 0;
$ApiResultIndex_ = isset($intOutBoundId['ApiResultIndex']) ? $intOutBoundId['ApiResultIndex'] : 0;
$FlightBooking = isset($APIBookingData['FlightBookingData']) ? ($APIBookingData['FlightBookingData']) : $intOutBoundId;
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$ICSourceSysId = isset($FlightBooking[0]['ICSourceSysId']) ? $FlightBooking[0]['ICSourceSysId'] : $ICSourceSysId_;
$apiTraceId = isset($FlightBooking[0]['apiTraceId']) ? $FlightBooking[0]['apiTraceId'] : $apiTraceId_;
$ApiResultIndex = isset($FlightBooking[0]['ApiResultIndex']) ? $FlightBooking[0]['ApiResultIndex'] : $ApiResultIndex_;
$intMemberCount = (int) ($adultCount + $childCount + $infantCount);
$intMarkUp = $this->getCancelCharge($intCountryCode);
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$AgencyMarkup = ($intMarkUp * $intMemberCount);
$FareRulesCancel = [];
$getData['BookingData'] = $FlightBooking;
$getData['flowType'] = 'SEARCH';
if ($ICSourceSysId == 7) {
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($getData, $this->intLoggedinAgencyId);
$FareRules = isset($apiResponse['fareRule']) ? $apiResponse['fareRule'] : [];
$success = $apiResponse['status']['success'];
if ($success && $FareRules) {
foreach ($FareRules as $key => $val) {
$CANCELLATION = isset($val['tfr']['CANCELLATION']) ? $val['tfr']['CANCELLATION'] : '';
$DATECHANGE = isset($val['tfr']['DATECHANGE']) ? $val['tfr']['DATECHANGE'] : '';
$NO_SHOW = isset($val['tfr']['NO_SHOW']) ? $val['tfr']['NO_SHOW'] : '';
$SEAT_CHARGEABLE = isset($val['tfr']['SEAT_CHARGEABLE']) ? $val['tfr']['SEAT_CHARGEABLE'] : '';
$cancel = [];
if ($CANCELLATION) {
foreach ($CANCELLATION as $keys => $cl) {
$policyInfo_ = isset($cl['policyInfo']) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Airline Cancellation Charges + Taxes + Surcharges'];
$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
$st = $this->hoursTodays($startTime);
$et = $this->hoursTodays($endTime);
$TimeFrame = $st . ' to ' . $et;
$cancel[$keys] = $cl;
$cancel[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
$cancel[$keys]['amount'] = $amount;
$cancel[$keys]['sector'] = $key;
$cancel[$keys]['policyInfo'] = $policyInfo_;
$cancel[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
$cancel[$keys]['additionalFee'] = round($additionalFee + (float) ($AgencyMarkup));
}
} else {
$cancel[0]['sector'] = $key;
$cancel[0]['TimeFrame'] = 'As Per Airline';
$cancel[0]['policyInfo'] = ['As Per Airline'];
}
$datechange = [];
if ($DATECHANGE) {
foreach ($DATECHANGE as $keys => $cl) {
$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
$st = $this->hoursTodays($startTime);
$et = $this->hoursTodays($endTime);
$TimeFrame = $st . ' to ' . $et;
$datechange[$keys] = $cl;
$datechange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
$datechange[$keys]['amount'] = $amount;
$datechange[$keys]['sector'] = $key;
$datechange[$keys]['policyInfo'] = $policyInfo_;
$datechange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
$datechange[$keys]['additionalFee'] = round($additionalFee + (float) ($AgencyMarkup));
}
} else {
$datechange[0]['sector'] = $key;
$datechange[0]['TimeFrame'] = 'As Per Airline';
$datechange[0]['policyInfo'] = ['As Per Airline'];
}
$noshow = [];
if ($NO_SHOW) {
foreach ($NO_SHOW as $keys => $cl) {
$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['Fees As Per Airline Rule + Surcharges'];
$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
$st = $this->hoursTodays($startTime);
$et = $this->hoursTodays($endTime);
$TimeFrame = $st . ' to ' . $et;
$noshow[$keys] = $cl;
$noshow[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
$noshow[$keys]['amount'] = $amount;
$noshow[$keys]['sector'] = $key;
$noshow[$keys]['policyInfo'] = $policyInfo_;
$noshow[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
$noshow[$keys]['additionalFee'] = round($additionalFee + (float) ($AgencyMarkup));
}
} else {
$noshow[0]['sector'] = $key;
$noshow[0]['TimeFrame'] = 'As Per Airline';
$noshow[0]['policyInfo'] = ['As Per Airline'];
}
$seatchange = [];
if ($SEAT_CHARGEABLE) {
foreach ($SEAT_CHARGEABLE as $keys => $cl) {
$policyInfo_ = (isset($cl['policyInfo']) && !empty($cl['policyInfo'])) ? array_values(array_filter(explode('__nls__', $cl['policyInfo']))) : ['As per Airlines'];
$startTime = (isset($cl['st']) && !empty($cl['st'])) ? $cl['st'] : 0;
$endTime = (isset($cl['et']) && !empty($cl['et'])) ? $cl['et'] : 0;
$additionalFee = (isset($cl['additionalFee']) && !empty($cl['additionalFee'])) ? $cl['additionalFee'] : 0;
$amount = (isset($cl['amount']) && !empty($cl['amount'])) ? $cl['amount'] : 0;
$policyperiod = (isset($cl['pp']) && !empty($cl['pp'])) ? $cl['pp'] : '';
$st = $this->hoursTodays($startTime);
$et = $this->hoursTodays($endTime);
$TimeFrame = $st . ' to ' . $et;
$seatchange[$keys] = $cl;
$seatchange[$keys]['CurrencyTitle'] = $this->CurrencyTitle;
$seatchange[$keys]['amount'] = $amount;
$seatchange[$keys]['sector'] = $key;
$seatchange[$keys]['policyInfo'] = $policyInfo_;
$seatchange[$keys]['TimeFrame'] = (!empty($policyperiod)) ? $policyperiod : $TimeFrame;
$seatchange[$keys]['additionalFee'] = round($additionalFee + (float) ($AgencyMarkup));
}
} else {
$seatchange[0]['sector'] = $key;
$seatchange[0]['TimeFrame'] = 'As Per Airline';
$seatchange[0]['policyInfo'] = ['Fees As Per Airline Rule + Surcharges'];
}
$FareRulesCancel['CANCELLATION'] = $cancel;
$FareRulesCancel['DATECHANGE'] = $datechange;
$FareRulesCancel['NO_SHOW'] = $noshow;
$FareRulesCancel['SEAT_CHARGEABLE'] = $seatchange;
}
}
// echo '<pre>';print_r($FareRulesCancel);die;
// if ($FareRules && $success) {
// foreach ($FareRules as $keys => $val) {
// $CANCELLATION = isset($val['tfr']['CANCELLATION']) ? $val['tfr']['CANCELLATION'] : '';
// $DATECHANGE = isset($val['tfr']['DATECHANGE']) ? $val['tfr']['DATECHANGE'] : '';
// $NO_SHOW = isset($val['tfr']['NO_SHOW']) ? $val['tfr']['NO_SHOW'] : '';
// $SEAT_CHARGEABLE = isset($val['tfr']['SEAT_CHARGEABLE']) ? $val['tfr']['SEAT_CHARGEABLE'] : '';
// $NOSHOW_ARR = [];
// $DATECHANGE_ARR = [];
// $CANCELLATION_ARR = [];
// $SEATCHARGEABLE_ARR = [];
// if (!empty($NO_SHOW)) {
// foreach ($NO_SHOW as $key => $values) {
// $policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
// $NOSHOW_ARR['NO_SHOW'][] = array(
// 'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : $AgencyMarkup,
// 'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate) ,
// 'policyInfo' => ($policyInfo),
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// }else{
// $CANCELLATION_ARR['NO_SHOW'][] = array(
// 'amount' => 0,
// 'additionalFee' => ($AgencyMarkup),
// 'amount_' => 0,
// 'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ['No show policy Info'],
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// if (!empty($DATECHANGE)) {
// foreach ($DATECHANGE as $key => $values) {
// $policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
// $DATECHANGE_ARR['DATECHANGE'][] = array(
// 'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
// 'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ($policyInfo),
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// }else{
// $CANCELLATION_ARR['DATECHANGE'][] = array(
// 'amount' => 0,
// 'additionalFee' => ($AgencyMarkup),
// 'amount_' => 0,
// 'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ['Difference in Fare + Taxes + Surcharges'],
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// if (!empty($CANCELLATION)) {
// foreach ($CANCELLATION as $key => $values) {
// $policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
// $CANCELLATION_ARR['CANCELLATION'][] = array(
// 'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
// 'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ($policyInfo),
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// }else{
// $CANCELLATION_ARR['CANCELLATION'][] = array(
// 'amount' => 0,
// 'additionalFee' => ($AgencyMarkup),
// 'amount_' => 0,
// 'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ['Airline Cancellation Charges + Taxes + Surcharges'],
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// if (!empty($SEAT_CHARGEABLE)) {
// foreach ($SEAT_CHARGEABLE as $key => $values) {
// $policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
// $SEATCHARGEABLE_ARR['SEAT_CHARGEABLE'][] = array(
// 'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
// 'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
// 'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ($policyInfo),
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// }else{
// $CANCELLATION_ARR['SEAT_CHARGEABLE'][] = array(
// 'amount' => 0,
// 'additionalFee' => ($AgencyMarkup),
// 'amount_' => 0,
// 'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
// 'policyInfo' => ['As per Airlines'],
// 'CurrencyTitle' => ($this->CurrencyTitle),
// );
// }
// $FareRulesCancel[] = array(
// 'sector' => $keys,
// 'status' => $success,
// 'FareRules' => array_merge($NOSHOW_ARR, $DATECHANGE_ARR, $CANCELLATION_ARR, $SEATCHARGEABLE_ARR),
// );
// }
// }else{
// $FareRulesCancel[] = array(
// 'sector' => '',
// 'status' => $success,
// 'FareRules' => [],
// );
// }
} else {
$getData['ResultIndex'] = $ApiResultIndexRequest;
$getData['TraceId'] = $apiTraceId;
// echo '<pre>';
// print_r($ApiResultIndexRequest);
// print_r($apiTraceId);
// echo '<pre>';die;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->fareRuleDetails($getData, $this->intLoggedinAgencyId);
}
// echo '<pre>';
// print_r(($FareRulesCancel));
// echo '<pre>';
// print_r($FareRulesCancel);
// die;
$this->view->apiResponse = $apiResponse;
$this->view->getData = $getData;
$this->view->FareRulesCancel = $FareRulesCancel;
$this->view->intMarkUp = ($intMarkUp * $intMemberCount);
$this->view->IsLCC = $getData['IsLCC'];
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('apiResponse' => $apiResponse,'ApiResultIndexRequest'=>$ApiResultIndexRequest, 'FareRulesCancel' => $FareRulesCancel, 'getData' => $getData, 'intMarkUp' => ($intMarkUp * $intMemberCount), 'IsLCC' => $getData['IsLCC'], 'supplier' => $supplier, 'FlightBooking' => $FlightBooking));
$bodyText = $html->render('getflightfarerules.phtml');
$response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found!');
}
}
public function selectedformailAction() {
$this->_helper->layout->disableLayout();
$post = json_decode(file_get_contents('php://input'), true);
$objFlight = new Travel_Model_TblFlight();
$route = ($post['route']);
$SearchTraceId = ($post['SearchTraceId']);
$JourneyType = ($post['JourneyType']);
$PriceIdArr = ($post['PriceIdArr']);
$allitem = isset($post['allitem']) ? ($post['allitem']) : [];
// echo '<pre>';print_r($post);echo '</pre>';die;
$FinalArray__ = [];
// if($route == 3){
// $FlightTempData = $objFlight->GetFlightTempData($SearchTraceId);
// $arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
// if($arrUrlData['outbound']){
// foreach($arrUrlData['outbound'] as $k=>$element){
// echo '<pre>';print_r($element['FD']);echo '</pre>';die;
// if($element['FD']){
// foreach($element['FD'] as $kk=>$element2){
// if($element2['FairRules']){
// foreach($element2['FairRules'] as $fareval){
// echo '<pre>';print_r($fareval);echo '</pre>';die;
// // if (in_array($fareval['PriceID'],$PriceIdArr)){
// // $FinalArray__[$fareval['PriceID']] = $element;
// // $FinalArray__[$fareval['PriceID']]['FairRules'] = [$fareval];
// // }
// }
// }
// }
// }
// }
// }
// echo '<pre>';print_r($PriceIdArr);echo '</pre>';
// echo '<pre>';print_r($FinalArray__);echo '</pre>';
// die;
// }
if ($allitem) {
foreach ($allitem as $element) {
if ($element['FairRules']) {
foreach ($element['FairRules'] as $fareval) {
if (in_array($fareval['PriceID'], $PriceIdArr)) {
$FinalArray__[$fareval['PriceID']] = $element;
$FinalArray__[$fareval['PriceID']]['FairRules'] = [$fareval];
}
}
}
}
}
$post['FinalArray'] = $FinalArray__;
$IsInternational = ($post['IsInternational']);
$FinalArray = ($post['FinalArray']);
$FlightData = [];
if ($FinalArray) {
foreach ($FinalArray as $val) {
if ($val['TripType'] == 2 && $val['IsInternational'] == 1) {
$FlightData[$val['origin']['JourneyType']][] = $val;
} else {
if ($route == 3 && $IsInternational == '') {
$SourceAirportCode = $val['SourceAirportCode'];
$DestAirportCode = $val['DestAirportCode'];
//echo '<pre>';print_r($val);echo '</pre>';
$FlightData[$SourceAirportCode . '-' . $DestAirportCode][] = $val;
} else {
$FlightData[$val['JourneyType']][] = $val;
}
}
}
}
// echo '<pre>';print_r($FlightData);echo '</pre>';
// die;
$response = array('success' => true, 'FlightData' => json_encode($FlightData), 'IsInternational' => $IsInternational, 'JourneyType' => $JourneyType);
echo json_encode($response);
exit;
}
public function shareonmailAction() {
$this->_helper->layout->disableLayout();
$post = json_decode(file_get_contents('php://input'), true);
$Outbound = ($post['item']);
$selectedDataformail = json_decode($post['selectedDataformail'], true);
$discountvalue = ($post['discountvalue']);
$addMarkup = ($post['addMarkup']);
$mobilenumber = ($post['mobilenumber']);
$countrycode = ($post['countrycode']);
$emailId = $customeremail = ($post['emailId']);
$leadId = ($post['leadId']);
$ccemail = (isset($post['ccemail']) && !empty($post['ccemail'])) ? $post['ccemail'] : '';
$customername = ($post['customername']);
$remarks = ($post['remarks']);
$CustomerSysId = $customerRcord = ($post['CustomerSysId']);
$customerSysIdSel = ($post['customerSysIdSel']);
$senderEmailID = $sendersEmailId = trim($post['senderEmailID']);
$SearchTraceId = ($post['SearchTraceId']);
$agentsysID = ($post['aId']);
$agencySysID = $this->intLoggedinAgencyId;
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencySysID);
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$objFlight = new Travel_Model_TblFlight();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$sourceCityText = $sessionFlightSearchParams->params['sourceCityText'];
$destinationCityText = $sessionFlightSearchParams->params['destinationCityText'];
$Origincity = $sessionFlightSearchParams->params['from'];
$DestinationCity = $sessionFlightSearchParams->params['to'];
$route = $tripType = $sessionFlightSearchParams->params['route'];
$IsInterNational = $sessionFlightSearchParams->params['interNationalSearch'];
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailId = trim($emailId);
$mailCustmail = array(trim($emailId));
$emailSendId = $sendersEmailId = !empty($sendersEmailId) ? $sendersEmailId : trim($arrAgentDetail['EmailId']);
$PrimaryEmailWhatsApp = trim($arrAgentDetail['EmailId']);
$SACCode = !empty($this->getRequest()->getPost('sac_code')) ? $this->getRequest()->getPost('sac_code') : 440063; // default value 440063 for Tour Oprators..
$gsttype = !empty($this->getRequest()->getPost('gsttype')) ? $this->getRequest()->getPost('gsttype') : 1;
$bookingAllowed = !empty($post['bookingAllowed']) ? $post['bookingAllowed'] : 0;
// echo '<pre>';print_r($this->intLoggedinUserId);echo '</pre>';
// echo '<pre>';print_r($arrAgentDetail);echo '</pre>';
// echo '<pre>';print_r($post);echo '</pre>';
// die;
$Cities__ = [];
if ($Origincity && $route == 3) {
foreach ($Origincity as $key => $value) {
$string = isset($sourceCityText[$key]) ? $sourceCityText[$key] : '';
$sourceCityText__ = substr($string, 0, strpos($string, ','));
$string2 = isset($destinationCityText[$key]) ? $destinationCityText[$key] : '';
$destinationCityText__ = substr($string2, 0, strpos($string2, ','));
$Cities__[] = $sourceCityText__ . '-' . $destinationCityText__;
}
}
// echo '<pre>';print_r($Outbound);echo '</pre>';die('dd');
$mailToCC = explode(',', $ccemail);
$getflightData = [];
$getMarkupArr = [];
$index = 0;
if ($Outbound) {
foreach ($Outbound as $values) {
$val = json_decode($values, true);
//As per gaurav sir
$markup = $addMarkup[$index];
$discount = isset($discountvalue[$index]) ? $discountvalue[$index] : 0;
$markupgst = ($markup - $discount);
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($markupgst, "F", 0);
$MarkupArrayServiceTax = (!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) && $arrServiceTaxOnNetPayable['serviceTaxAmount'] > 0) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$val['ExtraMarkup'] = $markup;
$val['ExtraMarkupOnGST'] = $MarkupArrayServiceTax;
$val['DiscountValue'] = $discount;
$val['DiscountCoupon'] = ($discount > 0) ? 1 : 0;
//echo '<pre>';print_r($val);echo '</pre>';
$getflightData[] = $val;
$index++;
}
}
$post['item'] = $getflightData;
$FlightData = [];
$index = 0;
if ($getflightData) {
foreach ($getflightData as $val) {
if ($route == '3' && $IsInterNational == '') {
$SourceAirportCode = $val['SourceAirportCode'];
$DestAirportCode = $val['DestAirportCode'];
$FlightData[$SourceAirportCode . '-' . $DestAirportCode][] = $val;
} else {
$FlightData[$val['JourneyType']][] = $val;
}
$index++;
}
}
// sort($FlightData);
// echo '<pre>';print_r($FlightData);echo '</pre>';die;
$adultDetails = ($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : '';
$childDetails = ($sessionFlightSearchParams->params['child'] > 0) ? ', ' . $sessionFlightSearchParams->params['child'] . ' Child(s)' : '';
$InfantDetails = ($sessionFlightSearchParams->params['infant'] > 0) ? ', ' . $sessionFlightSearchParams->params['infant'] . ' Infant(s)' : '';
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'];
if ($route == 3) {
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'][0];
}
$return_dates_string = $sessionFlightSearchParams->params['return_dates'];
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$explode_dateR = explode("/", $return_dates_string);
$return_dates = $explode_dateR[2] . '-' . $explode_dateR[1] . '-' . $explode_dateR[0];
$NoofPax = '%0a*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
$TravelDate = ($departure_dates) ? '%0a%0a*Travel Date:* ' . $departure_dates : '';
$whatsappmessageFlight = '';
$navarrow = ($tripType == 1) ? "→" : "⇄";
if ($route == 3) {
$navarrow = "→";
}
//$navarrow = ($tripType == 1) ? "→" : "→";
//$demoArray = [];
foreach ($FlightData as $getflightKey => $flightDatas) {
$FareClass = $flightDatas[0]['FairRules'][0]['FareClass'];
$FareClass_ = ($FareClass) ? '%0a*Booking Class:* ' . $FareClass . '%0a' : '';
$finalHtml = '';
$kk = 0;
if ($route == 2 && $interNationalSearch == 1) {
$TravelDate = ($return_dates_string) ? '%0a*Travel Date:* ' . $departure_dates_string . ' ⇄ ' . $return_dates_string . '%0a' : '';
foreach ($flightDatas as $dKey => $fVal) {
if (count($flightDatas) > 1) {
$finalHtml .= '%0a*' . ($dKey + 1) . '.* ';
} else {
$finalHtml .= '%0a';
}
$Baggage = [];
if ($fVal['Segments']) {
foreach ($fVal['Segments'] as $value) {
$originDepTime = date('d M y H:i', strtotime($value['originDepTime']));
$destinationArrTime = date('d M y H:i', strtotime($value['destinationArrTime']));
$Baggage[] = $value['originAirportCode'] . '-' . $value['destinationAirportCode'] . ' on ' . $originDepTime . ' → ' . $destinationArrTime . ' - Checkin ' . $value['Baggage'] . ' | Cabin ' . $value['CabinBaggage'];
}
}
$imploadeAdd = implode('%0a', $Baggage);
$IsRefundableTxt = $fVal['origin']['IsRefundableTxt'];
$ExtraMarkup__ = $fVal['ExtraMarkup'];
$ExtraMarkupOnGST__ = $fVal['ExtraMarkupOnGST'];
$duration = $fVal['origin']['FlightDuration'];
$durationDes = $fVal['destination']['FlightDuration'];
$IsRefundableTxt__ = $fVal['destination']['IsRefundableTxt'];
$routeDetail = '%0a' . trim($fVal['origin']['SourceAirportCode']) . ' - ' . trim($fVal['origin']['DestAirportCode']) . ' on ' . $fVal['origin']['DepartureTime'] . ' - ' . $fVal['origin']['ArrivalTime'];
$finalHtml .= '*' . trim($fVal['origin']['AirlineName']) . ' (' . trim($fVal['origin']['OrFlightNumber']) . ') :*' . ' ' . $IsRefundableTxt . $routeDetail . ' ' . $duration . '%0a';
$routeDetail = '%0a' . trim($fVal['destination']['SourceAirportCode']) . ' - ' . trim($fVal['destination']['DestAirportCode']) . ' on ' . $fVal['destination']['DepartureTime'] . ' - ' . $fVal['destination']['ArrivalTime'];
$finalHtml .= '*' . trim($fVal['destination']['AirlineName']) . ' (' . trim($fVal['destination']['DeFlightNumber']) . ') :*' . ' ' . $IsRefundableTxt__ . $routeDetail . ' ' . $durationDes . '%0a*Total Cost:* ' . trim($fVal['FairRules'][0]['Currency']) . ' ' . round($fVal['FairRules'][0]['PublishedFare'] + $ExtraMarkup__ + $ExtraMarkupOnGST__) . '/-(' . trim($fVal['FairRules'][0]['fareIdentifier']) . ')%0a' . $imploadeAdd . '%0a';
$kk++;
}
$SourcePlaceName = $flightDatas[0]['origin']['SourcePlaceName'];
$DestPlaceName = $flightDatas[0]['origin']['DestPlaceName'];
$OrigincityTitle = $SourcePlaceName . ' (' . trim($flightDatas[0]['origin']['SourceAirportCode']) . ')';
$DestinationCityTitle = $DestPlaceName . ' (' . trim($flightDatas[0]['origin']['DestAirportCode']) . ')';
$whatsappmessageFlight .= "%0a%0a*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*%0a $NoofPax $TravelDate $FareClass_ $finalHtml ";
} else if ($route == 3 && $interNationalSearch == 1) {
$TravelDate = ($departure_dates_string) ? '%0a*Travel Date:* ' . $departure_dates_string . '%0a' : '';
$finalHtml_2 = '';
$Option = 1;
foreach ($flightDatas as $dKey2 => $fVal2) {
$ExtraMarkup__ = $fVal2['ExtraMarkup'];
$ExtraMarkupOnGST__ = $fVal2['ExtraMarkupOnGST'];
$DiscountValue__ = $fVal2['DiscountValue'];
$finalHtml = '';
foreach ($fVal2['FlightData'] as $dKey => $fVal) {
if (count($flightDatas) > 1) {
$finalHtml .= '%0a*' . ($dKey + 1) . '.* ';
} else {
$finalHtml .= '%0a';
}
$Baggage = [];
if ($fVal['Segments']) {
foreach ($fVal['Segments'] as $value) {
$originDepTime = date('d M y H:i', strtotime($value['originDepTime']));
$destinationArrTime = date('d M y H:i', strtotime($value['destinationArrTime']));
$Baggage[] = $value['originAirportCode'] . '-' . $value['destinationAirportCode'] . ' on ' . $originDepTime . ' → ' . $destinationArrTime . ' - Checkin ' . $value['Baggage'] . ' | Cabin ' . $value['CabinBaggage'];
}
}
$imploadeAdd = implode('%0a', $Baggage);
$IsRefundableTxt = $fVal['IsRefundableTxt'];
$duration = $fVal['FlightDuration'];
$routeDetail = '%0a' . trim($fVal['SourceAirportCode']) . ' - ' . trim($fVal['DestAirportCode']) . ' on ' . $fVal['DepartureTime'] . ' - ' . $fVal['ArrivalTime'];
$finalHtml .= '*' . trim($fVal['AirlineName']) . ' (' . trim($fVal['FlightNumber']) . ') :*' . ' ' . $IsRefundableTxt . $routeDetail . ' ' . $duration;
$kk++;
}
$SourcePlaceName = $fVal2['FlightData'][0]['SourcePlaceName'];
$DestPlaceName = $fVal2['FlightData'][0]['DestPlaceName'];
$OrigincityTitle = $SourcePlaceName . ' (' . trim($fVal2['FlightData'][0]['SourceAirportCode']) . ')';
$DestinationCityTitle = $DestPlaceName . ' (' . trim($fVal2['FlightData'][0]['DestAirportCode']) . ')';
$totalcost_ = trim($fVal2['FairRules'][0]['Currency']) . ' ' . round($fVal2['FairRules'][0]['PublishedFare'] + $ExtraMarkup__ + $ExtraMarkupOnGST__ - $DiscountValue__) . '/-(' . trim($fVal2['FairRules'][0]['fareIdentifier']) . ')%0a' . $imploadeAdd . '%0a';
$finalHtml_2 .= "%0a%0a*Option - $Option* *----------------* $finalHtml %0a*Total Cost:* $totalcost_/-%0a";
$Option++;
}
$whatsappmessageFlight .= " $NoofPax $TravelDate $FareClass_ $finalHtml_2 ";
//echo '<pre>'; print_r($departure_dates_string);
} else {
if ($getflightKey == 1) {
$TravelDate = ($departure_dates_string) ? '%0a*Travel Date:* ' . $departure_dates_string . '%0a' : '';
} else {
$TravelDate = ($return_dates_string) ? '%0a*Travel Date:* ' . $return_dates_string . '%0a' : '';
}
// echo '<pre>'; print_r($FareClass);
foreach ($flightDatas as $dKey => $fVal) {
if (count($flightDatas) > 1) {
$finalHtml .= '%0a*' . ($dKey + 1) . '.* ';
} else {
$finalHtml .= '%0a';
}
$Baggage = [];
if ($fVal['Segments']) {
foreach ($fVal['Segments'] as $value) {
$originDepTime = date('d M y H:i', strtotime($value['originDepTime']));
$destinationArrTime = date('d M y H:i', strtotime($value['destinationArrTime']));
$Baggage[] = $value['originAirportCode'] . '-' . $value['destinationAirportCode'] . ' on ' . $originDepTime . ' → ' . $destinationArrTime . ' - Checkin ' . $value['Baggage'] . ' | Cabin ' . $value['CabinBaggage'];
}
}
$imploadeAdd = implode('%0a', $Baggage);
// echo '</pre>'; print_r($Baggage);
$IsRefundableTxt = $fVal['IsRefundableTxt'];
$ExtraMarkup__ = $fVal['ExtraMarkup'];
$ExtraMarkupOnGST__ = $fVal['ExtraMarkupOnGST'];
$DiscountValue__ = $fVal['DiscountValue'];
$duration = $fVal['FlightDuration'];
$routeDetail = '%0a' . trim($fVal['SourceAirportCode']) . ' - ' . trim($fVal['DestAirportCode']) . ' on ' . $fVal['DepartureTime'] . ' - ' . $fVal['ArrivalTime'];
$finalHtml .= '*' . trim($fVal['AirlineName']) . ' (' . trim($fVal['FlightNumber']) . ') :*' . ' ' . $IsRefundableTxt . $routeDetail . ' ' . $duration . '%0a*Total Cost:* ' . trim($fVal['FairRules'][0]['Currency']) . ' ' . round($fVal['FairRules'][0]['PublishedFare'] + $ExtraMarkup__ + $ExtraMarkupOnGST__ - $DiscountValue__) . '/-(' . trim($fVal['FairRules'][0]['fareIdentifier']) . ')-%0a' . $imploadeAdd . '%0a';
$kk++;
}
$SourcePlaceName = $flightDatas[0]['SourcePlaceName'];
$DestPlaceName = $flightDatas[0]['DestPlaceName'];
$OrigincityTitle = $SourcePlaceName . ' (' . trim($flightDatas[0]['SourceAirportCode']) . ')';
$DestinationCityTitle = $DestPlaceName . ' (' . trim($flightDatas[0]['DestAirportCode']) . ')';
$whatsappmessageFlight .= "%0a%0a*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*%0a $NoofPax $TravelDate $FareClass_ $finalHtml ";
}
}
if (trim($remarks) != '') {
$whatsappmessageFlight .= "%0a*Remark:* $remarks";
}
// echo '</pre>'; print_r($whatsappmessageFlight);
// die;
$startdate = date('Y-m-d H:i:s');
$status = '2';
$createDate = date('Y-m-d H:i:s');
$from = $sessionFlightSearchParams->params['from'];
$to = $sessionFlightSearchParams->params['to'];
if ($route == 3) {
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'][0];
} else {
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'];
}
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$adults = $sessionFlightSearchParams->params['adults'];
$flight_class = $sessionFlightSearchParams->params['flight_class'];
$route = $tripType = $sessionFlightSearchParams->params['route'];
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$return_dates_string = $sessionFlightSearchParams->params['return_dates'];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($sessionFlightSearchParams->params['return_dates']) && !empty($sessionFlightSearchParams->params['return_dates'])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
$editLeadId = $sessionFlightSearchParams->params['editLeadId'];
$adults = $sessionFlightSearchParams->params['adults'];
$child = $sessionFlightSearchParams->params['child'];
$infant = $sessionFlightSearchParams->params['infant'];
$SearchTraceId = $sessionFlightSearchParams->params['SearchTraceId'];
$oneway_origin_text = isset($sessionFlightSearchParams->params['oneway_origin_text']) ? $sessionFlightSearchParams->params['oneway_origin_text'] : $sessionFlightSearchParams->params['sourceCityAirportCode'];
$oneway_destination_text = isset($sessionFlightSearchParams->params['oneway_destination_text']) ? $sessionFlightSearchParams->params['oneway_destination_text'] : $sessionFlightSearchParams->params['destinationCityAirportCode'];
$cardcharges = !empty($getData['cardcharges']) ? $getData['cardcharges'] : 1;
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerById($CustomerSysId);
$TraceId = $SearchTraceId;
$agencyDisplayName = $getAgencyDetail['DisplayName'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$primarycontact = $sessionLogin_user->ContactNo1 ? $sessionLogin_user->ContactNo1 : 'N/A';
// $response = array('success' => true,'whatsapp' => $whatsappmessageFlight,'contactno'=>$countrycode.$mobilenumber);
// echo json_encode($response);
// exit;
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// $html->assign(array('FlightBooking' => $getflightData,'FlightData'=>$FlightData,'bookingAllowed'=>$bookingAllowed, 'addMarkup' => $addMarkup, 'TraceId' => $TraceId, 'sessionFlightSearchParams' => $sessionFlightSearchParams->params, 'customername' => $customername,'arrAgentDetail'=>$arrAgentDetail, 'getAgencyData' => $getAgencyDetail, 'agencySysID' => $this->intLoggedinAgencyId, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
// echo $bodyText = $html->render('shareonmail.phtml');die;
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
if ($IsInterNational) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$roomjson = array();
$childcount = $child;
$roomjson[1]['route'] = $route;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
$roomjson[1]['Infant'] = $infant;
$roomjson[1]['ChildAge_1'] = $infant;
$roomjson[1]['departuredate'] = ($route == 3) ? $sessionFlightSearchParams->params['departure_dates'] : $departure_dates_string;
$roomjson[1]['returndate'] = $return_dates_string;
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
$roomjson[1]['airclass'] = $flight_class;
$RoomInfoJson = json_encode($roomjson);
// echo '</pre>'; print_r($sessionFlightSearchParams->params['departure_dates']);
// die;
// if (($CustomerSysId != $CustomerSysIdSel)) {
// $planbookingID = 'QS/' . date('y');
// $data = array(
// 'PlanBookingId' => $planbookingID,
// 'StatusType' => $status,
// 'CustomerSysId' => $CustomerSysId,
// 'AdditionalReq' => '',
// 'PlanType' => 1,
// 'InventoryType' => 1,
// 'TemplatePckSysId' => !empty($editLeadId) ? trim($editLeadId) : 0,
// 'CurrencyType' => $getflightData[0]['CurrencyType'],
// 'RoomInfoJson' => $RoomInfoJson,
// 'IsCardChrgToCustomer' => isset($cardcharges)?$cardcharges:0,
// 'SourcePlaceSysId' => $getflightData[0]['SourcePlaceSysId'],
// 'DestinationPlacesSysId' => $getflightData[0]['DestPlaceSysId'],
// 'SourcePlaces' => $getflightData[0]['SourcePlaceName'],
// 'DestinationPlaces' => $getflightData[0]['DestPlaceName'],
// 'Cities' => $getflightData[0]['SourcePlaceName'] . "-" . $getflightData[0]['DestPlaceName'],
// 'CreatorSysId' => $agentsysID,
// 'AgencySysId' => $agencySysID,
// 'AgentSysId' => $agentsysID,
// 'SupplierSysId' => 3,
// 'IsHotelFromApi' => 1,
// 'CreateDate' => $createDate,
// 'StartDate' => $departure_dates,
// 'ValidTill' => $return_dates,
// 'UpdateDate' => $createDate,
// 'IsActive' => 1,
// 'IsMarkForDel' => 0,
// 'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent'])
// );
// $leadID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
// if ($leadID) {
// $travelitenary = array(
// 'TPSysId' => $leadID,
// 'AgencySysId' => $agencySysID,
// 'StartDate' => $createDate,
// 'CreateDate' => $createDate,
// 'UpdateDate' => $createDate,
// 'IsActive' => 1,
// 'IsMarkForDel' => 0,
// );
// $lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
// }
// $airData = array(
// 'TPIntSysId' => $lasttravelitenaryID,
// 'AgencySysId' => $agencySysID,
// 'CreateDate' => $createDate,
// 'UpdateDate' => $createDate,
// 'AdultPax' => $adults,
// 'FlightCabinClass' => '',
// 'LocalFromTime' => $departure_dates,
// 'LocalToTime' => $return_dates,
// 'ChildPax' => $child,
// 'InfentPax' => $infant,
// 'SourceAirportCode' => $oneway_origin_text,
// 'DestAirportCode' => $oneway_destination_text,
// 'SupplierSysId' => 3,
// 'TripType' => $tripType,
// 'MarkUp' => 0,
// 'ICSourceSysId' => 3,
// 'IsFromAPI' => 1,
// 'IsActive' => 1,
// 'IsMarkForDel' => 0,
// 'IsSelectedOnPkg' => 1
// );
// $lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
// } else {
// $leadID = trim($editLeadId);
// }
$leadID = trim($editLeadId);
// echo '</pre>';
// echo count($getflightData);
// die('s');
if (!empty($leadID)) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplan, $where);
}
if ($getflightData) {
for ($i = 0; $i < count($getflightData); $i++) {
if ($route == 2 && $interNationalSearch == 1) {
$planbookingID = 'QS/' . date('y');
$agentMarkup = $addMarkup[$i];
$discount = isset($discountvalue[$i]) ? $discountvalue[$i] : 0;
$TPId = trim($getflightData[$i]['origin']['AirlineSysId']);
$isPriceShared = 1;
$FairRules = $getflightData[$i]['FairRules'][0];
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax(($addMarkup[$i] - $discount), "F", 0);
$MarkupArrayServiceTax = (!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) && $arrServiceTaxOnNetPayable['serviceTaxAmount'] > 0) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$intAgencyFixMarkUp = $FairRules['FixedMarkUp'];
$intGTXMarkUp = $FairRules['intGTXMarkUp'];
$GTXMarkUpGST = $FairRules['GTXMarkUpGST'];
$intOfferedFare = $FairRules['OfferedFare'];
$totalCost = ($FairRules['PublishedFare'] + $agentMarkup - $discount);
//echo "<pre>";print_r($getflightData[$i]);echo "</pre>";
$data = array(
'PlanBookingId' => $planbookingID,
'TPId' => $TPId,
'MasterTPSysId' => $leadID,
'Price' => $intOfferedFare,
'TotalCost' => $totalCost,
'NetPrice' => $totalCost,
'StatusType' => '4',
'ProposalEmailTo' => $customeremail,
'PlanType' => 1,
'InventoryType' => 1,
'CurrencyType' => $FairRules['currencySysId'],
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => isset($cardcharges) ? $cardcharges : 0,
'SourcePlaces' => $getflightData[$i]['origin']['SourcePlaceName'],
'SourcePlaceSysId' => $getflightData[$i]['origin']['SourcePlaceSysId'],
'DestinationPlacesSysId' => $getflightData[$i]['origin']['DestPlaceSysId'],
'DestinationPlaces' => $getflightData[$i]['origin']['DestPlaceName'],
'Cities' => $getflightData[$i]['origin']['SourcePlaceName'] . "-" . $getflightData[$i]['origin']['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => 3,
'IsHotelFromApi' => 1,
'CustomerSysId' => $customerRcord,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent']),
'IsPriceShared' => trim($isPriceShared),
'GSTSharedMode' => trim($gsttype),
'SACCode' => trim($SACCode),
'ProposalEmailFrom' => trim($sendersEmailId),
);
//echo "<pre>";print_r($data);exit;
########### Start Add Data in Travel Table(Base Table) ###################
if ($i == 0) {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
} else {
$lastID = $lastID;
}
//$sessionLogin_lead_customer->leadID = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
$arrival_date = $getflightData[$i]['origin']['ArrivalTime'];
$departure_date = $getflightData[$i]['origin']['DepartureTime'];
$airData = array(
'TPIntSysId' => $lasttravelitenaryID,
'AgencySysId' => $agencySysID,
'FlightNumber' => $getflightData[$i]['origin']['FlightNumber'],
'AirlineSysId' => $getflightData[$i]['origin']['AirlineSysId'],
'CreateDate' => $createDate,
'Cost' => $intOfferedFare,
'XServiceTaxAmount' => ($FairRules['GSTonComm']) ? $FairRules['GSTonComm'] : 0, //$intTotalGSTAgencyEarnings,
'GTXServiceTaxAmount' => ($FairRules['GTXMarkUpGST']) ? $FairRules['GTXMarkUpGST'] : 0, //$GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => ($FairRules['GSTOnMarkUp']) ? $FairRules['GSTOnMarkUp'] : 0, //$AgencyMarkupArrayServiceTax,
'AgentsCustomServiceTaxAmount' => $MarkupArrayServiceTax,
'TotalCost' => $totalCost,
'MarkUp' => $agentMarkup > 0 ? $agentMarkup : 0,
'AgencyMarkUp' => isset($intAgencyFixMarkUp) ? $intAgencyFixMarkUp : 0,
'AgencyCommission' => $FairRules['CommEarned'], //$intTotalEarningsForAgency - $intAgencyFixMarkUp,
'GTXMarkUp' => $intGTXMarkUp,
'FlightCabinClass' => $sessionFlightSearchParams->params['flight_class'],
'AdultPax' => $sessionFlightSearchParams->params['adults'],
'LocalFromTime' => $getflightData[$i]['origin']['LocalFromTime'], //$departure_date->format('Y-m-d H:i:s'),
'LocalToTime' => $getflightData[$i]['origin']['LocalToTime'], //$arrival_date->format('Y-m-d H:i:s'),
'FromUTCTime' => str_replace('T', ' ', $getflightData[$i]['origin']['FromUTCTime']), //$departure_date->format('Y-m-d H:i:s'),
'ToUTCTime' => str_replace('T', ' ', $getflightData[$i]['origin']['ToUTCTime']), //$arrival_date->format('Y-m-d H:i:s'),
'ChildPax' => $sessionFlightSearchParams->params['child'],
'InfentPax' => $sessionFlightSearchParams->params['infant'],
'SourceAirportCode' => $getflightData[$i]['origin']['SourceAirportCode'],
'DestAirportCode' => $getflightData[$i]['origin']['DestAirportCode'],
'TripType' => $tripType,
'CurrencyType' => $FairRules['currencySysId'], //$getflightData[$i]['CurrencyType'],
'SupplierSysId' => 3,
'ICSourceSysId' => 7,
'InvnItemSysId' => isset($getflightData[$i]['origin']['AirInvenSysId']) ? $getflightData[$i]['origin']['AirInvenSysId'] : 0,
'IsFromAPI' => 1,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
);
//echo "<pre>";print_r($airData);exit;
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
} else {
$planbookingID = 'QS/' . date('y');
$agentMarkup = $addMarkup[$i];
$TPId = trim($getflightData[$i]['AirlineSysId']);
$isPriceShared = 1;
$FairRules = $getflightData[$i]['FairRules'][0];
$ExtraMarkup = $getflightData[$i]['ExtraMarkup'];
$ExtraMarkupOnGST = ($getflightData[$i]['ExtraMarkupOnGST'] > 0) ? $getflightData[$i]['ExtraMarkupOnGST'] : 0;
$DiscountValue = $getflightData[$i]['DiscountValue'];
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax(($addMarkup[$i] - $DiscountValue), "F", 0);
$MarkupArrayServiceTax = (!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) && $arrServiceTaxOnNetPayable['serviceTaxAmount'] > 0) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$intAgencyFixMarkUp = $FairRules['FixedMarkUp'];
$intGTXMarkUp = $FairRules['intGTXMarkUp'];
$GTXMarkUpGST = $FairRules['GTXMarkUpGST'];
$intOfferedFare = $FairRules['OfferedFare'];
$PublishedFare = ($FairRules['PublishedFare']);
$TotalExtraCharge = ($ExtraMarkup + $ExtraMarkupOnGST);
$intOfferedFare = ($PublishedFare);
$totalCost = ($PublishedFare + $TotalExtraCharge - $DiscountValue);
// echo "<pre>";print_r($getflightData[$i]);echo "</pre>";
$data = array(
'PlanBookingId' => $planbookingID,
'TPId' => $TPId,
'MasterTPSysId' => $leadID,
'Price' => $intOfferedFare,
'TotalCost' => $totalCost,
'NetPrice' => $totalCost,
'StatusType' => '4',
'ProposalEmailTo' => $customeremail,
'PlanType' => 1,
'InventoryType' => 1,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => isset($cardcharges) ? $cardcharges : 0,
'SourcePlaces' => $getflightData[$i]['SourcePlaceName'],
'SourcePlaceSysId' => $getflightData[$i]['SourcePlaceSysId'],
'DestinationPlacesSysId' => $getflightData[$i]['DestPlaceSysId'],
'DestinationPlaces' => $getflightData[$i]['DestPlaceName'],
'Cities' => $getflightData[$i]['SourcePlaceName'] . "-" . $getflightData[$i]['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => 3,
'IsHotelFromApi' => 1,
'CustomerSysId' => $customerRcord,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent']),
'IsPriceShared' => trim($isPriceShared),
'GSTSharedMode' => trim($gsttype),
'SACCode' => trim($SACCode),
'ProposalEmailFrom' => trim($sendersEmailId),
);
if ($route == 3) {
$data['Cities'] = implode(',', $Cities__);
}
// echo "<pre>";print_r($data);exit;
########### Start Add Data in Travel Table(Base Table) ################### StartDate
if ($i == 0) {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
} else {
$lastID = $lastID;
}
//$sessionLogin_lead_customer->leadID = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
$travelitenary = array(
'TPSysId' => ($lastID) ? (int) $lastID : 0,
'AgencySysId' => (int) $agencySysID,
'StartDate' => $createDate,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
$arrival_date = $getflightData[$i]['ArrivalTime'];
$departure_date = $getflightData[$i]['DepartureTime'];
$airData = array(
'TPIntSysId' => $lasttravelitenaryID,
'AgencySysId' => $agencySysID,
'FlightNumber' => $getflightData[$i]['FlightNumber'],
'AirlineSysId' => $getflightData[$i]['AirlineSysId'],
'CreateDate' => $createDate,
'Cost' => $intOfferedFare,
'XServiceTaxAmount' => ($FairRules['GSTonComm']) ? $FairRules['GSTonComm'] : 0, //$intTotalGSTAgencyEarnings,
'GTXServiceTaxAmount' => ($FairRules['GTXMarkUpGST']) ? $FairRules['GTXMarkUpGST'] : 0, //$GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => ($FairRules['GSTOnMarkUp']) ? $FairRules['GSTOnMarkUp'] : 0, //$AgencyMarkupArrayServiceTax,
'AgentsCustomServiceTaxAmount' => 0,
'TotalCost' => $totalCost,
'MarkUp' => 0,
'ExtraMarkup' => $ExtraMarkup,
'ExtraMarkupOnGST' => $ExtraMarkupOnGST,
'AgencyMarkUp' => isset($intAgencyFixMarkUp) ? $intAgencyFixMarkUp : 0,
'AgencyCommission' => $FairRules['CommEarned'], //$intTotalEarningsForAgency - $intAgencyFixMarkUp,
'GTXMarkUp' => $intGTXMarkUp,
'FlightCabinClass' => $sessionFlightSearchParams->params['flight_class'],
'AdultPax' => $sessionFlightSearchParams->params['adults'],
'LocalFromTime' => $getflightData[$i]['LocalFromTime'], //$departure_date->format('Y-m-d H:i:s'),
'LocalToTime' => $getflightData[$i]['LocalToTime'], //$arrival_date->format('Y-m-d H:i:s'),
'FromUTCTime' => str_replace('T', ' ', $getflightData[$i]['FromUTCTime']), //$departure_date->format('Y-m-d H:i:s'),
'ToUTCTime' => str_replace('T', ' ', $getflightData[$i]['ToUTCTime']), //$arrival_date->format('Y-m-d H:i:s'),
'ChildPax' => $sessionFlightSearchParams->params['child'],
'InfentPax' => $sessionFlightSearchParams->params['infant'],
'SourceAirportCode' => $getflightData[$i]['SourceAirportCode'],
'DestAirportCode' => $getflightData[$i]['DestAirportCode'],
'TripType' => $tripType,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'SupplierSysId' => 3,
'ICSourceSysId' => 7,
'InvnItemSysId' => isset($getflightData[$i]['AirInvenSysId']) ? $getflightData[$i]['AirInvenSysId'] : 0,
'IsFromAPI' => 1,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
);
//echo "<pre>";print_r($airData);exit;
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
}
}
}
$bookingUrl = $this->view->baseUrl('flight-proposal/view-flight-proposal-new/id/' . ($TraceId) . '/cust/1');
//$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
if ($arrAgentDetail['IsB2CSite'] == 1) {
$bookingUrl = $arrAgentDetail['Url'] . "/detail/index/view/id/" . base64_encode($bookingUrl);
} else if (($arrAgentDetail['IsB2CSite'] == 2) && ($arrAgentDetail['IsSiteType'] == 1)) {
$bookingUrl = $arrAgentDetail['Url'] . "/hellogtx/index.html?id=" . base64_encode($bookingUrl);
} else if (($arrAgentDetail['IsB2CSite'] == 2) && ($arrAgentDetail['IsSiteType'] == 0)) {
$bookingUrl = $arrAgentDetail['Url'] . "/hellogtx/gtx.php?id=" . base64_encode($bookingUrl);
}
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($bookingUrl, $this->BITLYLOGIN, $this->BITLYAPIKEY);
if ($bitly_response['errorCode'] == 0) {
$bookingUrl = $bitly_response['results'][trim($bookingUrl)]['shortUrl'];
}
$roundToOrigin = ($tripType == 2) ? 'to ' . $Origincity : '';
if ($bookingAllowed == 0) {
$whatsappmessage = "*Dear $customername*,%0a%0aThanks for your Flight query for $Origincity to $DestinationCity $roundToOrigin.$whatsappmessageFlight %0a%0aYou can call $firstname at $primarycontact or email at $PrimaryEmailWhatsApp or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
} else {
$whatsappmessage = "*Dear $customername*,%0a%0aThanks for your Flight query for $Origincity to $DestinationCity $roundToOrigin.$whatsappmessageFlight %0a%0aTo view flight details and *book online* click on the below link:%0a$bookingUrl %0a%0aYou can also call $firstname at $primarycontact or email at $PrimaryEmailWhatsApp or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
if ($route == 3) {
$whatsappmessage = "*Dear $customername*,%0a%0aThanks for your Flight query for multicity $whatsappmessageFlight %0a%0aTo view flight details and *book online* click on the below link:%0a$bookingUrl %0a%0aYou can also call $firstname at $primarycontact or email at $PrimaryEmailWhatsApp or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
}
}
$arrData = array(
'postData' => $post,
'sessionFlightSearchParams' => $sessionFlightSearchParams->params,
);
//$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
$tempData = array(
'TraceId' => $TraceId,
'APIBookingData' => json_encode($arrData),
'TPSysId' => $lastID,
);
$objFlight->deleteFlightTempData($TraceId);
$TempInsertId = $objFlight->insertFlightTempData($tempData);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('FlightBooking' => $getflightData, 'bookingUrl' => $bookingUrl, 'FlightData' => $FlightData, 'addMarkup' => $addMarkup, 'queryID' => $leadID, 'proposalId' => $lastID, 'bookingAllowed' => $bookingAllowed, 'TraceId' => $TraceId, 'sessionFlightSearchParams' => $sessionFlightSearchParams->params, 'customername' => $customername, 'arrAgentDetail' => $arrAgentDetail, 'getAgencyData' => $getAgencyDetail, 'agencySysID' => $this->intLoggedinAgencyId, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
$bodyText = $html->render('shareonmail.phtml');
$subject = ucfirst(trim($getcustomerdetails['FirstName'])) . " your " . $Origincity . " to " . $DestinationCity . " Flight details from " . trim($getAgencyDetail['DisplayName']);
if ($route == 3) {
$subject = ucfirst(trim($getcustomerdetails['FirstName'])) . " your multicity Flight details from " . trim($getAgencyDetail['DisplayName']);
}
//echo $bodyText;die;
$emailData = array(
'fromEmail' => trim($emailSendId),
'fromName' => trim($fromName),
'subject' => $subject,
'to' => explode(',', trim($emailId)),
'bodyHtml' => $bodyText, 'bodyText' => ''
);
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
if (($sendersEmailId)) {
$emailDataToSender = array(
'fromEmail' => trim($emailSendId),
'fromName' => trim($fromName),
'subject' => $subject,
'to' => explode(',', $sendersEmailId),
'bodyHtml' => $bodyText, 'bodyText' => ''
);
$arrEmailStatistics = array(
"TPSysId" => isset($lastID) ? $lastID : '0', //$lastID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$this->mailSentByElastice($emailDataToSender, $arrEmailStatistics, 1, 0);
}
if (!empty($mailToCC)) {
$emailDataToCC = array(
'fromEmail' => trim($emailSendId),
'fromName' => trim($fromName),
'subject' => $subject,
'to' => $mailToCC,
'bodyHtml' => $bodyText, 'bodyText' => ''
);
$arrEmailStatistics = array(
"TPSysId" => isset($lastID) ? $lastID : '0', //$lastID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$this->mailSentByElastice($emailDataToCC, $arrEmailStatistics, 1, 0);
}
$arrEmailStatistics = array(
"TPSysId" => isset($lastID) ? $lastID : '0', //$lastID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$arrEmailStatisticsAgent = $arrEmailStatistics;
$arrEmailStatisticsAgent["Source"] = $arrEmailStatisticsType[2];
$dddd = $this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $CustomerSysId);
$response = array('success' => true, 'whatsapp' => $whatsappmessage, 'contactno' => $countrycode . $mobilenumber);
echo json_encode($response);
exit;
}
public function selectForPackageAction() {
$getData = $this->getRequest()->getParams();
$forPackageSearch = isset($getData['forPackageSearch']) ? $getData['forPackageSearch'] : 0;
$post = json_decode(file_get_contents('php://input'), true);
if ($forPackageSearch == 1) {
$post = $getData;
}
// echo '</pre>';
// print_r($post);
// die('s');
//$FlightRoute = isset($post['FlightRoute'])?$post['FlightRoute']:0;
$FlightRoute = isset($post['Outbound']['JourneyType']) ? $post['Outbound']['JourneyType'] : $post['FlightRoute'];
$IsInternational = (isset($post['Outbound']['IsInternational']) && !empty($post['Outbound']['IsInternational'])) ? $post['Outbound']['IsInternational'] : 0;
if ($FlightRoute == 2 && $IsInternational == 0) {
$SingleSelect = isset($post['SingleSelect']) ? $post['SingleSelect'] : 0;
$roundSelect = isset($post['roundSelect']) ? $post['roundSelect'] : 0;
$Outbound = json_decode($post['Outbound'], true);
$Inbound = json_decode($post['Inbound'], true);
$FairRules = [];
if ($Outbound['FairRules']) {
foreach ($Outbound['FairRules'] as $price) {
if ($price['PriceID'] == $SingleSelect) {
$FairRules = $price;
}
}
}
$BookingData = $Outbound;
$BookingData['FairRules'] = $FairRules;
$FairRulesInb = [];
if ($Inbound['FairRules']) {
foreach ($Inbound['FairRules'] as $priceinb) {
if ($priceinb['PriceID'] == $roundSelect) {
$FairRulesInb = $priceinb;
}
}
}
$BookingDataInb = $Inbound;
$BookingDataInb['FairRules'] = $FairRulesInb;
} else {
$BookingData = $post['Outbound'];
$BookingData['FairRules'] = $post['Price'];
}
$SearchTraceId = $BookingData['SearchTraceId'];
$objFlight = new Travel_Model_TblFlight();
$FlightTempData = $objFlight->GetFlightTempData($SearchTraceId);
$APIBookingData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$Segments = $BookingData['Segments'];
$AirlineName = $BookingData['AirlineName'];
$AirlineCode = $BookingData['AirlineCode'];
$condCity = "tbl.Code = '" . $AirlineCode . "'";
$arrResponse = $objFlight->getAirlineName($condCity);
$FairRulesArr = [];
// echo '<pre>';
// print_r($BookingData);
// die;
if ($BookingData['FairRules']['FareBreakdown']) {
foreach ($BookingData['FairRules']['FareBreakdown'] as $key => $value) {
$PassengerCount = $value['PassengerCount'];
$MF = $value['MF'];
$MU = $value['MU'];
$AGST = $value['AGST'];
$MFT = $value['MFT'];
$YR = $value['YR'];
$YQ = $value['YQ'];
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$OtherCharges = $value['OtherCharges'];
$NetFare = $value['NetFare'];
$ServiceFee = isset($value['ServiceFee']) ? $value['ServiceFee'] : 0;
$MarkUpPax = (($FixedMarkUp) / $PassengerCount);
$PricePerPAxD = (($NetFare + $MU) / $PassengerCount);
//$PricePerPAxD = (($value['BaseFare'] + $value['OT'] + $MU + $MF + $AGST + $MFT + $YR + $YQ + $OtherCharges + $ServiceFee)/$PassengerCount);
$PricePerPAx = ($PricePerPAxD );
$FairRulesArr[$key] = array(
'PricePerPAx' => ceil(($PricePerPAx) * $this->CurrencyRate),
'FixedMarkUp' => ceil($MarkUpPax * $this->CurrencyRate),
'GSTOnMarkUp' => ceil($value['GSTOnMarkUp'] * $this->CurrencyRate),
'OtherCharges' => ceil($value['OtherCharges'] * $this->CurrencyRate),
'ServiceFee' => ceil($value['ServiceFee'] * $this->CurrencyRate),
'CurrencyRate' => $this->CurrencyRate,
'CurrencyTitle' => $this->CurrencyTitle,
'CurrencyId' => $this->CurrencyId,
);
}
}
$Data = array(
'FlightNo' => $BookingData['FlightNumber'],
'AirlineName' => $BookingData['AirlineName'],
'AirlineSysId' => isset($arrResponse[0]['AirlineSysId']) ? $arrResponse[0]['AirlineSysId'] : 0,
'departureCity' => $sessionFlightSearchParams['sourceCityText'],
'arrivalCity' => $sessionFlightSearchParams['destinationCityText'],
'sourceCityId' => $sessionFlightSearchParams['sourceCityId'],
'destinationCityId' => $sessionFlightSearchParams['destinationCityId'],
'sourceCityAirportCode' => $sessionFlightSearchParams['sourceCityAirportCode'],
'destinationCityAirportCode' => $sessionFlightSearchParams['destinationCityAirportCode'],
'depaartureDate' => date('d/m/Y', strtotime($BookingData['LocalFromTime'])),
'arrivalDate' => date('d/m/Y', strtotime($BookingData['LocalToTime'])),
'depaartureTime' => $BookingData['DepartureTime'],
'arrivalTime' => $BookingData['ArrivalTime'],
'duration' => $BookingData['FlightDuration'],
'Stops' => $BookingData['Stops'],
'Refundable' => $BookingData['Refundable'],
'IsRefundable' => $BookingData['IsRefundable'],
'LocalFromTime' => $BookingData['LocalFromTimeDMY'],
'LocalToTime' => $BookingData['LocalToTimeDMY'],
'FareClass' => isset($BookingData['FairRules']['FareClass']) ? $BookingData['FairRules']['FareClass'] : '',
'Baggage' => $Segments[0]['Baggage'],
'CabinBaggage' => $Segments[0]['CabinBaggage'],
'Fair' => $FairRulesArr,
);
if ($FlightRoute == 2 && $IsInternational == 0) {
$Segments = $BookingDataInb['Segments'];
$AirlineName = $BookingDataInb['AirlineName'];
$AirlineCode = $BookingDataInb['AirlineCode'];
$condCity = "tbl.Code = '" . $AirlineCode . "'";
$arrResponse = $objFlight->getAirlineName($condCity);
$FairRulesArrInb = [];
if ($BookingDataInb['FairRules']['FareBreakdown']) {
foreach ($BookingDataInb['FairRules']['FareBreakdown'] as $keys => $values) {
$PassengerCount = $values['PassengerCount'];
$MF = $values['MF'];
$MU = $values['MU'];
$AGST = $values['AGST'];
$MFT = $values['MFT'];
$YR = $values['YR'];
$YQ = $values['YQ'];
$FixedMarkUp = $values['FixedMarkUp'];
$GSTOnMarkUp = $values['GSTOnMarkUp'];
$OtherCharges = $values['OtherCharges'];
$NetFare = $values['NetFare'];
$ServiceFee = isset($values['ServiceFee']) ? $values['ServiceFee'] : 0;
$MarkUpPax = (($FixedMarkUp) / $PassengerCount);
$PricePerPAxD = (($NetFare + $MU) / $PassengerCount);
//$PricePerPAxD = (($values['BaseFare'] + $values['OT'] + $MU + $MF + $AGST + $MFT + $YR + $YQ + $OtherCharges + $ServiceFee)/$PassengerCount);
$PricePerPAx = ($PricePerPAxD );
$FairRulesArrInb[$keys] = array(
'PricePerPAx' => ceil(($PricePerPAx) * $this->CurrencyRate),
'FixedMarkUp' => ceil($MarkUpPax * $this->CurrencyRate),
'GSTOnMarkUp' => ceil($values['GSTOnMarkUp'] * $this->CurrencyRate),
'OtherCharges' => ceil($values['OtherCharges'] * $this->CurrencyRate),
'ServiceFee' => ceil($values['ServiceFee'] * $this->CurrencyRate),
'CurrencyRate' => $this->CurrencyRate,
'CurrencyTitle' => $this->CurrencyTitle,
'CurrencyId' => $this->CurrencyId,
);
}
}
$DataInb = array(
'FlightNo' => $BookingDataInb['FlightNumber'],
'AirlineName' => $BookingDataInb['AirlineName'],
'AirlineSysId' => isset($arrResponse[0]['AirlineSysId']) ? $arrResponse[0]['AirlineSysId'] : 0,
'departureCity' => $sessionFlightSearchParams['destinationCityText'],
'arrivalCity' => $sessionFlightSearchParams['sourceCityText'],
'sourceCityId' => $sessionFlightSearchParams['destinationCityId'],
'destinationCityId' => $sessionFlightSearchParams['sourceCityId'],
'sourceCityAirportCode' => $sessionFlightSearchParams['destinationCityAirportCode'],
'destinationCityAirportCode' => $sessionFlightSearchParams['sourceCityAirportCode'],
'depaartureDate' => date('d/m/Y', strtotime($BookingDataInb['LocalFromTime'])),
'arrivalDate' => date('d/m/Y', strtotime($BookingDataInb['LocalToTime'])),
'depaartureTime' => $BookingDataInb['DepartureTime'],
'arrivalTime' => $BookingDataInb['ArrivalTime'],
'duration' => $BookingDataInb['FlightDuration'],
'Stops' => $BookingDataInb['Stops'],
'Refundable' => $BookingDataInb['Refundable'],
'LocalFromTime' => $BookingDataInb['LocalFromTimeDMY'],
'LocalToTime' => $BookingDataInb['LocalToTimeDMY'],
'FareClass' => isset($BookingDataInb['FairRules']['FareClass']) ? $BookingDataInb['FairRules']['FareClass'] : '',
'Baggage' => $Segments[0]['Baggage'],
'CabinBaggage' => $Segments[0]['CabinBaggage'],
'Fair' => $FairRulesArrInb,
);
}
if ($FlightRoute == 2 && $IsInternational == 1) {
$Fair = [];
if ($FairRulesArr) {
foreach ($FairRulesArr as $value) {
$Fair[] = array(
'PricePerPAx' => !empty($value['PricePerPAx']) ? (($value['PricePerPAx'] / $FlightRoute)) : 0,
'FixedMarkUp' => !empty($value['FixedMarkUp']) ? (($value['FixedMarkUp'] / $FlightRoute)) : 0,
'GSTOnMarkUp' => !empty($value['GSTOnMarkUp']) ? (($value['GSTOnMarkUp'] / $FlightRoute)) : 0,
'OtherCharges' => !empty($value['OtherCharges']) ? (($value['OtherCharges'] / $FlightRoute)) : 0,
'ServiceFee' => !empty($value['ServiceFee']) ? (($value['ServiceFee'] / $FlightRoute)) : 0,
'CurrencyRate' => $this->CurrencyRate,
'CurrencyTitle' => $this->CurrencyTitle,
'CurrencyId' => $this->CurrencyId,
);
}
}
$Data = array(
'FlightNo' => $BookingData['origin']['FlightNumber'],
'AirlineName' => $BookingData['origin']['AirlineName'],
'AirlineSysId' => isset($arrResponse[0]['AirlineSysId']) ? $arrResponse[0]['AirlineSysId'] : 0,
'departureCity' => $sessionFlightSearchParams['sourceCityText'],
'arrivalCity' => $sessionFlightSearchParams['destinationCityText'],
'sourceCityId' => $sessionFlightSearchParams['sourceCityId'],
'destinationCityId' => $sessionFlightSearchParams['destinationCityId'],
'sourceCityAirportCode' => $sessionFlightSearchParams['sourceCityAirportCode'],
'destinationCityAirportCode' => $sessionFlightSearchParams['destinationCityAirportCode'],
'depaartureDate' => date('d/m/Y', strtotime($BookingData['origin']['LocalFromTime'])),
'arrivalDate' => date('d/m/Y', strtotime($BookingData['origin']['LocalToTime'])),
'depaartureTime' => $BookingData['origin']['DepartureTime'],
'arrivalTime' => $BookingData['origin']['ArrivalTime'],
'duration' => $BookingData['origin']['FlightDuration'],
'Stops' => $BookingData['origin']['Stops'],
'Refundable' => $BookingData['origin']['Refundable'],
'LocalFromTime' => $BookingData['origin']['LocalFromTimeDMY'],
'LocalToTime' => $BookingData['origin']['LocalToTimeDMY'],
'FareClass' => isset($BookingData['FairRules']['FareClass']) ? $BookingData['FairRules']['FareClass'] : '',
'Baggage' => $Segments[0]['Baggage'],
'CabinBaggage' => $Segments[0]['CabinBaggage'],
'Fair' => $Fair,
);
$DataInb = array(
'FlightNo' => $BookingData['destination']['FlightNumber'],
'AirlineName' => $BookingData['destination']['AirlineName'],
'AirlineSysId' => isset($arrResponse[0]['AirlineSysId']) ? $arrResponse[0]['AirlineSysId'] : 0,
'departureCity' => $sessionFlightSearchParams['destinationCityText'],
'arrivalCity' => $sessionFlightSearchParams['sourceCityText'],
'sourceCityId' => $sessionFlightSearchParams['destinationCityId'],
'destinationCityId' => $sessionFlightSearchParams['sourceCityId'],
'sourceCityAirportCode' => $sessionFlightSearchParams['destinationCityAirportCode'],
'destinationCityAirportCode' => $sessionFlightSearchParams['sourceCityAirportCode'],
'depaartureDate' => date('d/m/Y', strtotime($BookingData['destination']['LocalFromTime'])),
'arrivalDate' => date('d/m/Y', strtotime($BookingData['destination']['LocalToTime'])),
'depaartureTime' => $BookingData['destination']['DepartureTime'],
'arrivalTime' => $BookingData['destination']['ArrivalTime'],
'duration' => $BookingData['destination']['FlightDuration'],
'Stops' => $BookingData['destination']['Stops'],
'Refundable' => $BookingData['destination']['Refundable'],
'LocalFromTime' => $BookingData['destination']['LocalFromTimeDMY'],
'LocalToTime' => $BookingData['destination']['LocalToTimeDMY'],
'FareClass' => isset($BookingData['FairRules']['FareClass']) ? $BookingData['FairRules']['FareClass'] : '',
'Baggage' => $Segments[0]['Baggage'],
'CabinBaggage' => $Segments[0]['CabinBaggage'],
'Fair' => $Fair,
);
}
// echo '<pre>';
// print_r($Data);
// echo '<pre>============';
// print_r($DataInb);
// die;
$response = array('success' => true, 'message' => 'Done', 'FLData' => $Data, 'FLDataInb' => $DataInb, 'FlightRoute' => $FlightRoute, 'IsInternational' => $IsInternational);
echo json_encode($response);
exit;
}
public function bookNowAction() {
Zend_Session::namespaceUnset('FlightBookingDataRoundInter');
Zend_Session::namespaceUnset('FlightBookingDataInbound');
Zend_Session::namespaceUnset('FlightBookingData');
$post = json_decode(file_get_contents('php://input'), true);
$roundSelect = isset($post['roundSelect']) ? $post['roundSelect'] : 0;
$SingleSelect = isset($post['SingleSelect']) ? $post['SingleSelect'] : 0;
$multiSelect = isset($post['multiSelect']) ? $post['multiSelect'] : [];
$ProposaltraceID = isset($post['traceID']) ? $post['traceID'] : 0;
if (isset($post['sessionFlightSearchParams']) && !empty($post['sessionFlightSearchParams'])) {
$sessionParams = json_decode($post['sessionFlightSearchParams'], true);
}
$route = ($sessionParams['route']);
$interNationalSearch = ($sessionParams['interNationalSearch']);
$Outbound = json_decode($post['Outbound'], true);
$Inbound = json_decode(($post['Inbound']) ? $post['Inbound'] : json_encode([]), true);
$SearchTraceId = $Outbound['SearchTraceId'];
$IsTJFlightAPI = $Outbound['IsTJFlightAPI'];
$ICSourceSysId = $Outbound['ICSourceSysId'];
if ($ICSourceSysId == 8) {
$sessionParams['departure_dates'] = $Outbound['FromDate'];
$sessionParams['return_dates'] = $Outbound['FromDate'];
}
$FairRules = [];
if ($route == 3 && $interNationalSearch != 1) {
if ($Outbound) {
foreach ($Outbound as $key => $priceVal) {
$FairRules = [];
$SearchTraceId = $priceVal['SearchTraceId'];
$Outbound[$key] = $priceVal;
if ($priceVal['FairRules']) {
foreach ($priceVal['FairRules'] as $price) {
if (in_array($price['PriceID'], $multiSelect)) {
$FairRules = $price;
}
}
}
$Outbound[$key]['FairRules'] = $FairRules;
}
}
} else {
if ($Outbound['FairRules']) {
foreach ($Outbound['FairRules'] as $price) {
if ($price['PriceID'] == $SingleSelect) {
$FairRules = $price;
}
}
}
if ($IsTJFlightAPI == 1) {
$Outbound['apiTraceId'] = $SingleSelect;
}
$Outbound['FairRules'] = $FairRules;
}
$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
$FlightBookingDataRoundInter = new Zend_Session_Namespace('FlightBookingDataRoundInter');
$FlightBookingDataInbound = new Zend_Session_Namespace('FlightBookingDataInbound');
if ($route == 3 && $interNationalSearch != 1) {
$FlightBookingData->params = $Outbound; // Putting all form data to Session
} else {
$FlightBookingData->params[0] = $Outbound;
}
// echo '<pre>';
// print_r($FlightBookingData->params);
// die;
$FlightBookingDataRoundInter->params[0] = $Outbound; // Putting all form data to Session
$apiTraceId = $SingleSelect;
if (!empty($Inbound)) {
$RoundFairRules = [];
if ($Inbound['FairRules']) {
foreach ($Inbound['FairRules'] as $price2) {
if ($price2['PriceID'] == $roundSelect) {
$RoundFairRules = $price2;
}
}
}
if ($IsTJFlightAPI == 1) {
$Outbound['apiTraceId'] = $roundSelect;
}
$Inbound['FairRules'] = $RoundFairRules;
$FlightBookingData->params[1] = $Inbound; // Putting all form data to Session
$FlightBookingDataInbound->params = $Inbound; // Putting all form data to Session
$apiTraceId = $SingleSelect . ',' . $roundSelect;
}
// echo '<pre>';
// echo count($FlightBookingData->params);
// echo '<pre>';
// print_r($post);
// die;
try {
$objFlight = new Travel_Model_TblFlight();
$FlightTempData = $objFlight->GetFlightTempData($SearchTraceId);
$arrData = json_decode($FlightTempData['APIBookingData'], true);
$TPSysId = $FlightTempData['TPSysId'];
$sessionFlightSearchParams = $arrData['sessionFlightSearchParams'];
// $arrData = array(
// 'FlightBookingData' => $FlightBookingData->params,
// 'apiTraceId' => $apiTraceId,
// 'SearchTraceId' => $SearchTraceId,
// );
$arrData['FlightBookingData'] = $FlightBookingData->params;
$arrData['apiTraceId'] = $apiTraceId;
$arrData['SearchTraceId'] = $SearchTraceId;
$arrData['AirInvenSysIdArr'] = [];
$arrData['sessionFlightSearchParams'] = $sessionParams;
// echo '<pre>';
// print_r($APIBookingData);
// print_r($arrData);
// echo '</pre>';die;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => $TPSysId,
'APIBookingData' => json_encode($arrData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
//$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
if ($FlightBookingData->params) {
if (!empty($ProposaltraceID)) {
$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight-proposal/view-flight-proposal-travellers/data/' . $SearchTraceId . '/id/' . $ProposaltraceID);
echo json_encode($response);
exit;
} else {
$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight/travellers/data/' . $SearchTraceId);
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
echo json_encode($response);
exit;
}
} catch (Exception $e) {
//echo $e->getMessage();
$response = array('success' => false, 'message' => 'Traceid expired. please search again', 'url' => '');
echo json_encode($response);
exit;
}
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$origin = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
if (!empty($sessionParams)) {
$sessionFlightSearchParams = $sessionParams;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strSourceAirportCode = $sessionFlightSearchParams['from'];
$strDestinationAirportCode = $sessionFlightSearchParams['to'];
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'] : '';
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$origin = $sessionFlightSearchParams['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams['destinationCityAirportCode'];
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
}
/* Common Variable For API Call */
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
$data = $FlightBookingData->params;
$arrCommonInsVariables = array(
'strTraceId' => $apiTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 1, // For Single Trips API Search
'TripType' => 1,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$AirInvenSysIdArr = [];
if (!empty($data)) {
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
// Fix Values.....
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
$ICSourceSysId = 7;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
foreach ($data as $result) {
//print_r($arrOutBoundFlights); exit;
$origin = [];
$destination = [];
if ($interNationalSearch == 1 && $strFlightRoute == 2) {
$origin[] = $result['origin'];
$destination[] = $result['destination'];
$SegmentsMerge = array_merge($origin, $destination);
$ResultIndex = $result['origin']['ResultIndex'];
$IsLCC = $result['origin']['IsLCC'];
$IsRefundable = $result['origin']['IsRefundable'];
$AirlineCode = $result['origin']['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$result['origin']['AirlineCode']]) ? $arrAirlineList[$result['origin']['AirlineCode']] : '0';
$strFlightNumber = $result['origin']['FlightNumber'];
$OrFlightNumber = $result['origin']['OrFlightNumber'];
$strFareClass = $result['origin']['FareClass'];
$localFromDateTime = $result['origin']['LocalFromTime'];
$initialOriginDepTime = $result['origin']['FromUTCTime'];
$localToDateTime = $result['origin']['LocalToTime'];
$ToUTCTime = $result['origin']['ToUTCTime'];
} else {
$ResultIndex = $result['ResultIndex'];
$IsLCC = $result['IsLCC'];
$IsRefundable = $result['IsRefundable'];
$AirlineCode = $result['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
$strFlightNumber = $result['FlightNumber'];
$strFareClass = $result['FareClass'];
$localFromDateTime = $result['LocalFromTime'];
$initialOriginDepTime = $result['FromUTCTime'];
$localToDateTime = $result['LocalToTime'];
$ToUTCTime = $result['ToUTCTime'];
$SegmentsMerge = [];
}
// echo "<pre>";
// print_r($SegmentsMerge);
// Fare
$Currency = $result['FairRules']['Currency'];
$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$BaseFare = $result['FairRules']['BaseFare'];
$Tax = $result['FairRules']['Tax'];
$YQTax = $result['FairRules']['YQTax'];
$AdditionalTxnFeeOfrd = $result['FairRules']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['FairRules']['AdditionalTxnFeePub'];
$OtherCharges = $result['FairRules']['OtherCharges'];
$Discount = $result['FairRules']['Discount'];
$PublishedFare = $result['FairRules']['PublishedFare'];
$CommissionEarned = $result['FairRules']['CommEarned'];
$PLBEarned = $result['FairRules']['PLBEarned'];
$IncentiveEarned = $result['FairRules']['IncentiveEarned'];
$OfferedFare = $result['FairRules']['OfferedFare'];
$TdsOnCommission = $result['FairRules']['TdsOnCommission'];
$TdsOnPLB = $result['FairRules']['TdsOnPLB'];
$TdsOnIncentive = $result['FairRules']['TdsOnIncentive'];
$ServiceFee = $result['FairRules']['ServiceFee'];
//print_r($result); exit;
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => $currencySysId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"OfferedFare" => $OfferedFare,
"TdsOnCommission" => ($TdsOnCommission) ? $TdsOnCommission : 0,
"TdsOnPLB" => ($TdsOnPLB) ? $TdsOnPLB : 0,
"TdsOnIncentive" => ($TdsOnIncentive) ? $TdsOnIncentive : 0,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => $IsActive,
"IsMarkForDel" => $IsMarkForDel
);
$FlyingMinutesOutBound = 0;
$FlyingMinutesInBound = 0;
if (!empty($result['Segments'])) {
$FlyingMinutes = 0;
//$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
foreach ($result['Segments'] as $segmentsResult) {
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['TripIndicator'];
$AirlineName = $segmentsResult['AirlineName'];
$FlightNumber = $segmentsResult['SegFlightNumber'];
$FareClass = $segmentsResult['FareClass'];
$originAirportCode = $segmentsResult['originAirportCode'];
$originDepTime = $segmentsResult['originDepTime'];
$destinationAirportCode = $segmentsResult['destinationAirportCode'];
$destinationArrTime = $segmentsResult['destinationArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
if ($TripIndicator == 1) {
$FlyingMinutesOutBound += ($Duration + $GroundTime);
} else {
$FlyingMinutesInBound += ($Duration + $GroundTime);
}
$arrSegments = array(
"AirInvenAPISysId" => '',
"TripIndicator" => $TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"SegmentIndicator" => ($SegmentIndicator) ? $SegmentIndicator : 1,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status
);
// FOR FLIGHT SEGMENTS.....
}
}
// Fare
$FlyingMinutes = $FlyingMinutes;
if (count($result['Segments']) > 1) {
$SegmentsCount = count($result['Segments']);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
} else {
$StopCount = '0';
$IsDirect = '1';
}
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['IsRefundable'] = $IsRefundable;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = str_replace('T', ' ', $initialOriginDepTime);
$arrInsertFlightData['LocalToTime'] = str_replace('T', ' ', $localToDateTime);
$arrInsertFlightData['ToUTCTime'] = str_replace('T', ' ', $ToUTCTime);
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $strFareClass;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $strTraceId;
$arrInsertFlightData['JourneyType'] = $intJourneyType;
$arrInsertFlightData['TripType'] = $result['TripType'];
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$arrInsertFlightData['IsInternational'] = $interNationalSearch;
// echo '<pre>';
// print_r($arrInsertFlightData);
// echo '</pre>';
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $AirInvenSysIdArr[] = $intFlightLastInsertId;
$arrInsertFlightData = array();
if (!empty($SegmentsMerge)) {
$intSegments = 1;
$intFlightParentRecordId = $AirInvenSysId;
foreach ($SegmentsMerge as $MergeResult) {
$arrInsertFlightData['FlightNumber'] = ($intSegments > 1) ? $MergeResult['DeFlightNumber'] : $MergeResult['OrFlightNumber'];
;
$arrInsertFlightData['AirInvenSysId'] = $intFlightParentRecordId;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($result['strTraceId']) ? $result['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = 7;
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = $localFromDateTime;
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = $localToDateTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $MergeResult['FareClass'];
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = ($intSegments > 1) ? $FlyingMinutesInBound : $FlyingMinutesOutBound;
if ($intSegments > 1) {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
} else {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
}
$arrInsertFlightData['SourceAirportCode'] = $MergeResult['SourceAirportCode'];
$arrInsertFlightData['DestAirportCode'] = $MergeResult['DestAirportCode'];
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = 1;
$arrInsertFlightData['PublishedFare'] = isset($result['FairRules']['OfferedFare']) ? (int) round($result['FairRules']['OfferedFare']) : 0;
$arrInsertFlightData['CommissionEarned'] = isset($result['FairRules']['CommissionEarned']) ? (int) round($result['FairRules']['CommissionEarned']) : 0;
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = 2;
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $UpdatedByISSysId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$intFlightChildRecordId = $objFlight->addFlightDetails($arrInsertFlightData);
$intSegments++;
}
}
// echo '<pre>';
// print_r($AirInvenSysId);
// echo '</pre>';
// FOR FLIGHT FAIR-RULES.....
try {
$arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightFairRuleDetails($arrFairRules);
} catch (Exception $e) {
echo $e->getMessage();
}
// FOR FLIGHT FAIR-RULES.....
// FOR FLIGHT SEGMENTS.....
try {
$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
} catch (Exception $e) {
echo $e->getMessage();
}
// FOR FLIGHT SEGMENTS.....
if (!empty($result['FairRules']['FareBreakdown'])) {
foreach ($result['FairRules']['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = isset($fareBreakdown['Tax']) ? $fareBreakdown['Tax'] : $fareBreakdown['TaxIN'];
$YQTax = isset($fareBreakdown['YQTax']) ? $fareBreakdown['YQTax'] : $fareBreakdown['YQ'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $AirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => ($BaseFare) ? $BaseFare : 0,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
if ($IsDirect == 0) {
$tempFlightNumber = "";
$IsFlightChange = 0;
//$changedFlightNumber = "";
$FlyingMinutes = 0;
$intSegmentsCount = 0;
//$firstFlightNumber = "";
foreach ($result['Segments'] as $segmentsResult) {
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['TripIndicator'];
$FlightNumber = $segmentsResult['SegFlightNumber'];
// if($firstFlightNumber == ""){
// $firstFlightNumber = $FlightNumber;
// }
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
}
$tempFlightNumber = $FlightNumber;
$AirlineName = $segmentsResult['AirlineName'];
$FareClass = $segmentsResult['FareClass'];
$originAirportCode = $segmentsResult['originAirportCode'];
$originDepTime = $segmentsResult['originDepTime'];
$destinationAirportCode = $segmentsResult['destinationAirportCode'];
$destinationArrTime = $segmentsResult['destinationArrTime'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
try {
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $AirInvenSysId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"Sequance" => ($SegmentIndicator) ? $SegmentIndicator : 1,
"DestPlaceSysId" => $DestPlaceSysId,
"StayDuration" => $GroundTime,
"FlightDuration" => $Duration,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FlightNumber" => $FlightNumber,
"FareClass" => $FareClass,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"OriginAirportCode" => $originAirportCode,
"DestinationAirportCode" => $destinationAirportCode,
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => $NewFInvenSysId,
"ArrivalTime" => str_replace('T', ' ', $originDepTime),
"DepartureTime" => str_replace('T', ' ', $destinationArrTime),
"HaultInclusions" => '',
"CurrencyType" => $currencySysId,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => ($CommissionEarned) ? $CommissionEarned : 0,
"CreateDate" => $CreateDate,
"UpdateDate" => $UpdateDate,
"IsActive" => $IsActive,
"IsMarkForDelete" => $IsMarkForDel
);
// echo '<pre>';
// print_r($arrFlightStopsInsert);
// echo '</pre>';
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$intSegmentsCount++;
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
} // Foreach ends
}
$arrData['AirInvenSysIdArr'] = $AirInvenSysIdArr;
if (!empty($sessionParams)) {
$arrData['sessionFlightSearchParams'] = $sessionFlightSearchParams;
}
$tempData = array(
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrData),
);
// echo '</pre>';
// print_r($tempData);
// die('dd');
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
//$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
if ($FlightBookingData->params) {
if (!empty($ProposaltraceID)) {
$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight-proposal/view-flight-proposal-travellers/data/' . $SearchTraceId . '/id/' . $ProposaltraceID);
echo json_encode($response);
exit;
} else {
$response = array('success' => true, 'message' => 'Plase wait...', 'url' => $this->baseUrl . '/flight/travellers/data/' . $SearchTraceId);
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'Oops something went wrong', 'url' => '');
echo json_encode($response);
exit;
}
}
public function travellersAction() {
//$strUrlData = $this->getRequest()->getParam('data');
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$GeoCountry = $this->view->GeoCountry = $objFlight->GetGeoCountry();
//$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
if (isset($arrUrlData['FlightBookingData'])) {
$FlightBookingData = $arrUrlData['FlightBookingData'];
} else {
$FlightBookingData = $arrUrlData['intOutBoundId'];
}
$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
$AirInvenSysIdArr = $arrUrlData['AirInvenSysIdArr'];
$apiTraceId = $arrUrlData['apiTraceId'];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$intTPSysId = $arrUrlData['intTPSysId'];
$intCustomerSysId = !empty($this->view->intInBoundId = $arrUrlData['intCustomerSysId']) ? $this->view->intOutBoundId = $arrUrlData['intCustomerSysId'] : 0;
if (!empty($intCustomerSysId)) {
$EditCustomerData = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->EditCustomerData = $EditCustomerData;
}
// echo "<pre>";
// print_r($FlightBookingData);
// die; departureDayInfant
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$param = $this->getRequest()->getParams();
$route = $sessionFlightSearchParams['route'];
$departureDates = $sessionFlightSearchParams['departure_dates'];
if ($route == '3') {
$departureDates = $sessionFlightSearchParams['departure_dates'][0];
}
// echo "<pre>";
// print_r($departureDates);die;
$arrDepartureDates = explode("/", $departureDates);
$this->view->departureDates = $arrDepartureDates[2] . "/" . $arrDepartureDates[1] . "/" . ($arrDepartureDates[0] - 1);
$this->view->departureMonthInfant = $arrDepartureDates[1];
$this->view->departureDayInfant = ($arrDepartureDates[0] + 1);
$this->view->departureMonthChild = $arrDepartureDates[1];
$this->view->departureDayChild = ($arrDepartureDates[0]);
$this->view->intFlightRoute = $intFlightRoute = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
$arrPaxCount = array(
'intAdultsCount' => $adultCount,
'intChildCount' => $childCount,
'intInfantCount' => $infantCount
);
$this->view->arrPaxCount = $arrPaxCount;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->FlightBookingData = $FlightBookingData;
$this->view->AirInvenSysIdArr = json_encode($AirInvenSysIdArr);
$this->view->apiTraceId = ($apiTraceId);
$this->view->ICSourceSysId = ($ICSourceSysId);
$this->view->AgencySysId = ($sessionFlightSearchParams['AgencySysId']);
$intCountryCode = ($sessionFlightSearchParams['intCountryCode']);
$roomjson = array();
// $roomjson[1]['Adult'] = $adultCount;
// $roomjson[1]['Child'] = $childCount;
// $roomjson[1]['paxType'] = 1;
$intPaxCount = 1;
for ($i = 1; $i <= $adultCount; $i++) {
$roomjson[$i]['Title'] = 'Adult';
$roomjson[$i]['paxType'] = 1;
$roomjson[$i]['intPaxCount'] = $intPaxCount;
$intPaxCount++;
}
if (!empty($childCount)) {
$intPaxCount = 1;
for ($j = $i; $j <= ($adultCount + $childCount); $j++) {
$roomjson[$j]['Title'] = 'Child';
$roomjson[$j]['paxType'] = 2;
$roomjson[$j]['intPaxCount'] = $intPaxCount;
$intPaxCount++;
}
}
$this->view->roomjson = $roomjson;
$this->view->traceId = $arrUrlData['apiTraceId'];
$this->view->SearchTraceId = $arrUrlData['SearchTraceId'];
$this->view->param = $param;
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = isset($sessionFlightSearchParams['customerID']) ? $this->_crmcustomerObj->GetAgencyCustomerById(trim($sessionFlightSearchParams['customerID'])) : '';
$this->view->arrTrevllerDetails = $customerDetails;
$this->view->CurrencyRate = $this->CurrencyRate;
$this->view->CurrencyTitle = $this->CurrencyTitle;
$objMarkup = new Markup_Model_Markup();
if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
$intAirType = 2;
} else {
$intAirType = 1;
}
$arrAgencyUserDetail = $objMarkup->getAgencyUserDetail(array("AgencySysId" => $this->intLoggedinAgencyId, "ItemSourceType" => (int) $intAirType, "PlanType" => 0));
$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
// echo '<pre>';
// print_r($arrAgencyUserDetail);
// die;
}
public function getflightfarequoteAction() {
$getData = $this->getRequest()->getParams();
$FlightBookingData = (json_decode(base64_decode($getData['intOutBoundId']), true));
$AirInvenSysIdArr = ($getData['AirInvenSysIdArr']);
$SearchTraceId = $FlightBookingData[0]['SearchTraceId'];
$IsSeriesFareData = isset($FlightBookingData[0]['IsSeriesFareData']) ? $FlightBookingData[0]['IsSeriesFareData'] : 0;
$IsTJFlightAPI = isset($FlightBookingData[0]['IsTJFlightAPI']) ? $FlightBookingData[0]['IsTJFlightAPI'] : 0;
$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId']) ? $FlightBookingData[0]['ICSourceSysId'] : 0;
$objTempFlight = new Travel_Model_TblFlight();
$FlightTempData = $objTempFlight->GetFlightTempData($SearchTraceId);
$APIBookingData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$route = $sessionFlightSearchParams['route'];
$interNationalSearch = $sessionFlightSearchParams['interNationalSearch'];
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$intCountryCode = ($sessionFlightSearchParams['intCountryCode']);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
$getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
$getMarkup = $getMarkupB2B;
$MarketPlaceSysId = isset($getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId']) ? $getMarkup['arrAgencyMarkups'][0]['MarketPlaceSysId'] : 0;
$MasterId = isset($getMarkup['arrAgencyMarkups'][0]['MasterId']) ? $getMarkup['arrAgencyMarkups'][0]['MasterId'] : 0;
if(empty($MasterId) || $MasterId == 0){
$MarketPlaceSysId = $MarketPlaceSysId;
}else{
$MarketPlaceSysId = $MasterId;
}
//$MarketPlaceSysId = 1158;
// $filterData = ['ApiSourceSysId' => 3];
// $AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
// echo '<pre>';print_r($getMarkupB2B);
// echo '<pre>';print_r($getMarkup);
// die;
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
Zend_Session::namespaceUnset('FlightSeatSession');
Zend_Session::namespaceUnset('selectedSeatSession');
//
$FareRuleRequest = [];
$apiResponseInbound = [];
$getQ = array(
'ApiResultIndex' => $getData['ApiResultIndex'],
'TraceId' => $getData['TraceId'],
'Inbound' => false,
'BookingData' => $FlightBookingData[0],
);
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
$apiResponse = array('status' => array('success' => 1), 'bookingId' => $FlightBookingData[0]['bookingId']);
} elseif ($ICSourceSysId == '7') {
$EXPTraceId = explode(',', $getData['TraceId']);
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareQuoteTripJack($getQ, $this->intLoggedinAgencyId);
$requestData = array(
'TraceId' => $apiResponse['bookingId'],
'flowType' => 'REVIEW',
'BookingData' => $FlightBookingData[0],
);
$apiResponsefr = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetApiFlightsFareRulesTripJack($requestData, $this->intLoggedinAgencyId);
$FareRuleRequest = $apiResponsefr;
}
//$str = file_get_contents($this->baseUrl.'/public/logs/flight/flightSSR_response.json');
//$apiResponse = json_decode($str,true);
//echo '<pre>';print_r($FareRuleRequest);die;
$ResponseStatus = isset($apiResponse['status']['success']) ? $apiResponse['status']['success'] : 0;
$ErrorMessage = isset($apiResponse['errors'][0]['message']) ? $apiResponse['errors'][0]['message'] : '';
$ErrorMessageInb = isset($apiResponseInbound['errors'][0]['message']) ? $apiResponseInbound['errors'][0]['message'] : '';
$ResponseStatusInb = isset($apiResponseInbound['status']['success']) ? $apiResponseInbound['status']['success'] : 0;
if ($ResponseStatus == 1 || $IsSeriesFareData == '1') {
$alerts = isset($apiResponse['alerts']) ? $apiResponse['alerts'] : '';
if ($IsSeriesFareData == 0) {
$filterData = ['ApiSourceSysId' => 3];
$AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
$FlightBookingData = $this->UpdateFlightBookingData($apiResponse, $alerts, $SearchTraceId, $FareRuleRequest, $APIBookingData, $getMarkup ,$AdditionalMarkup);
}
//$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
//echo '<pre>';print_r($FlightBookingData->params);
// echo '<pre>';
// print_r($getMarkup);
// print_r($FlightBookingData);
// die('d');
$newFare = 0;
$oldFare = 0;
$PublishedFare = 0;
$intPublishedFare = 0;
$Baggage = [];
$Meal = [];
$ExtraMarkup = 0;
$intExtraMarkup = 0;
$ExtraMarkupOnGST = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $value) {
$ExtraMarkup += $value['FairRules']['ExtraMarkup'];
$ExtraMarkupOnGST += $value['FairRules']['ExtraMarkupOnGST'];
$newFare += $value['FairRules']['newFare'];
$PublishedFare += $value['FairRules']['newFare'];
$intPublishedFare += $value['FairRules']['PublishedFare'];
$oldFare += $value['FairRules']['oldFare'];
//echo '<pre>';print_r($value);die('d');
$Baggage[] = $value['Baggage'];
$Meal[] = $value['Meal'];
}
}
$MarkupArr['showintax'] = 0;
$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$SSRArr = array('Meal' => $Meal, 'Baggage' => $Baggage, 'SeatPreference' => array());
$FareChange = false;
if ($newFare != $oldFare) {
$FareChange = true;
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBookingData, 'MarkupArr' => $MarkupArr, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(($intPublishedFare)), 'SSRArr' => json_encode($SSRArr), 'SSRArrInb' => [], 'apiResponse' => json_encode($FlightBookingData));
echo json_encode($response);
exit;
} elseif ($ICSourceSysId == '3') {
$filterData = ['ApiSourceSysId' => 1];
$AdditionalMarkup = $this->getMarketPlace($MarketPlaceSysId,$filterData);
$FlightBookingDataArr = [];
$FlightBooking = [];
$oldFare = 0;
$newFare = 0;
$intPublishedFare = 0;
// echo '<pre>';
// print_r($FlightBookingData);
// die('ddd');
if ($FlightBookingData && $IsSeriesFareData == 0) {
foreach ($FlightBookingData as $key => $vl) {
$IsLCC = $vl['IsLCC'];
$strAirlineCode = $vl['AirlineCode'];
$FlightBookingDataArr[$key] = $vl;
$oldFare += isset($vl['FairRules']['intPublishedFare']) ? $vl['FairRules']['intPublishedFare'] : 0;
$IsTJFlightAPI = isset($vl['IsTJFlightAPI']) ? $vl['IsTJFlightAPI'] : '0';
if ($IsTJFlightAPI == '0') {
$arrData['TraceId'] = $vl['apiTraceId'];
$arrData['ResultIndex'] = $vl['FairRules']['ApiResultIndex'];
$arrData['BookingData'] = $vl;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->fareQuoteDetails($arrData, $this->intLoggedinAgencyId);
$arrSSR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->flightSSRDetails($arrData, $this->intLoggedinAgencyId);
$FBD = $this->UpdateFlightBookingDataTBO($apiResponse, $arrSSR, $vl, $sessionFlightSearchParams, $getMarkup ,$AdditionalMarkup);
$newFare += isset($FBD['BookingData']['FairRules']['intPublishedFare']) ? $FBD['BookingData']['FairRules']['intPublishedFare'] : 0;
$intPublishedFare += isset($FBD['BookingData']['FairRules']['PublishedFare']) ? $FBD['BookingData']['FairRules']['PublishedFare'] : 0;
$SSRArr = isset($FBD['SSRArr']) ? $FBD['SSRArr'] : [];
$tripSeatMap = isset($FBD['tripSeatMap']) ? $FBD['tripSeatMap'] : [];
$FlightBooking[$key] = $FBD['BookingData'];
}
}
}
// die('ddd');
$ExtraMarkup = 0;
$intExtraMarkup = 0;
$ExtraMarkupOnGST = 0;
if ($FlightBooking) {
foreach ($FlightBooking as $value) {
$ExtraMarkup += $value['FairRules']['ExtraMarkup'];
$ExtraMarkupOnGST += $value['FairRules']['ExtraMarkupOnGST'];
}
}
$MarkupArr['showintax'] = 0;
$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$FareChange = false;
if ($newFare != $oldFare) {
$FareChange = true;
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBooking, 'MarkupArr' => $MarkupArr, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'FareChange' => $FareChange, 'html' => $bodyText, 'intPublishedFare' => number_format(($intPublishedFare)), 'tripSeatMap' => json_encode($tripSeatMap), 'SSRArr' => json_encode($SSRArr), 'SSRArrInb' => [], 'apiResponse' => json_encode($FlightBooking));
echo json_encode($response);
exit;
} elseif ($route == 2 && $ResponseStatus == 1 && $interNationalSearch == 1) {
} else {
$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
echo json_encode($response);
exit;
}
echo '<pre>';
print_r($apiResponse);
die('ddd');
$SSRArrInb = array();
// $str = file_get_contents($this->baseUrl.'public/logs/flight/flightSSR/flightSSR_response.json');
// $arrSSR = json_decode($str,true);
} else {
die('Page not found!');
}
}
public function validateFlight()
{
$validation = array(
'OV'=> ['dob'=>true,'passport'=>false],
'J9'=> ['dob'=>true,'passport'=>false],
'OG'=> ['dob'=>false,'passport'=>false],
'S9'=> ['dob'=>false,'passport'=>false],
'3L'=> ['dob'=>false,'passport'=>false],
'9I'=> ['dob'=>false,'passport'=>false],
'I5'=> ['dob'=>true,'passport'=>false],
'FD'=> ['dob'=>true,'passport'=>false],
'D7'=> ['dob'=>true,'passport'=>false],
'AK'=> ['dob'=>true,'passport'=>true],
'2T'=> ['dob'=>false,'passport'=>false],
'XJ'=> ['dob'=>true,'passport'=>false],
'TR'=> ['dob'=>true,'passport'=>true],
'TZ'=> ['dob'=>true,'passport'=>true],
'QZ'=> ['dob'=>true,'passport'=>false],
'XY'=> ['dob'=>true,'passport'=>true],
'FZ'=> ['dob'=>true,'passport'=>true],
'IX'=> ['dob'=>true,'passport'=>true],
'G9'=> ['dob'=>false,'passport'=>false],
);
return $validation;
}
public function UpdateFlightBookingDataTBO($apiResponse, $arrSSR, $vl, $sessionFlightSearchParams, $getMarkup ,$AdditionalMarkup) {
$IsLCC = $vl['IsLCC'];
$strAirlineCode = $vl['AirlineCode'];
$FlightNumber = explode('-', $vl['FlightNumber']);
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'] : '';
$strSourceAirportCode = $sessionFlightSearchParams['from'];
$strDestinationAirportCode = $sessionFlightSearchParams['to'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$intMarkUp = $getCancelCharge = $this->getCancelCharge($intCountryCode);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
// $getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
// $getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$ExtraMarkup = isset($vl['FairRules']['ExtraMarkup']) ? $vl['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($vl['FairRules']['ExtraMarkupOnGST']) ? $vl['FairRules']['ExtraMarkupOnGST'] : 0;
$DiscountCoupon = isset($vl['FairRules']['DiscountCoupon']) ? $vl['FairRules']['DiscountCoupon'] : 0;
$DiscountValue = isset($vl['FairRules']['DiscountValue']) ? $vl['FairRules']['DiscountValue'] : 0;
$tripSeatMapArr = [];
$BaggageAr = [];
$Meal = [];
// echo '<pre>';
// print_r($ExtraMarkup);
// echo '<pre>';
// print_r($vl);
// die('ddd');
if ($IsLCC) {
$Baggage = isset($arrSSR['Response']['Baggage']) ? $arrSSR['Response']['Baggage'] : [];
$MealDynamic = isset($arrSSR['Response']['MealDynamic']) ? $arrSSR['Response']['MealDynamic'] : [];
$SeatDynamic = isset($arrSSR['Response']['SeatDynamic']) ? $arrSSR['Response']['SeatDynamic'] : [];
if ($Baggage) {
foreach ($Baggage as $b => $bgg) {
//$Baggage[] = $bgg;
if ($bgg) {
foreach ($bgg as $bg) {
$BaggageAr[$b][] = array(
'AirlineCode' => $bg['AirlineCode'],
'FlightNumber' => $bg['FlightNumber'],
'key' => $bg['FlightNumber'],
'WayType' => $bg['WayType'],
'Code' => $bg['Code'],
'Description' => $bg['Description'],
'Weight' => $bg['Weight'],
'Currency' => $bg['Currency'],
'Price' => $bg['Price'],
'Origin' => $bg['Origin'],
'Destination' => $bg['Destination'],
);
}
}
}
}
if ($MealDynamic) {
foreach ($MealDynamic as $b => $mell) {
if ($mell) {
foreach ($mell as $ml) {
$Meal[$b][] = array(
'AirlineCode' => $ml['AirlineCode'],
'FlightNumber' => $ml['FlightNumber'],
'key' => $ml['FlightNumber'],
'WayType' => $ml['WayType'],
'Code' => $ml['Code'],
'Description' => $ml['Description'],
'AirlineDescription' => $ml['AirlineDescription'],
'Quantity' => $ml['Quantity'],
'Currency' => $ml['Currency'],
'Price' => $ml['Price'],
'Origin' => $ml['Origin'],
'Destination' => $ml['Destination'],
);
}
}
}
}
if ($SeatDynamic) {
foreach ($SeatDynamic as $stSeg) {
$SegmentSeat = $stSeg['SegmentSeat'];
if ($SegmentSeat) {
foreach ($SegmentSeat as $STKEY => $SG) {
$RowSeats = $SG['RowSeats'];
$sInfo = [];
$R = 1;
$segmentid = isset($vl['Segments'][$STKEY]['segmentid']) ? $vl['Segments'][$STKEY]['segmentid'] : 0;
// echo '<pre>';
// print_r($segmentid);
if ($RowSeats) {
foreach ($RowSeats as $RK => $RS) {
$Seats = $RS['Seats'];
$C = 1;
if ($Seats) {
foreach ($Seats as $SK => $ST) {
$sInfo[] = array(
'AirlineCode' => $ST['AirlineCode'],
'FlightNumber' => $ST['FlightNumber'],
'CraftType' => $ST['CraftType'],
'Origin' => $ST['Origin'],
'Destination' => $ST['Destination'],
'AvailablityType' => $ST['AvailablityType'],
'isBooked' => ($ST['AvailablityType'] == 3) ? true : false,
'Description' => $ST['Description'],
'Code' => $ST['Code'],
'code' => $ST['Code'],
'RowNo' => $ST['RowNo'],
'SeatNo' => $ST['SeatNo'],
'seatNo' => ($ST['Code'] == 'NoSeat') ? '' : $ST['Code'],
'SeatType' => $ST['SeatType'],
'SeatWayType' => $ST['SeatWayType'],
'Compartment' => $ST['Compartment'],
'Deck' => $ST['Deck'],
'Currency' => $ST['Currency'],
'Price' => $ST['Price'],
'amount' => $ST['Price'],
'Text' => $ST['Text'],
'seatPosition' => ['row' => $R, 'column' => $C],
);
$C++;
}
}
$R++;
}
}
$tripSeatMapArr[$segmentid]['sData'] = array('row' => count($RowSeats), 'column' => 7);
$tripSeatMapArr[$segmentid]['sInfo'] = $sInfo;
}
}
}
}
} else {
$MealDynamic = isset($arrSSR['Response']['Meal']) ? $arrSSR['Response']['Meal'] : [];
if ($MealDynamic) {
foreach ($MealDynamic as $k => $ml) {
$Meal[] = array(
'Code' => $ml['Code'],
'Description' => $ml['Description'],
'AirlineDescription' => $ml['Description'],
'Currency' => $this->CurrencyTitle,
'amount' => 0,
'Price' => 0,
'key' => $FlightNumber[1],
);
}
}
}
$ResponseStatus = $apiResponse['Response']['ResponseStatus'];
$ErrorMessage = $apiResponse['Response']['Error']['ErrorMessage'];
$result = $apiResponse['Response']['Results'];
$SegmentsArrary = $result['Segments'];
// echo '<pre>';
// print_r($vl['ApiResultIndex']);
// echo '<pre>';
// print_r($result);die;
if ($ResponseStatus == 1) {
$ResultIndex = $result['ResultIndex'];
$Currency = $result['Fare']['Currency'];
$currencySysId = $this->CurrencyId;
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
$AirlineCode = $result['AirlineCode'];
$fareIdentifier = $fareIdentifier__ = !empty($result['FareClassification']['Type']) ? str_replace('.', '_', strtoupper($result['FareClassification']['Type'])) : strtoupper(trim($result['ResultFareType']));
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdcolor = !empty($AddMarkup['color']) ? $AddMarkup['color'] : $fareIdcolor;
$fareIdentifier = (isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) && !empty($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'])) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : $fareIdentifier__;
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'])?$AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']:0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$MiniFareRules = (isset($result['MiniFareRules']) && !empty($result['MiniFareRules'])) ? $result['MiniFareRules'] : [];
$MiniFR = [];
if ($MiniFareRules) {
foreach ($MiniFareRules as $Minivalue) {
if ($Minivalue) {
foreach ($Minivalue as $kk => $Mini) {
$Type = !empty($Mini['Type']) ? strtoupper($Mini['Type']) : 'NA';
if (empty($Mini['To'])) {
$TimeFrame = 'from ' . $Mini['From'] . ' ' . $Mini['Unit'] . ' & above before dept';
} else {
$TimeFrame = 'from ' . $Mini['From'] . ' To ' . $Mini['To'] . ' ' . $Mini['Unit'] . ' before dept';
}
//$MiniFR[$Type][$kk] = $Mini;
$MiniFR[$Type][$kk]['sector'] = $Mini['JourneyPoints'];
$MiniFR[$Type][$kk]['amount'] = $Mini['Details'];
$MiniFR[$Type][$kk]['additionalFee'] = $getCancelCharge;
$MiniFR[$Type][$kk]['TimeFrame'] = $TimeFrame;
$MiniFR[$Type][$kk]['policyInfo'] = [];
}
}
}
}
$tripbinfo = [];
$tripbinfoBreack = [];
if($result['Segments']){
foreach($result['Segments'] as $value){
if($value){
foreach($value as $kk=>$vlbagg){
$Baggage = $vlbagg['Baggage'];
$CabinBaggage = $vlbagg['CabinBaggage'];
$SectorsCode = $vlbagg['Origin']['Airport']['AirportCode'].'-'.$vlbagg['Destination']['Airport']['AirportCode'];
$tripbinfo[$SectorsCode]['ADULT'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
$tripbinfoBreack[$SectorsCode]['1'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
if(!empty($childCount)){
$tripbinfo[$SectorsCode]['CHILD'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
$tripbinfoBreack[$SectorsCode]['2'] = ['cabin'=>$CabinBaggage,'checkin'=>$Baggage];
}
if(!empty($infantCount)){
$tripbinfo[$SectorsCode]['INFANT'] = ['cabin'=>$CabinBaggage,'checkin'=>'NA'];
$tripbinfoBreack[$SectorsCode]['3'] = ['cabin'=>$CabinBaggage,'checkin'=>'NA'];
}
}
}
}
}
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$ResultFareType = $result['ResultFareType'];
$FareBreakdown = $result['FareBreakdown'];
$totalCommissions = $result['Fare']['CommissionEarned'] + $result['Fare']['PLBEarned'] + $result['Fare']['IncentiveEarned'];
$totalCommissionsOnTds = $result['Fare']['TdsOnCommission'] + $result['Fare']['TdsOnIncentive'] + $result['Fare']['TdsOnPLB'];
$TotalPassengerCountForDiscount = $adultCount + $childCount;
$intDiscountPerHead = $totalCommissions / $TotalPassengerCountForDiscount;
//$intDiscountPerHead = $totalCommissions;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => $OfferedFare,
'intCommissionEarned' => $totalCommissions,
'TdsOnPLB' => $totalCommissionsOnTds,
'MUFee' => $ServiceFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo "<pre>"; print_r($result);echo "</pre>";
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr, 'Review');
$intPublishedFare = $arrMarkUps['PublishFare'];
$tripbinfoBreack = array_values($tripbinfoBreack);
$countBreakUp = count($FareBreakdown);
foreach ($FareBreakdown as $pk => $pax) {
$intBaseFare = $pax['BaseFare'];
$intTax = $pax['Tax'];
$OtherCharges_ = ($OtherCharges / $countBreakUp);
$intDiscountPerHead_ = ($intDiscountPerHead / $countBreakUp);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead_;
$intFareOfferedToPax = $intBaseFareCal + $intTax;
$Breackbagg = isset($tripbinfoBreack[0][$pax['PassengerType']]) ? $tripbinfoBreack[0][$pax['PassengerType']] : '';
$intPassengerCount = isset($pax['PassengerCount']) ? $pax['PassengerCount'] : 0;
$arrFareBreakdown[$pk]['Currency'] = $this->CurrencyTitle; //$pax['Currency'];
$arrFareBreakdown[$pk]['PassengerType'] = $pax['PassengerType'];
$arrFareBreakdown[$pk]['PassengerCount'] = $pax['PassengerCount'];
$arrFareBreakdown[$pk]['TaxIN'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['TotalBaseFare'] = 0;
$arrFareBreakdown[$pk]['BaseFareCal'] = ($arrMarkUps['BaseFareCal'] / $countBreakUp);
$arrFareBreakdown[$pk]['BaseFare'] = $pax['BaseFare'];
$arrFareBreakdown[$pk]['Tax'] = ($pax['Tax']);
$arrFareBreakdown[$pk]['CommissionEarned'] = ($totalCommissions / $countBreakUp);
$arrFareBreakdown[$pk]['OtherCharges'] = ($OtherCharges_);
$arrFareBreakdown[$pk]['ServiceFee'] = ($ServiceFee / $countBreakUp);
//$arrFareBreakdown[$pk]['TDS'] = ($totalCommissionsOnTds / $countBreakUp);
$arrFareBreakdown[$pk]['TDS'] = ($arrMarkUps['TripjackTDS'] / $countBreakUp);
$arrFareBreakdown[$pk]['MF'] = 0;
$arrFareBreakdown[$pk]['YQ'] = $pax['YQTax'];
$arrFareBreakdown[$pk]['AGST'] = 0;
$arrFareBreakdown[$pk]['MFT'] = 0;
$arrFareBreakdown[$pk]['OT'] = $pax['Tax'];
$arrFareBreakdown[$pk]['MU'] = ($ServiceFee / $countBreakUp);
$arrFareBreakdown[$pk]['YR'] = 0;
$arrFareBreakdown[$pk]['intTotalGST'] = ($arrMarkUps['intTotalGST'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiMarkup'] = ($arrMarkUps['apiMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommisionPass'] = ($arrMarkUps['CommisionPass'] / $countBreakUp);
$arrFareBreakdown[$pk]['IntCommission'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['apiTaxOnMarkup'] = ($arrMarkUps['apiTaxOnMarkup'] / $countBreakUp);
$arrFareBreakdown[$pk]['FixedMarkUp'] = ($arrMarkUps['IntAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTOnMarkUp'] = ($arrMarkUps['IntTaxOnAgencyFixMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['CommEarned'] = ($arrMarkUps['IntCommission'] / $countBreakUp);
; //($arrMarkUps['intCommisionEarnedForAgency'] / $countBreakUp);
$arrFareBreakdown[$pk]['GSTonComm'] = 0;
$arrFareBreakdown[$pk]['intGTXMarkUp'] = ($arrMarkUps['intGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['GTXMarkUpGST'] = ($arrMarkUps['intSTaxOnGTXMarkUp'] / $countBreakUp);
$arrFareBreakdown[$pk]['Agencycommission'] = ($arrMarkUps['Agencycommission'] / $countBreakUp);
$arrFareBreakdown[$pk]['AdditionalTxnFeeOfrd'] = $pax['AdditionalTxnFeeOfrd'];
$arrFareBreakdown[$pk]['AdditionalTxnFeePub'] = $pax['AdditionalTxnFeePub'];
$arrFareBreakdown[$pk]['PGCharge'] = 0;
//$arrFareBreakdown[$pk]['Baggage'] = ''; //Check In Baggage;
//$arrFareBreakdown[$pk]['CabinBaggage'] = ''; //Cabin Baggage ;
$arrFareBreakdown[$pk]['Baggage'] = isset($Breackbagg['checkin'])?$Breackbagg['checkin']:''; //Check In Baggage;
$arrFareBreakdown[$pk]['CabinBaggage'] = isset($Breackbagg['cabin'])?$Breackbagg['cabin']:''; //Cabin Baggage ;
}
// print_r($arrFareBreakdown);die;
$FareBreakdownar = [];
$FareBreakCount = count($arrFareBreakdown);
if ($arrFareBreakdown) {
foreach ($arrFareBreakdown as $brk => $farebreack) {
$FareBreakdownar[$brk] = $farebreack;
$FareBreakdownar[$brk]['ExtraMarkup'] = ((float) ($ExtraMarkup) / $FareBreakCount);
$FareBreakdownar[$brk]['ExtraMarkupOnGST'] = ((float) ($ExtraMarkupOnGST) / $FareBreakCount);
$FareBreakdownar[$brk]['DiscountCoupon'] = ($DiscountValue > 0) ? 1 : 0;
$FareBreakdownar[$brk]['DiscountValue'] = ((float) ($DiscountValue) / $FareBreakCount);
}
}
$arrFairRules = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => $PublishedFare,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"PublishedFareAgent" => ($arrMarkUps['CostToAgentCustomer'] * $this->CurrencyRate),
"OfferedFareAgent" => ($arrMarkUps['CostToAgent'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"PriceID" => $ResultIndex,
"ApiResultIndex" => $ResultIndex,
"IsGSTRequired" => $IsGSTMandatory,
"fareIdentifier" => $fareIdentifier,
"colors" => $fareIdcolor,
"FareClass" => $cabinClass,
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"CommisionPass" => $arrMarkUps['CommisionPass'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"CommEarnedAgent" => $arrMarkUps['AgentB2CEarning'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"ExtraMarkup" => $ExtraMarkup,
"ExtraMarkupOnGST" => $ExtraMarkupOnGST,
"DiscountCoupon" => $DiscountCoupon,
"DiscountValue" => $DiscountValue,
"FareBreakdown" => $FareBreakdownar,
"arrMarkUps" => $arrMarkUps,
"MiniFR" => $MiniFR,
"tripbinfo" => $tripbinfo,
);
$vl['FairRules'] = $arrFairRules;
$IsPassportRequiredAtBook = isset($result['IsPassportRequiredAtBook']) ? $result['IsPassportRequiredAtBook'] : false;
$IsPassportRequiredAtTicket = isset($result['IsPassportRequiredAtTicket']) ? $result['IsPassportRequiredAtTicket'] : false;
$validation = $this->validateFlight();
if ($IsLCC) {
if ($IsPassportRequiredAtTicket || $interNationalSearch == 1) {
$IsPassMandatory = true;
$IsPassExpiry = true;
$IsPassIssue = false;
} else {
$IsPassMandatory = isset($validation[$strAirlineCode]['passport'])?$validation[$strAirlineCode]['passport']:false;
$IsPassExpiry = isset($validation[$strAirlineCode]['passport'])?$validation[$strAirlineCode]['passport']:false;
$IsPassIssue = false;
}
} else {
if ($IsPassportRequiredAtBook) {
$IsPassMandatory = true;
$IsPassExpiry = true;
$IsPassIssue = false;
} else {
$IsPassMandatory = false;
$IsPassExpiry = false;
$IsPassIssue = false;
}
}
$IsPassDateOfBirth = false;
$isGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : false;
$IsPanRequiredAtBook = isset($result['IsPanRequiredAtBook']) ? $result['IsPanRequiredAtBook'] : false;
$IsPanRequiredAtTicket = isset($result['IsPanRequiredAtTicket']) ? $result['IsPanRequiredAtTicket'] : false;
$isSeatApplicable = false;
$isSessionTime = false;
$isSessionTime = 0;
if ($interNationalSearch == 1) {
$isAdobrMandatory = true;
$isCdobrMandatory = true;
$isIdobrMandatory = true;
} else if ($strAirlineCode == 'I5') {
$isAdobrMandatory = true;
$isCdobrMandatory = true;
$isIdobrMandatory = true;
} else {
$isAdobrMandatory = isset($validation[$strAirlineCode]['dob'])?$validation[$strAirlineCode]['dob']:false;
$isCdobrMandatory = isset($validation[$strAirlineCode]['dob'])?$validation[$strAirlineCode]['dob']:false;
$isIdobrMandatory = true;
}
$vl['Ispassengercity'] = true;
$vl['Ispassengeraddress'] = true;
$vl['ApiResultIndex'] = $ResultIndex;
$vl['isGSTMandatory'] = $isGSTMandatory;
$vl['CurrencyType'] = $this->CurrencyId;
$vl['IsPassMandatory'] = $IsPassMandatory;
$vl['IsPassExpiry'] = $IsPassExpiry;
$vl['IsPassIssue'] = $IsPassIssue;
$vl['IsPassDateOfBirth'] = $IsPassDateOfBirth;
$vl['isAdobrMandatory'] = $isAdobrMandatory;
$vl['isCdobrMandatory'] = $isCdobrMandatory;
$vl['isIdobrMandatory'] = $isIdobrMandatory;
$vl['isSeatApplicable'] = $isSeatApplicable;
$vl['IsPanRequiredAtTicket'] = $IsPanRequiredAtTicket;
$vl['IsPanRequiredAtBook'] = $IsPanRequiredAtBook;
$vl['isSessionTime'] = $isSessionTime . ':00';
$SegmentsArr = [];
$SegmentsArrInt = [];
if ($strFlightRoute == "2" && $interNationalSearch == "1") {
if ($SegmentsArrary) {
foreach ($SegmentsArrary as $kk => $segment) {
$BaggageArrNew = isset($Baggage[$kk]) ? $Baggage[$kk] : [];
if ($IsLCC) {
$MealArrNew = isset($MealDynamic[$kk]) ? $MealDynamic[$kk] : [];
} else {
$MealArrNew = isset($Meal) ? $Meal : [];
}
foreach ($segment as $k => $segval) {
$SegmentsArrInt[$kk][$k] = $segval;
$SegmentsArrInt[$kk][$k]['BAGGAGEARRAY'] = $BaggageArrNew;
$SegmentsArrInt[$kk][$k]['MEALARRAY'] = $MealArrNew;
}
}
}
}
if ($vl['Segments']) {
foreach ($vl['Segments'] as $kk => $segment) {
$isReturnSegment = !empty($segment['isReturnSegment']) ? $segment['isReturnSegment'] : 0;
$BaggageArrNew = isset($Baggage[$isReturnSegment]) ? $Baggage[$isReturnSegment] : [];
if ($IsLCC) {
$MealArrNew = isset($MealDynamic[$isReturnSegment]) ? $MealDynamic[$isReturnSegment] : [];
} else {
$MealArrNew = isset($Meal) ? $Meal : [];
}
$SegmentsArr[$kk] = $segment;
$SegmentsArr[$kk]['BAGGAGEARRAY'] = $BaggageArrNew;
$SegmentsArr[$kk]['MEALARRAY'] = $MealArrNew;
}
}
$vl["Segments"] = $SegmentsArr;
$vl["SegmentsInt"] = $SegmentsArrInt;
//$vl[0]['InternationalData'] = $vl;
// echo "<pre>"; print_r($vl);echo "</pre>";
if (!empty($tripSeatMapArr)) {
$tripSeatMap['tripSeatMap']['tripSeat'] = $tripSeatMapArr;
$tripSeatMap['status'] = ['success' => true, 'httpStatus' => 200];
} else {
$tripSeatMap['tripSeatMap']['tripSeat'] = [];
$tripSeatMap['status'] = ['success' => false, 'httpStatus' => 400];
}
if ($IsLCC) {
$SSRArr = array('Meal' => $Meal, 'Baggage' => $BaggageAr, 'SeatPreference' => array());
} else {
$Mealwwww[0] = $Meal;
$SSRArr = array('Meal' => $Mealwwww, 'Baggage' => $BaggageAr, 'SeatPreference' => array());
}
$response = array('success' => true, 'BookingData' => $vl, 'SSRArr' => $SSRArr, 'tripSeatMap' => $tripSeatMap, 'SeatDynamic' => ($SeatDynamic), 'SSRArrInb' => []);
return $response;
} else {
$response = array('success' => false, 'message' => 'Session is expired. Please try again with new session', 'FareChange' => false, 'html' => '');
echo json_encode($response);
exit;
}
}
public function UpdateFlightBookingData($data, $alerts, $SearchTraceId, $FareRuleRequest, $APIBookingData, $getMarkup ,$AdditionalMarkup) {
//echo '<pre>';print_r($SearchTraceId);die;
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$FlightBookingData = $APIBookingData['FlightBookingData'];
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$apiResponse = $data;
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
//$FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
$FlightSearchGuard = new Zend_Session_Namespace('FlightSearchGuard');
$CurrentFlightSearchGuard = new Zend_Session_Namespace('CurrentFlightSearchGuard');
$FlightSearchResults = new Zend_Session_Namespace('FlightSearchResults');
$intSourceCityId = ($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = ($sessionFlightSearchParams['destinationCityId']);
$interNationalSearch = trim($sessionFlightSearchParams['interNationalSearch']);
$strDepatureDate = $sessionFlightSearchParams['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams['return_dates']) ? $sessionFlightSearchParams['return_dates'] : '';
$strSourceAirportCode = $sessionFlightSearchParams['from'];
$strDestinationAirportCode = $sessionFlightSearchParams['to'];
$adultCount = $sessionFlightSearchParams['adults'];
$childCount = $sessionFlightSearchParams['child'];
$infantCount = $sessionFlightSearchParams['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$this->CurrencyRate = $sessionFlightSearchParams['CurrencyRate'];
$this->CurrencyTitle = $sessionFlightSearchParams['CurrencyTitle'];
$this->CurrencyId = $sessionFlightSearchParams['CurrencyId'];
$flight_class = trim($sessionFlightSearchParams['flight_class']);
$preferredFlightClassType = ($flight_class == 1) ? 2 : $flight_class;
$arrFlightClass = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getFlightClassesTripJack();
$cabinClass = isset($arrFlightClass[$preferredFlightClassType]) ? $arrFlightClass[$preferredFlightClassType] : 'Economy';
$intTatalPaxCT = $adultCount + $childCount;
//$getMarkup = $this->getMarkup($intCountryCode);
$intMarkUp = $this->getCancelCharge($intCountryCode);
$B2BType = (int) $sessionFlightSearchParams['B2BType'];
$CustomerSysId = $sessionFlightSearchParams['CustomerSysId'];
// $getMarkupB2B = $this->getMarkupB2B($intCountryCode, $CustomerSysId, $B2BType);
// $getMarkup['arrAgencyMarkups'] = $getMarkupB2B;
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$AgencyMarkup = ($intMarkUp * $intMemberCount);
$FareRules = isset($FareRuleRequest['fareRule']) ? $FareRuleRequest['fareRule'] : [];
$success = $FareRuleRequest['status']['success'];
$FareRulesCancel = [];
if ($FareRules && $success) {
foreach ($FareRules as $keys => $val) {
$CANCELLATION = isset($val['tfr']['CANCELLATION']) ? $val['tfr']['CANCELLATION'] : '';
$DATECHANGE = isset($val['tfr']['DATECHANGE']) ? $val['tfr']['DATECHANGE'] : '';
$NO_SHOW = isset($val['tfr']['NO_SHOW']) ? $val['tfr']['NO_SHOW'] : '';
$SEAT_CHARGEABLE = isset($val['tfr']['SEAT_CHARGEABLE']) ? $val['tfr']['SEAT_CHARGEABLE'] : '';
$NOSHOW_ARR = [];
$DATECHANGE_ARR = [];
$CANCELLATION_ARR = [];
$SEATCHARGEABLE_ARR = [];
if (!empty($NO_SHOW)) {
foreach ($NO_SHOW as $key => $values) {
$policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
$NOSHOW_ARR['NO_SHOW'][] = array(
'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : $AgencyMarkup,
'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ($policyInfo),
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
} else {
$CANCELLATION_ARR['NO_SHOW'][] = array(
'amount' => 0,
'additionalFee' => ($AgencyMarkup),
'amount_' => 0,
'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ['No show policy Info'],
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
if (!empty($DATECHANGE)) {
foreach ($DATECHANGE as $key => $values) {
$policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
$DATECHANGE_ARR['DATECHANGE'][] = array(
'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ($policyInfo),
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
} else {
$CANCELLATION_ARR['DATECHANGE'][] = array(
'amount' => 0,
'additionalFee' => ($AgencyMarkup),
'amount_' => 0,
'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ['Difference in Fare + Taxes + Surcharges'],
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
if (!empty($CANCELLATION)) {
foreach ($CANCELLATION as $key => $values) {
$policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
$CANCELLATION_ARR['CANCELLATION'][] = array(
'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ($policyInfo),
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
} else {
$CANCELLATION_ARR['CANCELLATION'][] = array(
'amount' => 0,
'additionalFee' => ($AgencyMarkup),
'amount_' => 0,
'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ['Airline Cancellation Charges + Taxes + Surcharges'],
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
if (!empty($SEAT_CHARGEABLE)) {
foreach ($SEAT_CHARGEABLE as $key => $values) {
$policyInfo = isset($values['policyInfo']) ? array_values(array_filter(explode('__nls__', $values['policyInfo']))) : ['Difference in Fare + Taxes + Surcharges'];
$SEATCHARGEABLE_ARR['SEAT_CHARGEABLE'][] = array(
'amount' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee' => isset($values['additionalFee']) ? $values['additionalFee'] + $AgencyMarkup : ($AgencyMarkup),
'amount_' => isset($values['amount']) ? ceil($values['amount'] * $this->CurrencyRate) : 0,
'additionalFee_' => isset($values['additionalFee']) ? ceil(($values['additionalFee'] + $AgencyMarkup) * $this->CurrencyRate) : ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ($policyInfo),
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
} else {
$CANCELLATION_ARR['SEAT_CHARGEABLE'][] = array(
'amount' => 0,
'additionalFee' => ($AgencyMarkup),
'amount_' => 0,
'additionalFee_' => ($AgencyMarkup * $this->CurrencyRate),
'policyInfo' => ['As per Airlines'],
'CurrencyTitle' => ($this->CurrencyTitle),
);
}
$FareRulesCancel[] = array(
'sector' => $keys,
'status' => $success,
'FareRules' => array_merge($NOSHOW_ARR, $DATECHANGE_ARR, $CANCELLATION_ARR, $SEATCHARGEABLE_ARR),
);
}
} else {
$FareRulesCancel[] = array(
'sector' => '',
'status' => $success,
'FareRules' => [],
);
}
// echo '<pre>';print_r($FareRulesCancel);die;
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => $strFlightRoute,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
// echo '<pre>';print_r($arrCommonInsVariables);
// echo '<pre>';print_r($sessionFlightSearchParams);
// die;
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
$intTripType = $strFlightRoute;
$arrInsertFlightData = [];
$BaggageArr = [];
$MealArr = [];
$bookingId = $data['bookingId'];
$alerts = isset($data['alerts']) ? $data['alerts'] : [];
$IsPassMandatory = isset($data['conditions']['pcs']['pm']) ? $data['conditions']['pcs']['pm'] : false;
$IsPassExpiry = isset($data['conditions']['pcs']['pped']) ? $data['conditions']['pcs']['pped'] : false;
$IsPassIssue = isset($data['conditions']['pcs']['pid']) ? $data['conditions']['pcs']['pid'] : false;
$IsPassDateOfBirth = isset($data['conditions']['pcs']['dobe']) ? $data['conditions']['pcs']['dobe'] : false;
$isGSTMandatory = isset($data['conditions']['gst']['igm']) ? $data['conditions']['gst']['igm'] : false;
$isSeatApplicable = isset($data['conditions']['isa']) ? $data['conditions']['isa'] : false;
$isSessionTime = isset($data['conditions']['st']) ? $data['conditions']['st'] : false;
$IsPassDateOfBirth = isset($data['conditions']['pcs']['dobe']) ? $data['conditions']['pcs']['dobe'] : false;
$isSessionTime = floor(($isSessionTime / 60) % 60);
if ($IsPassDateOfBirth && $interNationalSearch) {
$isAdobrMandatory = true;
$isCdobrMandatory = true;
$isIdobrMandatory = true;
$IsPassMandatory = true;
$IsPassExpiry = true;
$IsPassIssue = true;
} else {
$isAdobrMandatory = isset($data['conditions']['dob']['adobr']) ? $data['conditions']['dob']['adobr'] : false;
$isCdobrMandatory = isset($data['conditions']['dob']['cdobr']) ? $data['conditions']['dob']['cdobr'] : false;
$isIdobrMandatory = isset($data['conditions']['dob']['idobr']) ? $data['conditions']['dob']['idobr'] : false;
}
$arrInsertFlightBookingData = [];
if ($data['tripInfos']) {
$TempArr['onward'] = $data['tripInfos'][0];
$TempArr['return'] = $data['tripInfos'][1];
$totalPriceListArr = array_merge($TempArr['onward']['totalPriceList'], $TempArr['return']['totalPriceList']);
foreach ($data['tripInfos'] as $key => $result) {
if ($key == 0) {
$intJourneyType = 1;
} else {
$intJourneyType = 2;
}
$BookingData = $FlightBookingData[$key];
//
$alertsFare = isset($alerts[$key]) ? $alerts[$key] : [];
$newFare = isset($alertsFare['newFare']) ? $alertsFare['newFare'] : 0;
$oldFare = isset($alertsFare['oldFare']) ? $alertsFare['oldFare'] : 0;
$SegmentInformation = $result['sI'];
$totalPriceList = current($result['totalPriceList']);
$IsRefundable = $totalPriceList['fd']['ADULT']['rT'];
$NoOfSeatAvailable = $totalPriceList['fd']['ADULT']['sR'];
$strFareClass = $totalPriceList['fd']['ADULT']['cB'];
$IsMealIncludes = $totalPriceList['fd']['ADULT']['mI'];
$bagInfo = $totalPriceList['fd']['ADULT']['bI']['iB'];
$strTraceId = $BookingData['FairRules']['PriceID'];
$ResultIndex = $BookingData['FairRules']['PriceID'];
$ExtraMarkup = isset($BookingData['FairRules']['ExtraMarkup']) ? $BookingData['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($BookingData['FairRules']['ExtraMarkupOnGST']) ? $BookingData['FairRules']['ExtraMarkupOnGST'] : 0;
$DiscountCoupon = isset($BookingData['FairRules']['DiscountCoupon']) ? $BookingData['FairRules']['DiscountCoupon'] : 0;
$DiscountValue = isset($BookingData['FairRules']['DiscountValue']) ? $BookingData['FairRules']['DiscountValue'] : 0;
// echo '<pre>';print_r($result['totalPriceList'][0]['fareRuleInformation']);die;
if (!empty($bagInfo)) {
$IsBagIncludes = true;
} else {
$IsBagIncludes = false;
}
if ($IsRefundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($IsRefundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$OriginSegments = current($SegmentInformation);
$DestinationSegments = end($SegmentInformation);
$arrSegments = [];
$FlyingMinutes = 0;
$TotalLAYOVERMinutes = 0;
$LAYOVERCityArr = [];
$PublishedFare = 0;
$BaseFare = 0;
$Tax = 0;
$YQTax = 0;
$OtherCharges = 0;
$ServiceFee = 0;
$FareBreakdown = [];
$FairRulesArr = [];
$AirlineCode = $OriginSegments['fD']['aI']['code'];
array_multisort($result['totalPriceList']);
if ($result['totalPriceList']) {
foreach ($result['totalPriceList'] as $kp => $price) {
$fareDetail = $price['fd'];
//echo '<pre>';print_r(($fareDetail));echo '</pre>';
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$fareIdentifier = $price['fareIdentifier'];
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = 0; //isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = 0; //isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = 0; //isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
//$PublishedFareIN = $NetFare;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = $PublishedFareIN;
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => ($NetFare - $TdsOnPLBCal),
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo '<pre>';print_r(($markUpArr));echo '</pre>';
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr, 'Review');
//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[0]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] = ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] = ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] = ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] = ($ADULTNCMTDS * $adultCount);
$FareBreakdown[0]['MF'] = ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] = ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] = ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] = ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] = ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] = ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] = ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] = 0;
$FareBreakdown[0]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[0]['PGCharge'] = 0;
$FareBreakdown[0]['NetFare'] = ($ADULT['NF'] * $adultCount);
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[1]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] = ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] = ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] = ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] = ($CHILDNCMTDS * $childCount);
$FareBreakdown[1]['MF'] = ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] = ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] = ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] = ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] = ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] = ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] = ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] = 0;
$FareBreakdown[1]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['NetFare'] = ($CHILD['NF'] * $childCount);
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[2]['Currency'] = $this->CurrencyTitle;
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] = ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] = ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] = ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] = ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] = ($INFANTNCMTDS * $infantCount);
$FareBreakdown[2]['MF'] = ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] = ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] = ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] = ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] = ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] = ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] = ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] = $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] = $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] = $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] = $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] = $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] = $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] = $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] = 0;
$FareBreakdown[2]['intGTXMarkUp'] = $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] = $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] = 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] = 0;
$FareBreakdown[2]['PGCharge'] = 0;
$FareBreakdown[2]['NetFare'] = ($INFANT['NF'] * $infantCount);
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
$FareBreakdownar = [];
$FareBreakCount = count($FareBreakdown);
if ($FareBreakdown) {
foreach ($FareBreakdown as $brk => $farebreack) {
$FareBreakdownar[$brk] = $farebreack;
$FareBreakdownar[$brk]['ExtraMarkup'] = ((float) ($ExtraMarkup) / $FareBreakCount);
$FareBreakdownar[$brk]['ExtraMarkupOnGST'] = ((float) ($ExtraMarkupOnGST) / $FareBreakCount);
$FareBreakdownar[$brk]['DiscountCoupon'] = ($DiscountValue > 0) ? 1 : 0;
$FareBreakdownar[$brk]['DiscountValue'] = ((float) ($DiscountValue) / $FareBreakCount);
}
}
//echo '<pre>';print_r($price);
$FairRulesArr = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareIN,
"Tax" => $TaxIN,
"YQTax" => $YQTax,
"OtherCharges" => $OtherCharges,
"Discount" => 0, //$Discount,
"ServiceFee" => $ServiceFee,
"ManagementFeeTax" => $ManagementFeeTax,
"AirlineGSTComponent" => $AirlineGSTComponent,
"CarrierMiscFee" => $CarrierMiscFee,
"MUFee" => $MUFee,
"intPublishedFare" => $PublishedFareIN,
"PublishedFare" => ($arrMarkUps['PublishFare'] * $this->CurrencyRate),
"OfferedFare" => $arrMarkUps['intOfferedFare'],
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => str_replace('_', ' ', $fareIdentifier),
"colors" => $fareIdcolor,
"FareClass" => $fareDetail['ADULT']['cc'],
"intTotalGST" => $arrMarkUps['intTotalGST'],
"apiMarkup" => $arrMarkUps['apiMarkup'],
"IntCommission" => $arrMarkUps['IntCommission'],
"apiTaxOnMarkup" => $arrMarkUps['apiTaxOnMarkup'],
"FixedMarkUp" => $arrMarkUps['IntAgencyFixMarkUp'],
"GSTOnMarkUp" => $arrMarkUps['IntTaxOnAgencyFixMarkUp'],
"CommEarned" => $arrMarkUps['IntCommission'], //$arrMarkUps['intCommisionEarnedForAgency'],
"GSTonComm" => 0,
"intGTXMarkUp" => $arrMarkUps['intGTXMarkUp'],
"GTXMarkUpGST" => $arrMarkUps['intSTaxOnGTXMarkUp'],
"ExtraMarkup" => $ExtraMarkup,
"ExtraMarkupOnGST" => $ExtraMarkupOnGST,
"DiscountCoupon" => $DiscountCoupon,
"DiscountValue" => $DiscountValue,
"newFare" => $newFare,
"oldFare" => $oldFare,
"FareBreakdown" => $FareBreakdownar,
"arrMarkUps" => $arrMarkUps,
);
}
}
$BAGGAGE = isset($OriginSegments['ssrInfo']['BAGGAGE']) ? $OriginSegments['ssrInfo']['BAGGAGE'] : '';
$MEAL = isset($OriginSegments['ssrInfo']['MEAL']) ? $OriginSegments['ssrInfo']['MEAL'] : '';
if ($BAGGAGE) {
foreach ($BAGGAGE as $b => $bag) {
$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
$BaggageArr[$b]['Currency'] = $this->CurrencyTitle;
$BaggageArr[$b]['key'] = $OriginSegments['id'];
$BaggageArr[$b]['Code'] = $bag['code'];
$BaggageArr[$b]['Price'] = isset($bag['amount']) ? ($bag['amount']) : 0;
$BaggageArr[$b]['Amount'] = isset($bag['amount']) ? ($bag['amount'] * $this->CurrencyRate) : 0;
$BaggageArr[$b]['Weight'] = $Weight;
}
}
if ($MEAL) {
foreach ($MEAL as $m => $meals) {
$MealArr[$m]['Currency'] = $this->CurrencyTitle;
$MealArr[$m]['key'] = $OriginSegments['id'];
$MealArr[$m]['Code'] = $meals['code'];
$MealArr[$m]['Price'] = isset($meals['amount']) ? ($meals['amount'] ) : 0;
$MealArr[$m]['Amount'] = isset($meals['amount']) ? ($meals['amount'] * $this->CurrencyRate) : 0;
$MealArr[$m]['Description'] = $meals['desc'];
}
}
if ($SegmentInformation) {
foreach ($SegmentInformation as $segments) {
$BAGGAGEARRAY = isset($segments['ssrInfo']['BAGGAGE']) ? $segments['ssrInfo']['BAGGAGE'] : [];
$MEALARRAY = isset($segments['ssrInfo']['MEAL']) ? $segments['ssrInfo']['MEAL'] : [];
//echo '<pre>';print_r($BAGGAGEARRAY);echo '</pre>';
$MealArrNew = [];
$BaggageArrNew = [];
if ($MEALARRAY) {
foreach ($MEALARRAY as $m => $meals) {
$MealArrNew[$m]['Currency'] = $this->CurrencyTitle;
$MealArrNew[$m]['key'] = $segments['id'];
$MealArrNew[$m]['Code'] = $meals['code'];
$MealArrNew[$m]['Price'] = isset($meals['amount']) ? ($meals['amount'] ) : 0;
$MealArrNew[$m]['Amount'] = isset($meals['amount']) ? ($meals['amount'] * $this->CurrencyRate) : 0;
$MealArrNew[$m]['Description'] = $meals['desc'];
}
}
if ($BAGGAGEARRAY) {
foreach ($BAGGAGEARRAY as $b => $bag) {
$Weight = str_replace('Excess Baggage - ', '', $bag['desc']);
$BaggageArrNew[$b]['Currency'] = $this->CurrencyTitle;
$BaggageArrNew[$b]['key'] = $segments['id'];
$BaggageArrNew[$b]['Code'] = $bag['code'];
$BaggageArrNew[$b]['Price'] = isset($bag['amount']) ? ($bag['amount'] ) : 0;
$BaggageArrNew[$b]['Amount'] = isset($bag['amount']) ? ($bag['amount'] * $this->CurrencyRate) : 0;
$BaggageArrNew[$b]['Weight'] = $Weight;
}
}
$duration = $segments['duration'];
$LAYOVERMinutes = $GroundTime = isset($segments['cT']) ? $segments['cT'] : 0;
$LAYOVERCity = $LAYOVERCityArr[] = isset($segments['cT']) ? $segments['aa']['city'] : '';
$FlyingMinutes += ($duration + $LAYOVERMinutes);
$TotalLAYOVERMinutes += $LAYOVERMinutes;
$FareClass = $totalPriceList['fd']['ADULT']['cB'];
$strBaggage = $totalPriceList['fd']['ADULT']['bI']['iB']; ///Checking Baggage
$strCabinBaggage = $totalPriceList['fd']['ADULT']['bI']['cB']; ////Cabin Baggage
if (!empty($strCabinBaggage)) {
$IsBaggage = true;
} else {
$IsBaggage = false;
}
$AirlineCode = $segments['fD']['aI']['code'];
$AirlineName = $segments['fD']['aI']['name'];
$FlightNumber = $segments['fD']['fN'];
$SegFlightNumber = $AirlineCode . "-" . $FlightNumber;
$originAirportName = $segments['da']['name'];
$originAirportCode = $segments['da']['code'];
$originCityName = $segments['da']['city'];
$originCountryName = $segments['da']['country'];
$originDepTime = $segments['dt'];
$destinationAirportName = $segments['aa']['name'];
$destinationAirportCode = $segments['aa']['code'];
$destinationCityName = $segments['aa']['city'];
$destinationCountryName = $segments['aa']['country'];
$destinationArrTime = $segments['at'];
$DepTerminal = isset($segments['da']['terminal']) ? $segments['da']['terminal'] : '';
$ArrTerminal = isset($segments['aa']['terminal']) ? $segments['aa']['terminal'] : '';
$filePath = $this->getflightlogo($AirlineCode);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($LAYOVERMinutes);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($destinationArrTime);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiStringTJ($originDepTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->convertMinutesToHoursFormat($duration);
$arrSegments[] = array(
"segmentid" => $segments['id'],
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"originCityName" => $originCityName,
"originCountryName" => $originCountryName,
"destinationCityName" => $destinationCityName,
"destinationCountryName" => $destinationCountryName,
"destinationAirportCode" => $destinationAirportCode,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $SegFlightNumber,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FareClass" => $cabinClass,
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"TripIndicator" => '', //$TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"IsBaggage" => $IsBaggage,
"IsMealIncludes" => $IsMealIncludes,
//"SegmentIndicator" => $SegmentIndicator,
"Duration" => $duration,
"GroundTime" => $GroundTime,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"strDepartureDtTime" => $strDepartureDtTime,
"strArrivalDtTime" => $strArrivalDtTime,
"FlightDuration" => $strDuration,
"LAYOVERDuration" => $LAYOVERDuration,
"LAYOVERCity" => $LAYOVERCity,
"DepTerminal" => $DepTerminal,
"ArrTerminal" => $ArrTerminal,
"filePath" => $filePath,
"BAGGAGEARRAY" => $BaggageArrNew,
"MEALARRAY" => $MealArrNew,
"SegmentNumber" => $segments['sN'],
"isReturnSegment" => $segments['isRs'],
);
//echo '<pre>';print_r($arrSegments);
}
}
$LAYOVERTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->MinutesToHours($TotalLAYOVERMinutes);
$AirlineCode = $OriginSegments['fD']['aI']['code'];
$FlightNumber = $OriginSegments['fD']['fN'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strAirlineName = $OriginSegments['fD']['aI']['name'];
$IsLCC = $OriginSegments['fD']['aI']['isLcc'];
$strSourceAirportCode = $OriginSegments['da']['code'];
$strDestinationAirportCode = $DestinationSegments['aa']['code'];
$Stops = $DestinationSegments['sN'];
if ($Stops == 0) {
$StopCountTxt = "Non-stop";
} else {
$StopCountTxt = $Stops . " Stop(s)";
}
$filePath = $this->getflightlogo($AirlineCode);
$FlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->CalculateHoursMinutes($OriginSegments['dt'], $DestinationSegments['at']);
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($DestinationSegments['at']);
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getTimeFromApiString($OriginSegments['dt']);
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$FareRuleData = isset($FareRulesCancel) ? $FareRulesCancel : [];
//$FareRuleData = isset($result['totalPriceList'][0]['fareRuleInformation']) ? $result['totalPriceList'][0]['fareRuleInformation'] : [];
$arrInsertFlightData[$key]['bookingId'] = $bookingId;
$arrInsertFlightData[$key]['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData[$key]['AirlineName'] = $strAirlineName;
$arrInsertFlightData[$key]['AirlineCode'] = $AirlineCode;
$arrInsertFlightData[$key]['AirInvenSysId'] = 0;
$arrInsertFlightData[$key]['IsLCC'] = $IsLCC;
$arrInsertFlightData[$key]['IsMealIncludes'] = $IsMealIncludes;
$arrInsertFlightData[$key]['IsBagIncludes'] = $IsBagIncludes;
$arrInsertFlightData[$key]['IsRefundable'] = $IsRefundable;
$arrInsertFlightData[$key]['IsRefundableTxt'] = $IsRefundableTxt;
$arrInsertFlightData[$key]['SearchTraceId'] = $SearchTraceId;
$arrInsertFlightData[$key]['apiTraceId'] = $strTraceId;
$arrInsertFlightData[$key]['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData[$key]['DepartureTime'] = $strDepartureDtTime;
$arrInsertFlightData[$key]['ArrivalTime'] = $strArrivalDtTime;
$arrInsertFlightData[$key]['TravelDate'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalFromTime'] = str_replace('T', ' ', $OriginSegments['dt']);
$arrInsertFlightData[$key]['FromUTCTime'] = $OriginSegments['dt'];
$arrInsertFlightData[$key]['LocalToTime'] = str_replace('T', ' ', $DestinationSegments['at']);
$arrInsertFlightData[$key]['ToUTCTime'] = $DestinationSegments['at'];
$arrInsertFlightData[$key]['IsDirect'] = 0;
$arrInsertFlightData[$key]['FareClass'] = $strFareClass;
$arrInsertFlightData[$key]['LAYOVERCity'] = isset($LAYOVERCityArr[0]) ? $LAYOVERCityArr[0] : '';
$arrInsertFlightData[$key]['GroundTime'] = $TotalLAYOVERMinutes;
$arrInsertFlightData[$key]['LAYOVERDuration'] = $LAYOVERTime;
$arrInsertFlightData[$key]['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData[$key]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['dt']));
$arrInsertFlightData[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['at']));
$arrInsertFlightData[$key]['FlightDuration'] = $FlightDuration;
$arrInsertFlightData[$key]['SourcePlaceSysId'] = ($strFlightRoute == '3') ? $intSourceCityId[$key] : $intSourceCityId;
$arrInsertFlightData[$key]['DestPlaceSysId'] = ($strFlightRoute == '3') ? $intDestinationCityId[$key] : $intDestinationCityId;
$arrInsertFlightData[$key]['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData[$key]['DestAirportCode'] = $strDestinationAirportCode;
// $arrInsertFlightData[$key]['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData[$key]['StopCount'] = $StopCountTxt;
$arrInsertFlightData[$key]['Stops'] = $Stops;
$arrInsertFlightData[$key]['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData[$key]['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData[$key]['CurrencyType'] = $this->CurrencyId;
$arrInsertFlightData[$key]['PublishedFare'] = $PublishedFare; // As Discussed with GG
$arrInsertFlightData[$key]['PublishedFareTxt'] = number_format($PublishedFare); // As Discussed with GG
// $arrInsertFlightData[$key]['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData[$key]['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData[$key]['JourneyType'] = $intJourneyType;
$arrInsertFlightData[$key]['TripType'] = $intTripType;
$arrInsertFlightData[$key]['IsInternational'] = $interNationalSearch;
$arrInsertFlightData[$key]['logo'] = $filePath;
$arrInsertFlightData[$key]['FairRules'] = $FairRulesArr;
//$arrInsertFlightData[$key]['Fare'] = $FairRulesArr;
$arrInsertFlightData[$key]['Segments'] = $arrSegments;
$arrInsertFlightData[$key]['Baggage'] = $BaggageArr;
$arrInsertFlightData[$key]['Meal'] = $MealArr;
$arrInsertFlightData[$key]['isGSTMandatory'] = $isGSTMandatory;
$arrInsertFlightData[$key]['IsPassMandatory'] = $IsPassMandatory;
$arrInsertFlightData[$key]['IsPassExpiry'] = $IsPassExpiry;
$arrInsertFlightData[$key]['IsPassIssue'] = $IsPassIssue;
$arrInsertFlightData[$key]['IsPassDateOfBirth'] = $IsPassDateOfBirth;
$arrInsertFlightData[$key]['isAdobrMandatory'] = $isAdobrMandatory;
$arrInsertFlightData[$key]['isCdobrMandatory'] = $isCdobrMandatory;
$arrInsertFlightData[$key]['isIdobrMandatory'] = $isIdobrMandatory;
$arrInsertFlightData[$key]['isSeatApplicable'] = $isSeatApplicable;
$arrInsertFlightData[$key]['isSessionTime'] = $isSessionTime . ':00';
$arrInsertFlightData[$key]['IsTJFlightAPI'] = 1;
$arrInsertFlightData[$key]['ICSourceSysId'] = 7;
$arrInsertFlightData[$key]['supplier'] = 'Supplier 1';
$arrInsertFlightData[$key]['strTraceId'] = $strTraceId;
if ($key == 0) {
$arrInsertFlightData[$key]['FareRuleData'] = $FareRuleData;
}
$arrInsertFlightData[$key]['CancelFee'] = ((int) $intMarkUp * $intMemberCount);
$arrInsertFlightData[$key]['arrCommonInsVariables'] = $arrCommonInsVariables;
}
if ($strFlightRoute == 2 && $interNationalSearch == 1) {
$BookingData = $FlightBookingData[0];
$ExtraMarkup = isset($BookingData['FairRules']['ExtraMarkup']) ? $BookingData['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($BookingData['FairRules']['ExtraMarkupOnGST']) ? $BookingData['FairRules']['ExtraMarkupOnGST'] : 0;
$DiscountCoupon = isset($BookingData['FairRules']['DiscountCoupon']) ? $BookingData['FairRules']['DiscountCoupon'] : 0;
$DiscountValue = isset($BookingData['FairRules']['DiscountValue']) ? $BookingData['FairRules']['DiscountValue'] : 0;
$BaseFareT = 0;
$TaxT = 0;
$YQTaxT = 0;
$OtherChargesT = 0;
$DiscountT = 0;
$ServiceFeeT = 0;
$ManagementFeeTaxT = 0;
$AirlineGSTComponentT = 0;
$CarrierMiscFeeT = 0;
$MUFeeT = 0;
$intPublishedFareT = 0;
$PublishedFareT = 0;
$OfferedFareT = 0;
$CommissionEarnedT = 0;
$PLBEarnedT = 0;
$IncentiveEarnedT = 0;
$TdsOnPLBT = 0;
$TdsOnIncentive = 0;
$AdditionalTxnFeeOfrd = 0;
$AdditionalTxnFeePub = 0;
$RefundableT = 0;
$intTotalGSTT = 0;
$apiMarkupT = 0;
$IntCommissionT = 0;
$apiTaxOnMarkupT = 0;
$FixedMarkUpT = 0;
$GSTOnMarkUpT = 0;
$CommEarnedT = 0;
$GSTonCommT = 0;
0;
$intGTXMarkUpT = 0;
$GTXMarkUpGSTT = 0;
$newFareT = 0;
$oldFareT = 0;
$FairRulesArr = [];
$FareBreakdown = [];
$Segments = [];
//echo '<pre>';print_r(($totalPriceListArr));echo '</pre>';
if ($totalPriceListArr) {
foreach ($totalPriceListArr as $kp => $price) {
$fareDetail = $price['fd'];
//echo '<pre>';print_r(($fareDetail));echo '</pre>';
$Refundable = $fareDetail['ADULT']['rT'];
$PriceID = $price['id'];
$fareIdentifier = $price['fareIdentifier'];
if ($fareIdentifier == 'SME') {
$IsGSTRequired = true;
} else {
$IsGSTRequired = false;
}
if ($Refundable == 0) {
$IsRefundableTxt = 'Non Refundable';
} elseif ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Partial Refundable';
}
$fareIdentifier = $price['fareIdentifier'];
$AddMarkup = isset($AdditionalMarkup['finalArr'][$fareIdentifier]) ? $AdditionalMarkup['finalArr'][$fareIdentifier] : [];
$fareremarks = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['remarks']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['remarks'] : '';
$fareIdentifier = isset($AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier']) ? $AdditionalMarkup['finalArr'][$fareIdentifier]['fareIdentifier'] : '';
$colors = !empty($AddMarkup['color']) ? $AddMarkup['color'] : '#000000';
$MarkUpValue = isset($AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue']) ? $AdditionalMarkup['AirlineWiseMarkup'][$AirlineCode]['MarkUpValue'] : 0;
$AddMarkup['markup_b2c'] = ($AddMarkup['markup_b2c'] + $MarkUpValue);
$ADULT = $fareDetail['ADULT']['fC']; //fare Components
$CHILD = isset($fareDetail['CHILD']['fC']) ? $fareDetail['CHILD']['fC'] : []; //fare Components
$INFANT = isset($fareDetail['INFANT']['fC']) ? $fareDetail['INFANT']['fC'] : []; //fare Components
$ADULTafC = $fareDetail['ADULT']['afC']['TAF']; //additional fareComponents
$CHILDafC = isset($fareDetail['CHILD']['afC']['TAF']) ? $fareDetail['CHILD']['afC']['TAF'] : []; //additional fareComponents
$INFANTafC = isset($fareDetail['INFANT']['afC']['TAF']) ? $fareDetail['INFANT']['afC']['TAF'] : []; //additional fareComponents
$ADULTNCMTDS = isset($fareDetail['ADULT']['afC']['NCM']['TDS']) ? $fareDetail['ADULT']['afC']['NCM']['TDS'] : 0; //TDS
$CHILDNCMTDS = isset($fareDetail['CHILD']['afC']['NCM']['TDS']) ? $fareDetail['CHILD']['afC']['NCM']['TDS'] : 0; //TDS
$INFANTNCMTDS = isset($fareDetail['INFANT']['afC']['NCM']['TDS']) ? $fareDetail['INFANT']['afC']['NCM']['TDS'] : 0; //TDS
$ADULTNCMTOT = isset($fareDetail['ADULT']['afC']['NCM']['OT']) ? $fareDetail['ADULT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$CHILDNCMTOT = isset($fareDetail['CHILD']['afC']['NCM']['OT']) ? $fareDetail['CHILD']['afC']['NCM']['OT'] : 0; //- Gross Commission
$INFANTNCMTOT = isset($fareDetail['INFANT']['afC']['NCM']['OT']) ? $fareDetail['INFANT']['afC']['NCM']['OT'] : 0; //- Gross Commission
$AD_MF = isset($ADULTafC['MF']) ? $ADULTafC['MF'] : 0; //Management Fee
$AD_YQ = isset($ADULTafC['YQ']) ? $ADULTafC['YQ'] : 0; //Fuel Surcharge
$AD_AGST = isset($ADULTafC['AGST']) ? $ADULTafC['AGST'] : 0; //Airline GST Component
$AD_MFT = isset($ADULTafC['MFT']) ? $ADULTafC['MFT'] : 0; //Management Fee Tax
$AD_OT = isset($ADULTafC['OT']) ? $ADULTafC['OT'] : 0; //Other Charges
$AD_MU = isset($ADULTafC['MU']) ? $ADULTafC['MU'] : 0; //markup
$AD_YR = isset($ADULTafC['YR']) ? $ADULTafC['YR'] : 0; //Carrier Misc Fee
$CH_MF = isset($CHILDafC['MF']) ? $CHILDafC['MF'] : 0; //Management Fee
$CH_YQ = isset($CHILDafC['YQ']) ? $CHILDafC['YQ'] : 0; //Fuel Surcharge
$CH_AGST = isset($CHILDafC['AGST']) ? $CHILDafC['AGST'] : 0; //Airline GST Component
$CH_MFT = isset($CHILDafC['MFT']) ? $CHILDafC['MFT'] : 0; //Management Fee Tax
$CH_OT = isset($CHILDafC['OT']) ? $CHILDafC['OT'] : 0; //Other Charges
$CH_MU = isset($CHILDafC['MU']) ? $CHILDafC['MU'] : 0; //markup
$CH_YR = isset($CHILDafC['YR']) ? $CHILDafC['YR'] : 0; //Carrier Misc Fee
$IN_MF = isset($INFANTafC['MF']) ? $INFANTafC['MF'] : 0; //Management Fee
$IN_YQ = isset($INFANTafC['YQ']) ? $INFANTafC['YQ'] : 0; //Fuel Surcharge
$IN_AGST = isset($INFANTafC['AGST']) ? $INFANTafC['AGST'] : 0; //Airline GST Component
$IN_MFT = isset($INFANTafC['MFT']) ? $INFANTafC['MFT'] : 0; //Management Fee Tax
$IN_OT = isset($INFANTafC['OT']) ? $INFANTafC['OT'] : 0; //Other Charges
$IN_MU = isset($INFANTafC['MU']) ? $INFANTafC['MU'] : 0; //markup
$IN_YR = isset($INFANTafC['YR']) ? $INFANTafC['YR'] : 0; //Carrier Misc Fee
if ($kp == 0) {
$PublishedFare += (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFare += (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$Tax += (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
}
$PublishedFareIN = (($ADULT['TF'] * $adultCount) + ($CHILD['TF'] * $childCount) + ($INFANT['TF'] * $infantCount)); //Total Fare
$BaseFareIN = (($ADULT['BF'] * $adultCount) + ($CHILD['BF'] * $childCount) + ($INFANT['BF'] * $infantCount)); //Base Fare
$TaxIN = (($ADULT['TAF'] * $adultCount) + ($CHILD['TAF'] * $childCount) + ($INFANT['TAF'] * $infantCount)); //Taxes and Fees
$NetFare = (($ADULT['NF'] * $adultCount) + ($CHILD['NF'] * $childCount) + ($INFANT['NF'] * $infantCount)); //Taxes and Fees
$NetCommission = (($ADULT['NCM'] * $adultCount) + ($CHILD['NCM'] * $childCount) + ($INFANT['NCM'] * $infantCount)); //Taxes and Fees
//echo '<pre>';print_r(($ADULTafC));echo '</pre>';
$YQTax = (($AD_YQ * $adultCount) + ($CH_YQ * $childCount) + ($IN_YQ * $infantCount));
$OtherCharges = (($AD_OT * $adultCount) + ($CH_OT * $childCount) + ($IN_OT * $infantCount));
$ServiceFee = (($AD_MF * $adultCount) + ($CH_MF * $childCount) + ($IN_MF * $infantCount));
$ManagementFeeTax = (($AD_MFT * $adultCount) + ($CH_MFT * $childCount) + ($IN_MFT * $infantCount));
$AirlineGSTComponent = (($AD_AGST * $adultCount) + ($CH_AGST * $childCount) + ($IN_AGST * $infantCount));
$CarrierMiscFee = (($AD_YR * $adultCount) + ($CH_YR * $childCount) + ($IN_YR * $infantCount));
$MUFee = (($AD_MU * $adultCount) + ($CH_MU * $childCount) + ($IN_MU * $infantCount));
$TdsOnPLB = (($ADULTNCMTDS * $adultCount) + ($CHILDNCMTDS * $childCount) + ($INFANTNCMTDS * $infantCount));
//$NetCommission = (($ADULTNCMTOT * $adultCount) + ($CHILDNCMTOT * $childCount) + ($INFANTNCMTOT * $infantCount));
//$PublishedFareIN = $NetFare;
$PublishedFare = $PublishedFareIN;
$CommissionEarned = $NetCommission;
$PLBEarned = 0; //$result['Fare']['PLBEarned'];
$IncentiveEarned = 0; //$result['Fare']['IncentiveEarned'];
$OfferedFare = $PublishedFareIN;
$TdsOnPLBCal = isset($TdsOnPLB) ? str_replace('-', '', $TdsOnPLB) : 0;
$markUpArr = array(
'getMarkup' => $getMarkup,
'PublishedFare' => $PublishedFare,
'OfferedFare' => ($NetFare - $TdsOnPLBCal),
'intCommissionEarned' => $CommissionEarned,
'TdsOnPLB' => $TdsOnPLB,
'MUFee' => $MUFee,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $intMemberCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
//echo '<pre>';print_r(($markUpArr));echo '</pre>';
$arrMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArr, 'Review');
//echo '<pre>';print_r(($arrMarkUps));echo '</pre>';
$TdsOnPLBCal = isset($ADULTNCMTDS) ? str_replace('-', '', $ADULTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($ADULT['TF'] * $adultCount),
'OfferedFare' => (($ADULT['NF'] - $TdsOnPLBCal) * $adultCount),
'intCommissionEarned' => ($ADULT['NCM'] * $adultCount),
'TdsOnPLB' => ($ADULTNCMTDS * $adultCount),
'MUFee' => ($AD_MU * $adultCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $adultCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[0]['Currency'] = 'INR';
$FareBreakdown[0]['PassengerType'] = 1;
$FareBreakdown[0]['PassengerCount'] = $adultCount;
$FareBreakdown[0]['TaxIN'] += ($ADULT['TAF'] * $adultCount);
$FareBreakdown[0]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[0]['BaseFare'] += ($ADULT['BF'] * $adultCount);
$FareBreakdown[0]['CommissionEarned'] += ($ADULT['NCM'] * $adultCount);
$FareBreakdown[0]['TDS'] += ($ADULTNCMTDS * $adultCount);
$FareBreakdown[0]['MF'] += ($AD_MF * $adultCount);
$FareBreakdown[0]['YQ'] += ($AD_YQ * $adultCount);
$FareBreakdown[0]['AGST'] += ($AD_AGST * $adultCount);
$FareBreakdown[0]['MFT'] += ($AD_MFT * $adultCount);
$FareBreakdown[0]['OT'] += ($AD_OT * $adultCount);
$FareBreakdown[0]['MU'] += ($AD_MU * $adultCount);
$FareBreakdown[0]['YR'] += ($AD_YR * $adultCount);
$FareBreakdown[0]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[0]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[0]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
$FareBreakdown[0]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[0]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[0]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[0]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[0]['GSTonComm'] += 0;
$FareBreakdown[0]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[0]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[0]['AdditionalTxnFeeOfrd'] += 0;
$FareBreakdown[0]['AdditionalTxnFeePub'] += 0;
$FareBreakdown[0]['PGCharge'] += 0;
$FareBreakdown[0]['Baggage'] = isset($fareDetail['ADULT']['bI']['iB']) ? $fareDetail['ADULT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[0]['CabinBaggage'] = isset($fareDetail['ADULT']['bI']['cB']) ? $fareDetail['ADULT']['bI']['cB'] : []; //Cabin Baggage ;
if (isset($fareDetail['CHILD'])) {
$TdsOnPLBCal = isset($CHILDNCMTDS) ? str_replace('-', '', $CHILDNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($CHILD['TF'] * $childCount),
'OfferedFare' => (($CHILD['NF'] - $TdsOnPLBCal) * $childCount),
'intCommissionEarned' => ($CHILD['NCM'] * $childCount),
'TdsOnPLB' => ($CHILDNCMTDS * $childCount),
'MUFee' => ($CH_MU * $childCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $childCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[1]['Currency'] = 'INR';
$FareBreakdown[1]['PassengerType'] = 2;
$FareBreakdown[1]['PassengerCount'] = $childCount;
$FareBreakdown[1]['TaxIN'] += ($CHILD['TAF'] * $childCount);
$FareBreakdown[1]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[1]['BaseFare'] += ($CHILD['BF'] * $childCount);
$FareBreakdown[1]['CommissionEarned'] += ($CHILD['NCM'] * $childCount);
$FareBreakdown[1]['TDS'] += ($CHILDNCMTDS * $childCount);
$FareBreakdown[1]['MF'] += ($CH_MF * $childCount);
$FareBreakdown[1]['YQ'] += ($CH_YQ * $childCount);
$FareBreakdown[1]['AGST'] += ($CH_AGST * $childCount);
$FareBreakdown[1]['MFT'] += ($CH_MFT * $childCount);
$FareBreakdown[1]['OT'] += ($CH_OT * $childCount);
$FareBreakdown[1]['MU'] += ($CH_MU * $childCount);
$FareBreakdown[1]['YR'] += ($CH_YR * $childCount);
$FareBreakdown[1]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[1]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[1]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
$FareBreakdown[1]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[1]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[1]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[1]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[1]['GSTonComm'] += 0;
$FareBreakdown[1]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[1]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[1]['AdditionalTxnFeeOfrd'] += 0;
$FareBreakdown[1]['AdditionalTxnFeePub'] += 0;
$FareBreakdown[1]['PGCharge'] = 0;
$FareBreakdown[1]['Baggage'] = isset($fareDetail['CHILD']['bI']['iB']) ? $fareDetail['CHILD']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[1]['CabinBaggage'] = isset($fareDetail['CHILD']['bI']['cB']) ? $fareDetail['CHILD']['bI']['cB'] : []; //Cabin Baggage ;
}
if (isset($fareDetail['INFANT'])) {
$TdsOnPLBCal = isset($INFANTNCMTDS) ? str_replace('-', '', $INFANTNCMTDS) : 0;
$markUpArrBR = array(
'getMarkup' => $getMarkup,
'PublishedFare' => ($INFANT['TF'] * $infantCount),
'OfferedFare' => (($INFANT['NF'] - $TdsOnPLBCal) * $infantCount),
'intCommissionEarned' => ($INFANT['NCM'] * $infantCount),
'TdsOnPLB' => ($INFANTNCMTDS * $infantCount),
'MUFee' => ($IN_MU * $infantCount),
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned,
'intMemberCount' => $infantCount,
'intFlightRoute' => $strFlightRoute,
'interNationalSearch' => $interNationalSearch,
'AddMarkup' => $AddMarkup,
);
$arrMarkUpsBR = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateMarkup($markUpArrBR, 'Review');
$FareBreakdown[2]['Currency'] = 'INR';
$FareBreakdown[2]['PassengerType'] = 3;
$FareBreakdown[2]['PassengerCount'] = $infantCount;
$FareBreakdown[2]['TaxIN'] += ($INFANT['TAF'] * $infantCount);
$FareBreakdown[2]['BaseFareCal'] += ($arrMarkUpsBR['BaseFareCal']);
$FareBreakdown[2]['BaseFare'] += ($INFANT['BF'] * $infantCount);
$FareBreakdown[2]['CommissionEarned'] += ($INFANT['NCM'] * $infantCount);
$FareBreakdown[2]['TDS'] += ($INFANTNCMTDS * $infantCount);
$FareBreakdown[2]['MF'] += ($IN_MF * $infantCount);
$FareBreakdown[2]['YQ'] += ($IN_YQ * $infantCount);
$FareBreakdown[2]['AGST'] += ($IN_AGST * $infantCount);
$FareBreakdown[2]['OT'] += ($IN_OT * $infantCount);
$FareBreakdown[2]['MFT'] += ($IN_MFT * $infantCount);
$FareBreakdown[2]['MU'] += ($IN_MU * $infantCount);
$FareBreakdown[2]['YR'] += ($IN_YR * $infantCount);
$FareBreakdown[2]['intTotalGST'] += $arrMarkUpsBR['intTotalGST'];
$FareBreakdown[2]['apiMarkup'] += $arrMarkUpsBR['apiMarkup'];
$FareBreakdown[2]['IntCommission'] += $arrMarkUpsBR['IntCommission'];
$FareBreakdown[2]['apiTaxOnMarkup'] += $arrMarkUpsBR['apiTaxOnMarkup'];
$FareBreakdown[2]['FixedMarkUp'] += $arrMarkUpsBR['IntAgencyFixMarkUp'];
$FareBreakdown[2]['GSTOnMarkUp'] += $arrMarkUpsBR['IntTaxOnAgencyFixMarkUp'];
$FareBreakdown[2]['CommEarned'] += $arrMarkUpsBR['IntCommission']; //$arrMarkUpsBR['intCommisionEarnedForAgency'];
$FareBreakdown[2]['GSTonComm'] += 0;
$FareBreakdown[2]['intGTXMarkUp'] += $arrMarkUpsBR['intGTXMarkUp'];
$FareBreakdown[2]['GTXMarkUpGST'] += $arrMarkUpsBR['intSTaxOnGTXMarkUp'];
$FareBreakdown[2]['AdditionalTxnFeeOfrd'] += 0;
$FareBreakdown[2]['AdditionalTxnFeePub'] += 0;
$FareBreakdown[2]['PGCharge'] += 0;
$FareBreakdown[2]['Baggage'] = isset($fareDetail['INFANT']['bI']['iB']) ? $fareDetail['INFANT']['bI']['iB'] : []; //Check In Baggage;
$FareBreakdown[2]['CabinBaggage'] = isset($fareDetail['INFANT']['bI']['cB']) ? $fareDetail['INFANT']['bI']['cB'] : []; //Cabin Baggage ;
}
$FareBreakdownar = [];
$FareBreakCount = count($FareBreakdown);
if ($FareBreakdown) {
foreach ($FareBreakdown as $brk => $farebreack) {
$FareBreakdownar[$brk] = $farebreack;
$FareBreakdownar[$brk]['ExtraMarkup'] = ((float) ($ExtraMarkup) / $FareBreakCount);
$FareBreakdownar[$brk]['ExtraMarkupOnGST'] = ((float) ($ExtraMarkupOnGST) / $FareBreakCount);
$FareBreakdownar[$brk]['DiscountCoupon'] = ($DiscountValue > 0) ? 1 : 0;
$FareBreakdownar[$brk]['DiscountValue'] = ((float) ($DiscountValue) / $FareBreakCount);
}
}
$Currency = $this->CurrencyTitle;
$CurrencyRate = $this->CurrencyRate;
$currencySysId = $this->CurrencyId;
$BaseFareT += $BaseFareIN;
$TaxT += $TaxIN;
$YQTaxT += $YQTax;
$OtherChargesT += $OtherCharges;
$DiscountT += 0; //$Discount;
$ServiceFeeT += $ServiceFee;
$ManagementFeeTaxT += $ManagementFeeTax;
$AirlineGSTComponentT += $AirlineGSTComponent;
$CarrierMiscFeeT += $CarrierMiscFee;
$MUFeeT += $MUFee;
$intPublishedFareT += $PublishedFareIN;
$PublishedFareT += ($arrMarkUps['PublishFare'] * $this->CurrencyRate);
$OfferedFareT += $arrMarkUps['intOfferedFare'];
$CommissionEarnedT += $CommissionEarned;
$PLBEarnedT += $PLBEarned;
$IncentiveEarnedT += $IncentiveEarned;
$TdsOnPLBT += $TdsOnPLB;
$TdsOnIncentiveT += 0;
$AdditionalTxnFeeOfrd += 0;
$AdditionalTxnFeePub += 0;
$RefundableT += $Refundable;
$IsRefundableTxtT = $IsRefundableTxt;
$PriceID = $PriceID;
$IsGSTRequired = $IsGSTRequired;
$fareIdentifier = str_replace('_', ' ', $fareIdentifier);
$FareClass = $fareDetail['ADULT']['cc'];
$intTotalGSTT += $arrMarkUps['intTotalGST'];
$apiMarkupT += $arrMarkUps['apiMarkup'];
$IntCommissionT += $arrMarkUps['IntCommission'];
$apiTaxOnMarkupT += $arrMarkUps['apiTaxOnMarkup'];
$FixedMarkUpT += $arrMarkUps['IntAgencyFixMarkUp'];
$GSTOnMarkUpT += $arrMarkUps['IntTaxOnAgencyFixMarkUp'];
$CommEarnedT += $arrMarkUps['IntCommission']; //$arrMarkUps['intCommisionEarnedForAgency'];
$GSTonCommT += 0;
$intGTXMarkUpT += $arrMarkUps['intGTXMarkUp'];
$GTXMarkUpGSTT += $arrMarkUps['intSTaxOnGTXMarkUp'];
$newFareT += $newFare;
$oldFareT += $oldFare;
$seg = $arrInsertFlightData[$kp]['Segments'];
//
$Segments[] = $seg;
}
}
$FairRulesArr = array(
"Currency" => $this->CurrencyTitle, //$Currency,
"CurrencyRate" => $this->CurrencyRate, //$Currency,
"currencySysId" => $this->CurrencyId,
"BaseFare" => $BaseFareT,
"Tax" => $TaxT,
"YQTax" => $YQTaxT,
"OtherCharges" => $OtherChargesT,
"Discount" => 0,
"ServiceFee" => $ServiceFeeT,
"ManagementFeeTax" => $ManagementFeeTaxT,
"AirlineGSTComponent" => $AirlineGSTComponentT,
"CarrierMiscFee" => $CarrierMiscFeeT,
"MUFee" => $MUFeeT,
"intPublishedFare" => $intPublishedFareT,
"PublishedFare" => ($PublishedFareT),
"OfferedFare" => $OfferedFareT,
"CommissionEarned" => $CommissionEarnedT,
"PLBEarned" => $PLBEarnedT,
"IncentiveEarned" => $IncentiveEarnedT,
"TdsOnPLB" => $TdsOnPLBT,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxtT,
"PriceID" => $PriceID,
"IsGSTRequired" => $IsGSTRequired,
"fareIdentifier" => $fareIdentifier,
"FareClass" => $FareClass,
"intTotalGST" => $intTotalGSTT,
"apiMarkup" => $apiMarkupT,
"IntCommission" => $IntCommissionT,
"apiTaxOnMarkup" => $apiTaxOnMarkupT,
"FixedMarkUp" => $FixedMarkUpT,
"GSTOnMarkUp" => $GSTOnMarkUpT,
"CommEarned" => $CommEarnedT,
"GSTonComm" => 0,
"intGTXMarkUp" => $intGTXMarkUpT,
"GTXMarkUpGST" => $GTXMarkUpGSTT,
"newFare" => $newFareT,
"oldFare" => $oldFareT,
"ExtraMarkup" => $ExtraMarkup,
"ExtraMarkupOnGST" => $ExtraMarkupOnGST,
"DiscountCoupon" => $DiscountCoupon,
"DiscountCoupon" => $DiscountValue,
"FareBreakdown" => $FareBreakdownar,
);
//echo '<pre>';print_r(($FairRulesArr));echo '</pre>';
$arrInsertFlightDataInt['bookingId'] = $arrInsertFlightData[0]['bookingId'];
$arrInsertFlightDataInt['FlightNumber'] = $arrInsertFlightData[0]['FlightNumber'];
$arrInsertFlightDataInt['AirlineName'] = $arrInsertFlightData[0]['AirlineName'];
$arrInsertFlightDataInt['AirlineCode'] = $arrInsertFlightData[0]['AirlineCode'];
$arrInsertFlightDataInt['AirInvenSysId'] = $arrInsertFlightData[0]['AirInvenSysId'];
$arrInsertFlightDataInt['IsLCC'] = $arrInsertFlightData[0]['IsLCC'];
$arrInsertFlightDataInt['IsMealIncludes'] = $arrInsertFlightData[0]['IsMealIncludes'];
$arrInsertFlightDataInt['IsBagIncludes'] = $arrInsertFlightData[0]['IsBagIncludes'];
$arrInsertFlightDataInt['IsRefundable'] = $arrInsertFlightData[0]['IsRefundable'];
$arrInsertFlightDataInt['IsRefundableTxt'] = $arrInsertFlightData[0]['IsRefundableTxt'];
$arrInsertFlightDataInt['SearchTraceId'] = $arrInsertFlightData[0]['SearchTraceId'];
$arrInsertFlightDataInt['apiTraceId'] = $arrInsertFlightData[0]['apiTraceId'];
$arrInsertFlightDataInt['AirlineSysId'] = $arrInsertFlightData[0]['AirlineSysId'];
$arrInsertFlightDataInt['DepartureTime'] = $arrInsertFlightData[0]['DepartureTime'];
$arrInsertFlightDataInt['ArrivalTime'] = $arrInsertFlightData[0]['ArrivalTime'];
$arrInsertFlightDataInt['TravelDate'] = $arrInsertFlightData[0]['TravelDate'];
$arrInsertFlightDataInt['LocalFromTime'] = $arrInsertFlightData[0]['LocalFromTime'];
$arrInsertFlightDataInt['FromUTCTime'] = $arrInsertFlightData[0]['FromUTCTime'];
$arrInsertFlightDataInt['LocalToTime'] = $arrInsertFlightData[0]['LocalToTime'];
$arrInsertFlightDataInt['ToUTCTime'] = $arrInsertFlightData[0]['ToUTCTime'];
$arrInsertFlightDataInt['IsDirect'] = $arrInsertFlightData[0]['IsDirect'];
$arrInsertFlightDataInt['FareClass'] = $arrInsertFlightData[0]['FareClass'];
$arrInsertFlightDataInt['LAYOVERCity'] = $arrInsertFlightData[0]['LAYOVERCity'];
$arrInsertFlightDataInt['GroundTime'] = $arrInsertFlightData[0]['GroundTime'];
$arrInsertFlightDataInt['LAYOVERDuration'] = $arrInsertFlightData[0]['LAYOVERDuration'];
$arrInsertFlightDataInt['FlyingMinutes'] = $arrInsertFlightData[0]['FlyingMinutes'];
$arrInsertFlightDataInt['DepartureDateTxt'] = $arrInsertFlightData[0]['DepartureDateTxt'];
$arrInsertFlightDataInt['ArrivalDateTxt'] = $arrInsertFlightData[0]['ArrivalDateTxt'];
$arrInsertFlightDataInt['FlightDuration'] = $arrInsertFlightData[0]['FlightDuration'];
$arrInsertFlightDataInt['SourcePlaceSysId'] = $arrInsertFlightData[0]['SourcePlaceSysId'];
$arrInsertFlightDataInt['DestPlaceSysId'] = $arrInsertFlightData[0]['DestPlaceSysId'];
$arrInsertFlightDataInt['SourceAirportCode'] = $arrInsertFlightData[0]['SourceAirportCode'];
$arrInsertFlightDataInt['DestAirportCode'] = $arrInsertFlightData[0]['DestAirportCode'];
$arrInsertFlightDataInt['StopCount'] = $arrInsertFlightData[0]['StopCount'];
$arrInsertFlightDataInt['Stops'] = $arrInsertFlightData[0]['Stops'];
$arrInsertFlightDataInt['NoOfSeatAvailable'] = $arrInsertFlightData[0]['NoOfSeatAvailable'];
$arrInsertFlightDataInt['TotalFlightMembers'] = $arrInsertFlightData[0]['TotalFlightMembers'];
$arrInsertFlightDataInt['CurrencyType'] = $arrInsertFlightData[0]['CurrencyType'];
$arrInsertFlightDataInt['PublishedFare'] = $arrInsertFlightData[0]['PublishedFare'];
$arrInsertFlightDataInt['PublishedFareTxt'] = $arrInsertFlightData[0]['PublishedFareTxt'];
$arrInsertFlightDataInt['ApiResultIndex'] = $arrInsertFlightData[0]['ApiResultIndex'];
$arrInsertFlightDataInt['JourneyType'] = $arrInsertFlightData[0]['JourneyType'];
$arrInsertFlightDataInt['TripType'] = $arrInsertFlightData[0]['TripType'];
$arrInsertFlightDataInt['IsInternational'] = $arrInsertFlightData[0]['IsInternational'];
$arrInsertFlightDataInt['logo'] = $arrInsertFlightData[0]['logo'];
//$arrInsertFlightDataInt['FairRules'] = $arrInsertFlightData[0]['FairRules'];
$arrInsertFlightDataInt['Baggage'] = $arrInsertFlightData[0]['Baggage'];
$arrInsertFlightDataInt['Meal'] = $arrInsertFlightData[0]['Meal'];
$arrInsertFlightDataInt['isGSTMandatory'] = $arrInsertFlightData[0]['isGSTMandatory'];
$arrInsertFlightDataInt['IsPassMandatory'] = $arrInsertFlightData[0]['IsPassMandatory'];
$arrInsertFlightDataInt['IsPassExpiry'] = $arrInsertFlightData[0]['IsPassExpiry'];
$arrInsertFlightDataInt['IsPassIssue'] = $arrInsertFlightData[0]['IsPassIssue'];
$arrInsertFlightDataInt['IsPassDateOfBirth'] = $arrInsertFlightData[0]['IsPassDateOfBirth'];
$arrInsertFlightDataInt['isAdobrMandatory'] = $arrInsertFlightData[0]['isAdobrMandatory'];
$arrInsertFlightDataInt['isCdobrMandatory'] = $arrInsertFlightData[0]['isCdobrMandatory'];
$arrInsertFlightDataInt['isIdobrMandatory'] = $arrInsertFlightData[0]['isIdobrMandatory'];
$arrInsertFlightDataInt['isSeatApplicable'] = $arrInsertFlightData[0]['isSeatApplicable'];
$arrInsertFlightDataInt['isSessionTime'] = $arrInsertFlightData[0]['isSessionTime'];
$arrInsertFlightDataInt['strTraceId'] = $arrInsertFlightData[0]['strTraceId'];
$arrInsertFlightDataInt['FareRuleData'] = $arrInsertFlightData[0]['FareRuleData'];
$arrInsertFlightDataInt['CancelFee'] = $arrInsertFlightData[0]['CancelFee'];
$arrInsertFlightDataInt['FairRules'] = $FairRulesArr;
$arrInsertFlightDataInt['Segments'] = $Segments;
$arrCommonInsVariables = array(
'strTraceId' => $arrInsertFlightData[0]['apiTraceId'],
'localFromDateTime' => $arrInsertFlightData[0]['LocalFromTime'],
'localToDateTime' => $arrInsertFlightData[0]['LocalToTime'],
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => 1,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$arrInsertFlightDataInt[0]['arrCommonInsVariables'] = $arrCommonInsVariables;
$arrInsertFlightData[0]['InternationalData'] = $arrInsertFlightDataInt;
}
}
// echo '<pre>';print_r($arrInsertFlightData);echo '</pre>';die;
// $FlightBookingData = new Zend_Session_Namespace('FlightBookingData');
// $FlightBookingData->params = $arrInsertFlightData;
return $arrInsertFlightData;
}
public function loadAddOnsAction() {
$getData = $this->getRequest()->getParams();
// echo '<pre>';
// print_r($getData);
// die('d');
$CustomerSession = new Zend_Session_Namespace('CustomerSession');
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$flightSSRDetails = json_decode($getData['SSRArr'], true);
$TotalTravellers = json_decode($getData['TotalTravellers'], true);
$Response = $flightSSRDetails;
$SSRArr = $Response;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('CustomerSession' => $TotalTravellers, 'SSRArr' => $SSRArr, 'SSRArrInb' => [], 'flightSSRDetails' => $flightSSRDetails, 'FlightBookingData' => $FlightBookingData, 'FlightBookingDataInbound' => []));
$bodyText = $html->render('load-add-ons.phtml');
$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
echo json_encode($response);
exit;
//print_r($getData);
}
public function getseatpageAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
// echo '<pre>';
// print_r($getData);
// die('d');
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('FlightBookingData' => $FlightBookingData, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getseatpage.phtml');
$response = array('success' => true, 'message' => 'Done', 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found!');
}
//echo '<pre>';print_r($getData);die;
}
public function seatmapAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
$segmentid = $getData['segmentid'];
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$CustomerSession = json_decode($getData['TotalTravellers'], true);
$selectedSeatSession = json_decode($getData['selectedSeatSession'], true);
$tripSeatMap = json_decode($getData['tripSeatMap'], true);
// echo '<pre>';
// print_r($tripSeatMap);
// echo '</pre>';die;
$bookingId = $FlightBookingData[0]['bookingId'];
$IsTJFlightAPI = isset($FlightBookingData[0]['IsTJFlightAPI']) ? $FlightBookingData[0]['IsTJFlightAPI'] : 0;
$data = ['bookingId' => $bookingId];
if ($IsTJFlightAPI == 1) {
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSeatMapFlightsTripJack($data, $this->intLoggedinAgencyId);
} else {
$apiResponse = $tripSeatMap;
}
$SegmentsArr = [];
if ($FlightBookingData) {
foreach ($FlightBookingData as $Datass) {
if ($Datass['Segments']) {
foreach ($Datass['Segments'] as $keys => $value) {
$SegmentsArr[$value['segmentid']] = $value;
}
}
}
}
// echo '<pre>';
// print_r($apiResponse);
// echo '</pre>';die;
$this->view->apiResponse = $apiResponse;
$this->view->segmentid = $segmentid;
$this->view->SegmentsArr = $SegmentsArr;
$this->view->baseUrl = $this->baseUrl;
$this->view->CustomerSession = $CustomerSession;
$this->view->selectedSeatSession = $selectedSeatSession;
$this->view->CurrencyTitle = $this->CurrencyTitle;
} else {
die('Page not found!');
}
}
public function updatefareAction() {
if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
$getData = $this->getRequest()->getParams();
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$CustomerSession = json_decode($getData['TotalTravellers'], true);
$SSRArr = json_decode($getData['SSRArr'], true);
$SelectedMeal = json_decode($getData['SelectedMeal'], true);
$SelectedBagg = json_decode($getData['SelectedBagg'], true);
$selectedSeatSession = json_decode($getData['SelectedSeat'], true);
if (!empty($SelectedMeal)) {
$SelectedMealSessionNew = $SelectedMeal;
} else {
$SelectedMealSessionNew = [];
}
if (!empty($SelectedBagg)) {
$SelectedBaggSessionNew = $SelectedBagg;
} else {
$SelectedBaggSessionNew = [];
}
$this->CurrencyRate = $FlightBookingData[0]['FairRules']['CurrencyRate'];
$this->CurrencyTitle = $FlightBookingData[0]['FairRules']['Currency'];
$this->CurrencyId = $FlightBookingData[0]['FairRules']['currencySysId'];
// echo '<pre>';
// print_r($SSRArr['Meal']);die;
$BaggageArr = [];
$MealArr = [];
if ($SSRArr['Baggage']) {
foreach ($SSRArr['Baggage'] as $Datass) {
if ($Datass) {
foreach ($Datass as $keys => $value) {
$BaggageArr[$value['key']][] = $value;
}
}
}
}
if ($SSRArr['Meal']) {
foreach ($SSRArr['Meal'] as $Datass) {
if ($Datass) {
foreach ($Datass as $keys => $value) {
$MealArr[$value['key']][] = $value;
}
}
}
}
$CustomerSysId = $getData['CustomerSysId'];
$segmentid = $getData['segmentid'];
$index = $getData['index'];
if ($getData['actiontype'] == 'meal') {
$getData['data'] = $MealArr[$segmentid][$index];
if (!empty($SelectedMealSessionNew[$segmentid])) {
foreach ($SelectedMealSessionNew[$segmentid] as $CustomerId => $val) {
if ($CustomerId == $CustomerSysId) {
$SelectedMealSessionNew[$segmentid][$CustomerId] = $getData['data'];
} else {
$NewArray = true;
$SelectedMealSessionNew[$segmentid][$CustomerId] = $val;
}
}
} else {
$SelectedMealSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
}
if ($NewArray) {
$SelectedMealSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
}
} else {
$getData['data'] = $BaggageArr[$segmentid][$index];
if (!empty($SelectedBaggSessionNew[$segmentid])) {
foreach ($SelectedBaggSessionNew[$segmentid] as $CustomerId => $val) {
if ($CustomerId == $CustomerSysId) {
$SelectedBaggSessionNew[$segmentid][$CustomerId] = $getData['data'];
} else {
$NewArray = true;
$SelectedBaggSessionNew[$segmentid][$CustomerId] = $val;
}
}
} else {
$SelectedBaggSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
}
if ($NewArray) {
$SelectedBaggSessionNew[$segmentid][$CustomerSysId] = $getData['data'];
}
}
// if ($index == '' && $getData['actiontype'] == 'meal') {
// unset($SelectedMealSessionNew[$segmentid][$CustomerSysId]);
// }
// if ($index == '' && $getData['actiontype'] == 'baggage') {
// unset($SelectedBaggSessionNew[$segmentid][$CustomerSysId]);
// }
// echo '<pre>';
// print_r($SelectedMealSessionNew);
// print_r($SelectedBaggSessionNew);
// echo '</pre>';
$BaggFare = 0;
$MealFare = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BaggFare += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealFare += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$ExtraMarkup = 0;
$intExtraMarkup = 0;
$ExtraMarkupOnGST = 0;
$intNetPublishedFare = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $value) {
$intNetPublishedFare += $value['FairRules']['PublishedFare'];
$ExtraMarkup += $value['FairRules']['ExtraMarkup'];
$ExtraMarkupOnGST += $value['FairRules']['ExtraMarkupOnGST'];
}
}
$MarkupArr['showintax'] = 0;
$MarkupArr['intExtraMarkup'] = ($ExtraMarkup + $ExtraMarkupOnGST);
$MarkupArr['ExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$apiResponse = ($FlightBookingData);
$Data = $apiResponse;
$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBookingData, 'MarkupArr' => $MarkupArr, 'actiontype' => $getData['actiontype'], 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'MobilePublishedFare' => $this->CurrencyTitle . ' ' . $MobilePublishedFare, 'SelectedMealSessionNew' => json_encode($SelectedMealSessionNew), 'SelectedBaggSessionNew' => json_encode($SelectedBaggSessionNew), 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found');
}
}
public function continuewithseatmapAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
//echo '<pre>';print_r($getData);die;
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$CustomerSession = json_decode($getData['TotalTravellers'], true);
$SelectedMeal = json_decode($getData['SelectedMeal'], true);
$SelectedBagg = json_decode($getData['SelectedBagg'], true);
$apiResponseSeat = json_decode($getData['apiResponseSeat'], true);
$SelectedSeat = json_decode($getData['SelectedSeat'], true);
//Zend_Session::namespaceUnset('selectedSeatSession');die;
$segmentid = $getData['segmentid'];
$seatArray = $getData['seatArray'];
$paxTypeArr = $getData['paxTypeArr'];
$CustomerSysIdArray = $getData['CustomerSysIdArray'];
$SelectedMealSessionNew = $SelectedMeal;
$SelectedBaggSessionNew = $SelectedBagg;
if (!empty($SelectedSeat)) {
$selectedSeatSession = $SelectedSeat;
} else {
$selectedSeatSession = [];
}
$bookingId = $FlightBookingData[0]['bookingId'];
$data = ['bookingId' => $bookingId];
$tripSeat = $apiResponseSeat['tripSeatMap']['tripSeat'];
$value = $tripSeat[$segmentid];
$sInfo = $value['sInfo'];
$items = [];
foreach ($sInfo as $k => $val) {
$items[$val['seatNo']] = array(
'seatNo' => $val['seatNo'],
'amount' => $val['amount'],
'isBooked' => $val['isBooked'],
'isLegroom' => isset($val['isLegroom']) ? $val['isLegroom'] : 0,
'code' => $val['code'],
'isAisle' => isset($val['isAisle']) ? $val['isAisle'] : 0,
);
}
$selectedSeat = [];
$SelectedSegment = [];
if ($CustomerSysIdArray) {
foreach ($CustomerSysIdArray as $keys => $CustomerSysId) {
$seatNo = $seatArray[$keys];
$paxType = $paxTypeArr[$keys];
$checkSeat = str_replace(' ', '', $seatNo);
if (trim($checkSeat) != 'NA' && !empty($checkSeat)) {
$SelectedSegment[] = $paxType . ': ' . $seatNo;
} else {
$SelectedSegment[] = '';
}
//$SelectedSegment[] = $paxType . ':' . $seatNo;
foreach ($sInfo as $k => $val) {
if ($val['seatNo'] == $seatNo) {
$selectedSeat[$segmentid][$CustomerSysId] = $val;
}
}
}
}
if (count(array_filter($SelectedSegment)) == count($SelectedSegment)) {
$SelectedSegmentst = implode(', ', $SelectedSegment);
} else {
$SelectedSegmentst = '----';
}
//echo '<pre>';print_r(implode(', ',$SelectedSegment));
if (!empty($selectedSeatSession)) {
foreach ($selectedSeatSession as $segid => $value) {
$index = 0;
if ($segid == $segmentid) {
foreach ($value as $CustomerId => $val) {
$seatNo = $seatArray[$index];
$itemsdata = $items[$seatNo];
if (trim($val['seatNo']) == trim($seatNo)) {
$selectedSeatSession[$segmentid][$CustomerId] = $val;
} else {
$selectedSeatSession[$segmentid][$CustomerId] = $itemsdata;
}
$index++;
}
} else {
if ($CustomerSysIdArray) {
foreach ($CustomerSysIdArray as $keys => $CustomerSysId) {
$seatNo = $seatArray[$keys];
foreach ($sInfo as $k => $val) {
if ($val['seatNo'] == $seatNo) {
$selectedSeatSession[$segmentid][$CustomerSysId] = $val;
}
}
}
}
}
}
} else {
$selectedSeatSession = $selectedSeat;
}
//echo '<pre>';print_r($selectedSeatSession);die;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$intNetPublishedFare = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $value) {
$intNetPublishedFare += $value['FairRules']['PublishedFare'];
}
}
//echo '<pre>';print_r($SelectedMealSessionNewInb);
//echo '<pre>';print_r($SelectedBaggSessionNewInb);
$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBookingData, 'CurrencyTitle' => $this->CurrencyTitle, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'SelectedSegment' => $SelectedSegmentst, 'selectedSeatSession' => json_encode($selectedSeatSession), 'MobilePublishedFare' => $this->CurrencyTitle . ' ' . $MobilePublishedFare, 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found!');
}
}
public function addextramarkupAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$CustomerSession = json_decode($getData['TotalTravellers'], true);
$SelectedMeal = json_decode($getData['SelectedMeal'], true);
$SelectedBagg = json_decode($getData['SelectedBagg'], true);
$apiResponseSeat = json_decode($getData['apiResponseSeat'], true);
$SelectedSeat = json_decode($getData['SelectedSeat'], true);
$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);
//Zend_Session::namespaceUnset('selectedSeatSession');die;
$showintax = isset($getData['showintax']) ? $getData['showintax'] : 0;
$ExtraMarkup = isset($getData['ExtraMarkup']) ? $getData['ExtraMarkup'] : 0;
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SelectedMealSessionNew = $SelectedMeal;
$SelectedBaggSessionNew = $SelectedBagg;
$selectedSeatSession = $SelectedSeat;
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($ExtraMarkup, "F", 0);
$Reverse = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateReverse($ExtraMarkup, !empty($arrServiceTaxOnNetPayable['ServiceTaxPercentage']) ? $arrServiceTaxOnNetPayable['ServiceTaxPercentage'] : 0);
// echo '<pre>';print_r($ExtraMarkup);
// die;
$MarkupArrayServiceTax = $Reverse['TaxAmount']; //!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$MarkupArr['showintax'] = $showintax;
$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkup'] = $Reverse['NetPrice'];
$MarkupArr['ExtraMarkupOnGST'] = $Reverse['TaxAmount'];
$ExtraMarkup = $Reverse['NetPrice'];
$FlightBookingArr = [];
if ($FlightBookingData) {
$IntExtraMarkup = ($ExtraMarkup / $strFlightRoute);
$IntExtraMarkupOnGST = ($MarkupArrayServiceTax / $strFlightRoute);
foreach ($FlightBookingData as $key => $outb) {
$FlightBookingArr[$key] = $outb;
$FlightBookingArr[$key]['FairRules']['showintax'] = ($showintax);
$FlightBookingArr[$key]['FairRules']['ExtraMarkup'] = ($IntExtraMarkup);
$FlightBookingArr[$key]['FairRules']['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST);
//$FlightBookingArr[$key]['FairRules']['FixedMarkUp'] = ($outb['FairRules']['FixedMarkUp'] + $IntExtraMarkup);
//$FlightBookingArr[$key]['FairRules']['GSTOnMarkUp'] = ($outb['FairRules']['GSTOnMarkUp'] + $IntExtraMarkupOnGST);
$FareBreakdown = [];
$FareBreakCount = count($outb['FairRules']['FareBreakdown']);
if ($outb['FairRules']['FareBreakdown']) {
foreach ($outb['FairRules']['FareBreakdown'] as $k => $FareBreak) {
$FareBreakdown[$k] = $FareBreak;
$FareBreakdown[$k]['showintax'] = $showintax;
$FareBreakdown[$k]['ExtraMarkup'] = ($IntExtraMarkup / $FareBreakCount);
$FareBreakdown[$k]['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST / $FareBreakCount);
//$FareBreakdown[$k]['FixedMarkUp'] = ($FareBreak['FixedMarkUp'] + ($IntExtraMarkup / $FareBreakCount));
//$FareBreakdown[$k]['GSTOnMarkUp'] = ($FareBreak['GSTOnMarkUp'] + ($IntExtraMarkupOnGST / $FareBreakCount));
}
}
$FlightBookingArr[$key]['FairRules']['FareBreakdown'] = $FareBreakdown;
//$FairRulesarr[$kk]['ExtraMarkup'] = ($addMarkup);
//$FairRulesarr[$kk]['ExtraMarkupOnGST'] = ($MarkupArrayServiceTax);
}
}
// echo '<pre>';print_r($MarkupArr);
// echo '<pre>';print_r($FlightBookingArr);
// echo '<pre>';print_r($FlightBookingData);
// die;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$intNetPublishedFare = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $value) {
$intNetPublishedFare += $value['FairRules']['PublishedFare'];
}
}
//echo '<pre>';print_r($SelectedMealSessionNewInb);
//echo '<pre>';print_r($SelectedBaggSessionNewInb);
$MobilePublishedFare = ($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice + $ExtraMarkup + $MarkupArrayServiceTax);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBookingArr, 'MarkupArr' => $MarkupArr, 'CurrencyTitle' => $this->CurrencyTitle, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'FlightBookingArr' => json_encode($FlightBookingArr), 'MarkupArr' => json_encode($MarkupArr), 'selectedSeatSession' => json_encode($selectedSeatSession), 'MobilePublishedFare' => $MobilePublishedFare, 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found!');
}
}
public function adddiscountAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$getData = $this->getRequest()->getParams();
$FlightBookingData = json_decode($getData['intOutBoundId'], true);
$CustomerSession = json_decode($getData['TotalTravellers'], true);
$SelectedMeal = json_decode($getData['SelectedMeal'], true);
$SelectedBagg = json_decode($getData['SelectedBagg'], true);
$apiResponseSeat = json_decode($getData['apiResponseSeat'], true);
$SelectedSeat = json_decode($getData['SelectedSeat'], true);
$sessionFlightSearchParams = json_decode($getData['sessionFlightSearchParams'], true);
$showintax = isset($getData['showintax']) ? $getData['showintax'] : 0;
$ExtraMarkup = isset($getData['ExtraMarkup']) ? $getData['ExtraMarkup'] : 0;
$DiscountValue = isset($getData['DiscountValue']) ? $getData['DiscountValue'] : 0;
$DiscountCoupon = isset($getData['DiscountCoupon']) ? $getData['DiscountCoupon'] : 0;
$strFlightRoute = trim($sessionFlightSearchParams['route']);
$SelectedMealSessionNew = $SelectedMeal;
$SelectedBaggSessionNew = $SelectedBagg;
$selectedSeatSession = $SelectedSeat;
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($ExtraMarkup, "F", 0);
$Reverse = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->calculateReverse($ExtraMarkup, !empty($arrServiceTaxOnNetPayable['ServiceTaxPercentage']) ? $arrServiceTaxOnNetPayable['ServiceTaxPercentage'] : 0);
// echo '<pre>';print_r($getData);
// die;
$MarkupArrayServiceTax = $Reverse['TaxAmount']; //!empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$MarkupArr['showintax'] = $showintax;
$MarkupArr['intExtraMarkup'] = $ExtraMarkup;
$MarkupArr['ExtraMarkup'] = $Reverse['NetPrice'];
$MarkupArr['ExtraMarkupOnGST'] = $Reverse['TaxAmount'];
$MarkupArr['DiscountCoupon'] = $DiscountCoupon;
$MarkupArr['DiscountValue'] = $DiscountValue;
$ExtraMarkup = $Reverse['NetPrice'];
$FlightBookingArr = [];
if ($FlightBookingData) {
$IntExtraMarkup = ($ExtraMarkup / $strFlightRoute);
$IntExtraMarkupOnGST = ($MarkupArrayServiceTax / $strFlightRoute);
$DiscountValue = ($DiscountValue / $strFlightRoute);
foreach ($FlightBookingData as $key => $outb) {
$FlightBookingArr[$key] = $outb;
$FlightBookingArr[$key]['FairRules']['showintax'] = ($showintax);
$FlightBookingArr[$key]['FairRules']['ExtraMarkup'] = ($IntExtraMarkup);
$FlightBookingArr[$key]['FairRules']['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST);
$FlightBookingArr[$key]['FairRules']['DiscountValue'] = ($DiscountValue);
$FlightBookingArr[$key]['FairRules']['DiscountCoupon'] = ($DiscountCoupon);
//$FlightBookingArr[$key]['FairRules']['FixedMarkUp'] = ($outb['FairRules']['FixedMarkUp'] + $IntExtraMarkup);
//$FlightBookingArr[$key]['FairRules']['GSTOnMarkUp'] = ($outb['FairRules']['GSTOnMarkUp'] + $IntExtraMarkupOnGST);
$FareBreakdown = [];
$FareBreakCount = count($outb['FairRules']['FareBreakdown']);
if ($outb['FairRules']['FareBreakdown']) {
foreach ($outb['FairRules']['FareBreakdown'] as $k => $FareBreak) {
$FareBreakdown[$k] = $FareBreak;
$FareBreakdown[$k]['showintax'] = $showintax;
$FareBreakdown[$k]['DiscountCoupon'] = $DiscountCoupon;
$FareBreakdown[$k]['ExtraMarkup'] = ($IntExtraMarkup / $FareBreakCount);
$FareBreakdown[$k]['ExtraMarkupOnGST'] = ($IntExtraMarkupOnGST / $FareBreakCount);
$FareBreakdown[$k]['DiscountValue'] = ($DiscountValue / $FareBreakCount);
//$FareBreakdown[$k]['FixedMarkUp'] = ($FareBreak['FixedMarkUp'] + ($IntExtraMarkup / $FareBreakCount));
//$FareBreakdown[$k]['GSTOnMarkUp'] = ($FareBreak['GSTOnMarkUp'] + ($IntExtraMarkupOnGST / $FareBreakCount));
}
}
$FlightBookingArr[$key]['FairRules']['FareBreakdown'] = $FareBreakdown;
//$FairRulesarr[$kk]['ExtraMarkup'] = ($addMarkup);
//$FairRulesarr[$kk]['ExtraMarkupOnGST'] = ($MarkupArrayServiceTax);
}
}
// echo '<pre>';print_r($MarkupArr);
// echo '<pre>';print_r($FlightBookingArr);
// echo '<pre>';print_r($FlightBookingData);
// die;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$intNetPublishedFare = 0;
if ($FlightBookingData) {
foreach ($FlightBookingData as $value) {
$intNetPublishedFare += $value['FairRules']['PublishedFare'];
}
}
//echo '<pre>';print_r($SelectedMealSessionNewInb);
//echo '<pre>';print_r($SelectedBaggSessionNewInb);
$MobilePublishedFare = (($intNetPublishedFare + $MealFare + $BaggFare + $SeatPrice + $ExtraMarkup + $MarkupArrayServiceTax) - $DiscountValue);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('Data' => $FlightBookingArr, 'MarkupArr' => $MarkupArr, 'CurrencyTitle' => $this->CurrencyTitle, 'selectedSeatSession' => $selectedSeatSession, 'SelectedMealSessionNew' => $SelectedMealSessionNew, 'SelectedBaggSessionNew' => $SelectedBaggSessionNew, 'CurrencyRate' => $this->CurrencyRate));
$bodyText = $html->render('getflightfarequote.phtml');
$response = array('success' => true, 'message' => 'Done', 'FlightBookingArr' => json_encode($FlightBookingArr), 'MarkupArr' => json_encode($MarkupArr), 'selectedSeatSession' => json_encode($selectedSeatSession), 'MobilePublishedFare' => $MobilePublishedFare, 'html' => $bodyText);
echo json_encode($response);
exit;
} else {
die('Page not found!');
}
}
public function getCancelCharge($intCountryCode) {
if ($intCountryCode) {
$getMarkup = $this->getMarkup($intCountryCode);
$intMarkUp = 0;
if ($getMarkup['status'] == 1) {
if ($getMarkup['arrAgencyMarkupsCancellation']) {
foreach ($getMarkup['arrAgencyMarkupsCancellation'] as $value) {
//echo '<pre>';print_r($value);echo '</pre>';
if ($value['SupplierType'] == 2 && $value['ServiceType'] == 1 && $value['MPType'] == 1) {
$intGTXMarkUpType = $value['MarkUpType'];
$MarkUp = $value['MarkUp'];
$intGTXMarkUpType = $value['MarkUpType'];
if ($intGTXMarkUpType == 1) { // For Flat
$intMarkUp += $MarkUp;
} else { // For Percentage
$intMarkUp += $MarkUp; //($intOfferedFare * $MarkUp) / 100;
}
}
}
}
}
return $intMarkUp;
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
public function getMax($array) {
// Returns maximum in array
$n = count($array);
$max = $array[0];
for ($i = 1; $i < $n; $i++)
if ($max < $array[$i])
$max = $array[$i];
return $max;
}
// Returns maximum in array
public function getMin($array) {
$n = count($array);
$min = $array[0];
for ($i = 1; $i < $n; $i++)
if ($min > $array[$i])
$min = $array[$i];
return $min;
}
public function getflightlogo($strAirlineCodeLogo) {
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
if (file_exists($filePath . $strAirlineCodeLogo . ".gif")) {
$strAirlineLogo = $strAirlineCodeLogo . ".gif";
$filePath = $this->baseUrl . "/public/upload/AirlineLogo/" . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCodeLogo . ".png")) {
$strAirlineLogo = $strAirlineCodeLogo . ".png";
$filePath = $this->baseUrl . "/public/upload/AirlineLogo/" . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpg")) {
$strAirlineLogo = $strAirlineCodeLogo . ".jpg";
$filePath = $this->baseUrl . "/public/upload/AirlineLogo/" . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCodeLogo . ".jpeg")) {
$strAirlineLogo = $strAirlineCodeLogo . ".jpeg";
$filePath = $this->baseUrl . "/public/upload/AirlineLogo/" . $strAirlineLogo;
} else {
$filePath = $this->baseUrl . "/public/upload/AirlineLogo/noimage.png";
}
return $filePath;
}
public function searchResultNewAction() {
$this->view->typeQuick = $typeQuick = $this->getRequest()->getParam('type');
$this->view->SearchID = $SearchID = $this->getRequest()->getParam('SearchID');
$this->view->baseUrl = $this->baseUrl;
if (!$this->_request->isXmlHttpRequest()) {
$objTempFlight = new Travel_Model_TblFlight();
$FlightTempData = $objTempFlight->GetFlightTempData($SearchID);
$APIBookingData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $APIBookingData['sessionFlightSearchParams'];
$intSourceCityId = trim($sessionFlightSearchParams['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams['destinationCityId']);
if (isset($sessionFlightSearchParams['customerID']) && !empty($sessionFlightSearchParams['customerID'])) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = isset($sessionFlightSearchParams['customerID']) ? $this->_crmcustomerObj->GetAgencyCustomerById(trim($sessionFlightSearchParams['customerID'])) : '';
$sessionFlightSearchParams['customername'] = trim($customerDetails['FirstName']) . " " . trim($customerDetails['LastName']);
$this->view->customerDetails = $customerDetails;
}
/* For Displaying Temprary Result set of flights */
if (!empty($intSourceCityId) && !empty($intDestinationCityId)) {
$objTempFlight->strCondition = " t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
}
$arrTempFlightList = $objTempFlight->getTempFlightSearchResultList();
$this->view->arrTempFlightList = $arrTempFlightList;
/* For Displaying Temprary Result set of flights */
$sessionFlightRecordInfo = new Zend_Session_Namespace('sessionFlightRecordInfo');
$sessionFlightRecordInfo->params['intTotalRecordCount'] = 0; // Set Total Records to '0' on page Refresh...
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = trim($sessionLogin_user->intLoggedinUserAgencySysId);
$agencyModel = new Travel_Model_TblAgency();
$getActiveSenderEmailIdArr = $agencyModel->getActiveSenderEmailID($AgencySysId);
$this->view->getActiveSenderEmailIdArr = $getActiveSenderEmailIdArr;
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$this->view->SenderEmailSysId = $SenderEmailSysId;
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
$this->view->getActiveStaff = $getActiveStaff = $agencyModel->getActiveStaff($AgencySysId);
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
$this->view->getleadSource = $getleadSource;
}
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
}
$markupMdl = new Markup_Model_Markup();
// $this->view->getTaxSettingDetail = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinAgencyId,0,0,1);
$getTaxSettingDetail = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinAgencyId, 0, 0, 1);
//
if (empty($getTaxSettingDetail)) {
$this->view->getTaxSettingDetail = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinAgencyId, 0, 0, 5);
} else {
$this->view->getTaxSettingDetail = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinAgencyId, 0, 0, 1);
}
}
public function searchResultAction() {
$this->view->typeQuick = $typeQuick = $this->getRequest()->getParam('type');
$this->view->baseUrl = $this->baseUrl;
if (!$this->_request->isXmlHttpRequest()) {
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
if (isset($sessionFlightSearchParams->params['customerID']) && !empty($sessionFlightSearchParams->params['customerID'])) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = isset($sessionFlightSearchParams->params['customerID']) ? $this->_crmcustomerObj->GetAgencyCustomerById(trim($sessionFlightSearchParams->params['customerID'])) : '';
$sessionFlightSearchParams->params['customername'] = trim($customerDetails['FirstName']) . " " . trim($customerDetails['LastName']);
$this->view->customerDetails = $customerDetails;
}
/* For Displaying Temprary Result set of flights */
$objTempFlight = new Travel_Model_TblFlight();
if (!empty($intSourceCityId) && !empty($intDestinationCityId)) {
$objTempFlight->strCondition = " t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
}
$arrTempFlightList = $objTempFlight->getTempFlightSearchResultList();
$this->view->arrTempFlightList = $arrTempFlightList;
/* For Displaying Temprary Result set of flights */
$sessionFlightRecordInfo = new Zend_Session_Namespace('sessionFlightRecordInfo');
$sessionFlightRecordInfo->params['intTotalRecordCount'] = 0; // Set Total Records to '0' on page Refresh...
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = trim($sessionLogin_user->intLoggedinUserAgencySysId);
$agencyModel = new Travel_Model_TblAgency();
$getActiveSenderEmailIdArr = $agencyModel->getActiveSenderEmailID($AgencySysId);
$this->view->getActiveSenderEmailIdArr = $getActiveSenderEmailIdArr;
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$this->view->SenderEmailSysId = $SenderEmailSysId;
}
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
// echo "<pre>";
// print_r($sessionFlightSearchParams->params);
// exit;
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$origin = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$intSourceCityId = trim($sessionFlightSearchParams->params['sourceCityId']);
$intDestinationCityId = trim($sessionFlightSearchParams->params['destinationCityId']);
$preferredDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strDepatureDate, 'd/m/y') . "T00:00:00";
$preferredArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strReturnDate, 'd/m/y') . "T00:00:00";
$preferredFlightClassType = $sessionFlightSearchParams->params['flight_class'];
/* Common Variable For API Call */
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strReturnDate));
$FromUTCTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$ToUTCTime = date("Y-m-d h:i", strtotime($strReturnDate));
if (!empty($sessionFlightSearchParams->params)) {
$strfilterByPrice = trim($this->getRequest()->getPost('filterByPrice'));
$arrfilterByPrice = array();
if (!empty($strfilterByPrice)) {
$arrfilterByPrice = explode(",", $strfilterByPrice);
}
$strfilterByStops = trim($this->getRequest()->getPost('filterByStops'));
$strfilterByDepartureTime = trim($this->getRequest()->getPost('filterByDepartureTime'));
$arrFilterByDepartureTime = [];
if (!empty($strfilterByDepartureTime)) {
$arrFilterByDepartureTime = explode(",", $strfilterByDepartureTime);
}
$strfilterByAirlines = trim($this->getRequest()->getPost('filterByAirlines'));
$strOrderBy = trim($this->getRequest()->getPost('orderBy'));
$strOnRequest = trim($this->getRequest()->getPost('onRequest'));
// Database lookup for flights...
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = "";
// Filter Starts Here
if (!empty($intSourceCityId) && !empty($intDestinationCityId)) {
$objFlight->strCondition .= " t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
}
if (!empty($arrfilterByPrice)) {
$objFlight->strCondition .= " AND ( ";
$intP = 1;
foreach ($arrfilterByPrice as $priceSagments) {
$arrPriceSagments = explode("-", $priceSagments);
$intPriceSeg1 = !empty($arrPriceSagments[0]) ? $arrPriceSagments[0] : 0;
$intPriceSeg2 = !empty($arrPriceSagments[1]) ? $arrPriceSagments[1] : 0;
if (!empty($arrPriceSagments[0]) && !empty($arrPriceSagments[1])) {
$objFlight->strCondition .= " ( t1.PublishedFare >= '" . $intPriceSeg1 . "' AND t1.PublishedFare <= '" . $intPriceSeg2 . "' )";
if (count($arrfilterByPrice) > $intP) {
$objFlight->strCondition .= " OR ";
}
$intP++;
}
}
$objFlight->strCondition .= " ) ";
}
if ($strfilterByStops != "") {
$objFlight->strCondition .= " AND t1.StopCount IN ( $strfilterByStops )";
}
if (!empty(@$arrFilterByDepartureTime)) {
$arrTimeFilter = array(
"1" => "'00:00' AND '07:00'",
"2" => "'06:00' AND '11:00'",
"3" => "'11:00' AND '18:00'",
"4" => "'17:00' AND '23:59'"
);
$objFlight->strCondition .= " AND ( ";
$intI = 1;
foreach ($arrFilterByDepartureTime as $sagments) {
$objFlight->strCondition .= " SUBSTRING(convert(varchar, t1.FromUTCTime, 120),12,5) BETWEEN $arrTimeFilter[$sagments] ";
if (count($arrFilterByDepartureTime) != $intI) {
$objFlight->strCondition .= " OR ";
}
$intI++;
}
$objFlight->strCondition .= " ) ";
}
if ($strfilterByAirlines != "") {
$objFlight->strCondition .= " AND t1.AirlineSysId IN ( $strfilterByAirlines )";
}
// Filter Ends Here
//echo $objFlight->strCondition;
if (!empty($strDepatureDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.LocalFromTime, 120),0,11) = '" . $strDepatureDate . "'";
}
if (!empty($strReturnDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.LocalToTime, 120),0,11) = '" . $strReturnDate . "'";
}
if (!empty($intMemberCount)) {
$objFlight->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
if (!empty($strOnRequest)) {
$objFlight->onRequest = " $strOrderBy ";
} else {
$objFlight->orderBy = " $strOrderBy ";
}
$intPageNumber = !empty($this->getRequest()->getPost('page')) ? $this->getRequest()->getPost('page') : '1';
$intfilterFlag = trim($this->getRequest()->getPost('filterFlag'));
$intLimitPerPage = FLIGHT_SEARCH_PER_PAGE_LIMIT;
$sessionFlightRecordInfo = new Zend_Session_Namespace('sessionFlightRecordInfo');
if ($strFlightRoute == '1') {
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$objFlight->intJourneyType = "1";
$arrSearchFlightResultCount = $objFlight->getFlightSearchList();
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCount[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCount[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCount[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCount[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'];
$objFlight->strSelectedView = "list";
$objFlight->intJourneyType = "1";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
$arrSearchFlightResult = $objFlight->getFlightSearchList();
//echo "<pre>"; print_r($arrSearchFlightResult); //exit;
if ($intPageNumber == 1) {
$strAirlineSysIds = "";
foreach ($arrSearchFlightResult as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
// $arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResult->setCurrentPageNumber($page);
} else {
if ($interNationalSearch) {
//echo $objFlight->strCondition; exit;
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$objFlight->intJourneyType = "2";
$arrSearchFlightResultCount = $objFlight->getInterNationalFlightSearchList();
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCount[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCount[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCount[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCount[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'];
$objFlight->strSelectedView = "list";
$objFlight->intJourneyType = "2";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
$arrInterNationalFlightSearchResult = $objFlight->getInterNationalFlightSearchList();
} else {
//OutBound Flights..
$objFlight->intJourneyType = "2";
$objFlight->intTripType = "1";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResultCountOutBound = $objFlight->getFlightSearchList();
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCountOutBound[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCountOutBound[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCountOutBound[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCountOutBound[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$objFlight->strSelectedView = "list";
$arrSearchFlightResultOutBound = $objFlight->getFlightSearchList();
if ($intPageNumber == 1) {
$strAirlineSysIds = "";
foreach ($arrSearchFlightResultOutBound as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResultOutBound = Zend_Paginator::factory($arrSearchFlightResultOutBound);
// $arrSearchFlightResultOutBound->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResultOutBound->setCurrentPageNumber($page);
//echo "<pre>";print_r($arrSearchFlightResultOutBound);exit;
//InBound Flights..
$objFlight->intJourneyType = "2";
$objFlight->intTripType = "2";
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResultCountInBound = $objFlight->getFlightSearchList();
$this->view->intSearchedFlightResultCountInBound = $arrSearchFlightResultCountInBound[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCountInBound'] = $arrSearchFlightResultCountInBound[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPriceInBound'] = $arrSearchFlightResultCountInBound[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPriceInBound'] = $arrSearchFlightResultCountInBound[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'] + $sessionFlightRecordInfo->params['intTotalRecordCountInBound'];
$objFlight->strSelectedView = "list";
$arrSearchFlightResultInBound = $objFlight->getFlightSearchList();
if ($intPageNumber == 1) {
foreach ($arrSearchFlightResultInBound as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResultInBound = Zend_Paginator::factory($arrSearchFlightResultInBound);
// $arrSearchFlightResultInBound->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResultInBound->setCurrentPageNumber($page);
} // Domestic Round Trip ends
}
// Database lookup for flights...
if ($sessionFlightRecordInfo->params['intTotalRecordCount'] > 0 || $intfilterFlag == 0) {
if ($strFlightRoute == '1') { // for single trip flight...
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
//echo "<pre>"; print_r($arrSearchFlightResult); exit;
$this->render('all-airlines-db');
exit;
} else {
if ($interNationalSearch) { // for roundtrip international...
$TBQAirInvenSysId = array();
$TBQAirInvenSysIds = "";
foreach ($arrInterNationalFlightSearchResult as $arrResult) {
$TBQAirInvenSysId[] = $arrResult['TBQAirInvenSysId'];
}
$TBQAirInvenSysIds = implode(",", $TBQAirInvenSysId);
//echo $TBQAirInvenSysIds; exit;
$arrInterNationalFlightList = $objFlight->getInterNationalFlightByMasterId($TBQAirInvenSysIds);
if ($intPageNumber == 1) {
$strAirlineSysIds = "";
foreach ($arrInterNationalFlightList as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
//echo "<pre>";print_r($arrInterNationalFlightList);echo "</pre>";
$arr = array();
$temp = "";
foreach ($arrInterNationalFlightList as $arrRes) {
if ($temp == "") {
$arr[$arrRes['AirInvenSysId']]['outBound']['TBQAirInvenSysId'] = $arrRes['TBQAirInvenSysId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['ApiResultIndex'] = $arrRes['ApiResultIndex'];
$arr[$arrRes['AirInvenSysId']]['outBound']['apiTraceId'] = $arrRes['apiTraceId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['PublishedFare'] = $arrRes['PublishedFare'];
$arr[$arrRes['AirInvenSysId']]['outBound']['CommissionEarned'] = $arrRes['CommissionEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['PLBEarned'] = $arrRes['PLBEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['IncentiveEarned'] = $arrRes['IncentiveEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['OfferedFare'] = $arrRes['OfferedFare'];
$arr[$arrRes['AirInvenSysId']]['outBound']['AirlineName'] = $arrRes['AirlineName'];
$arr[$arrRes['AirInvenSysId']]['outBound']['SourceAirportCode'] = $arrRes['SourceAirportCode'];
$arr[$arrRes['AirInvenSysId']]['outBound']['DestAirportCode'] = $arrRes['DestAirportCode'];
$arr[$arrRes['AirInvenSysId']]['outBound']['FlightNumber'] = $arrRes['FlightNumber'];
$arr[$arrRes['AirInvenSysId']]['outBound']['AirlineSysId'] = $arrRes['AirlineSysId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['FlightDuration'] = $arrRes['FlightDuration'];
$arr[$arrRes['AirInvenSysId']]['outBound']['OriginDepartureTime'] = $arrRes['OriginDepartureTime'];
$arr[$arrRes['AirInvenSysId']]['outBound']['DestArrivalTime'] = $arrRes['DestArrivalTime'];
$arr[$arrRes['AirInvenSysId']]['outBound']['StopCount'] = $arrRes['StopCount'];
$arr[$arrRes['AirInvenSysId']]['outBound']['IsRefundable'] = $arrRes['IsRefundable'];
$arr[$arrRes['AirInvenSysId']]['outBound']['NoOfSeatAvailable'] = $arrRes['NoOfSeatAvailable'];
$temp = $arrRes['AirInvenSysId'];
} elseif ($temp != "" && $temp == $arrRes['AirInvenSysId']) {
$arr[$arrRes['AirInvenSysId']]['inBound']['SourceAirportCode'] = $arrRes['SourceAirportCode'];
$arr[$arrRes['AirInvenSysId']]['inBound']['DestAirportCode'] = $arrRes['DestAirportCode'];
$arr[$arrRes['AirInvenSysId']]['inBound']['FlightNumber'] = $arrRes['FlightNumber'];
$arr[$arrRes['AirInvenSysId']]['inBound']['AirlineSysId'] = $arrRes['AirlineSysId'];
$arr[$arrRes['AirInvenSysId']]['inBound']['FlightDuration'] = $arrRes['FlightDuration'];
$arr[$arrRes['AirInvenSysId']]['inBound']['OriginDepartureTime'] = $arrRes['OriginDepartureTime'];
$arr[$arrRes['AirInvenSysId']]['inBound']['DestArrivalTime'] = $arrRes['DestArrivalTime'];
$arr[$arrRes['AirInvenSysId']]['inBound']['StopCount'] = $arrRes['StopCount'];
$arr[$arrRes['AirInvenSysId']]['inBound']['IsRefundable'] = $arrRes['IsRefundable'];
$arr[$arrRes['AirInvenSysId']]['inBound']['NoOfSeatAvailable'] = $arrRes['NoOfSeatAvailable'];
$temp = "";
}
}
//echo "<pre>";print_r($arr);
$this->view->arrInterNationalFlightSearchResult = $arr;
$this->render('international-flights');
exit;
} else { // for roundtrip domestic...
$this->view->arrSearchFlightResultOutBound = $arrSearchFlightResultOutBound;
$this->view->arrSearchFlightResultInBound = $arrSearchFlightResultInBound;
$this->render('twoway-all-airlines');
exit;
}
}
} else { // API lookup for flights...
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->searchApiFlights($sessionFlightSearchParams->params);
//echo "<pre>"; print_r($apiResponse); exit;
$intResponseStatus = !empty($apiResponse['ResponseStatus']) ? $apiResponse['ResponseStatus'] : '0';
$strTraceId = !empty($apiResponse['TraceId']) ? $apiResponse['TraceId'] : '';
if ($intResponseStatus == 1) {
if ($strFlightRoute == '1') {
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 1, // For Single Trips API Search
'TripType' => 1,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$arrOutBoundFlightResults = $apiResponse['OutBoundFlightResults'];
//echo "<pre>"; print_r($arrOutBoundFlightResults); exit;
$this->insertUpdateOutBoundFlightAction($arrOutBoundFlightResults, $arrCommonInsVariables); // For One Way Flights...
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResultCount = $objFlight->getFlightSearchList();
//echo "<pre>"; print_r($arrSearchFlightResultCount); exit;
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCount[0]['total'];
$sessionFlightRecordInfo = new Zend_Session_Namespace('sessionFlightRecordInfo');
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCount[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCount[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCount[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'];
$objFlight->strSelectedView = "list";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
$arrSearchFlightResult = $objFlight->getFlightSearchList();
if ($intPageNumber == 1) { // Getting All Airlines Ids on First Search
$strAirlineSysIds = "";
foreach ($arrSearchFlightResult as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
// $arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$this->render('all-airlines-db');
exit;
} else if ($strFlightRoute == '2') {
if ($interNationalSearch) {
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => 1
);
$arrInterNationalFlightResults = $apiResponse['InterNationalFlightResults'];
//echo "<pre>"; print_r($arrInterNationalFlightResults); exit;
$this->insertInterNationalFlightAction($arrInterNationalFlightResults, $arrCommonInsVariables); // For One Way Flights...
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$objFlight->intJourneyType = "2";
$arrSearchFlightResultCount = $objFlight->getInterNationalFlightSearchList();
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCount[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCount[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCount[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCount[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'];
$objFlight->strSelectedView = "list";
$objFlight->intJourneyType = "2";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
$arrInterNationalFlightSearchResult = $objFlight->getInterNationalFlightSearchList();
//echo "<pre>";print_r($arrInterNationalFlightSearchResult);exit;
$arr = array();
if (!empty($arrInterNationalFlightSearchResult)) {
$TBQAirInvenSysId = array();
$TBQAirInvenSysIds = "";
foreach ($arrInterNationalFlightSearchResult as $arrResult) {
$TBQAirInvenSysId[] = $arrResult['TBQAirInvenSysId'];
}
$TBQAirInvenSysIds = implode(",", $TBQAirInvenSysId);
$arrInterNationalFlightList = $objFlight->getInterNationalFlightByMasterId($TBQAirInvenSysIds);
if ($intPageNumber == 1) {
$strAirlineSysIds = "";
foreach ($arrInterNationalFlightList as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
$arr = array();
$temp = "";
foreach ($arrInterNationalFlightList as $arrRes) {
if ($temp == "") {
$arr[$arrRes['AirInvenSysId']]['outBound']['TBQAirInvenSysId'] = $arrRes['TBQAirInvenSysId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['ApiResultIndex'] = $arrRes['ApiResultIndex'];
$arr[$arrRes['AirInvenSysId']]['outBound']['apiTraceId'] = $arrRes['apiTraceId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['PublishedFare'] = $arrRes['PublishedFare'];
$arr[$arrRes['AirInvenSysId']]['outBound']['CommissionEarned'] = $arrRes['CommissionEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['PLBEarned'] = $arrRes['PLBEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['IncentiveEarned'] = $arrRes['IncentiveEarned'];
$arr[$arrRes['AirInvenSysId']]['outBound']['OfferedFare'] = $arrRes['OfferedFare'];
$arr[$arrRes['AirInvenSysId']]['outBound']['AirlineName'] = $arrRes['AirlineName'];
$arr[$arrRes['AirInvenSysId']]['outBound']['SourceAirportCode'] = $arrRes['SourceAirportCode'];
$arr[$arrRes['AirInvenSysId']]['outBound']['DestAirportCode'] = $arrRes['DestAirportCode'];
$arr[$arrRes['AirInvenSysId']]['outBound']['FlightNumber'] = $arrRes['FlightNumber'];
$arr[$arrRes['AirInvenSysId']]['outBound']['AirlineSysId'] = $arrRes['AirlineSysId'];
$arr[$arrRes['AirInvenSysId']]['outBound']['FlightDuration'] = $arrRes['FlightDuration'];
$arr[$arrRes['AirInvenSysId']]['outBound']['OriginDepartureTime'] = $arrRes['OriginDepartureTime'];
$arr[$arrRes['AirInvenSysId']]['outBound']['DestArrivalTime'] = $arrRes['DestArrivalTime'];
$arr[$arrRes['AirInvenSysId']]['outBound']['StopCount'] = $arrRes['StopCount'];
$arr[$arrRes['AirInvenSysId']]['outBound']['IsRefundable'] = $arrRes['IsRefundable'];
$arr[$arrRes['AirInvenSysId']]['outBound']['NoOfSeatAvailable'] = $arrRes['NoOfSeatAvailable'];
$temp = $arrRes['AirInvenSysId'];
} elseif ($temp != "" && $temp == $arrRes['AirInvenSysId']) {
$arr[$arrRes['AirInvenSysId']]['inBound']['SourceAirportCode'] = $arrRes['SourceAirportCode'];
$arr[$arrRes['AirInvenSysId']]['inBound']['DestAirportCode'] = $arrRes['DestAirportCode'];
$arr[$arrRes['AirInvenSysId']]['inBound']['FlightNumber'] = $arrRes['FlightNumber'];
$arr[$arrRes['AirInvenSysId']]['inBound']['AirlineSysId'] = $arrRes['AirlineSysId'];
$arr[$arrRes['AirInvenSysId']]['inBound']['FlightDuration'] = $arrRes['FlightDuration'];
$arr[$arrRes['AirInvenSysId']]['inBound']['OriginDepartureTime'] = $arrRes['OriginDepartureTime'];
$arr[$arrRes['AirInvenSysId']]['inBound']['DestArrivalTime'] = $arrRes['DestArrivalTime'];
$arr[$arrRes['AirInvenSysId']]['inBound']['StopCount'] = $arrRes['StopCount'];
$arr[$arrRes['AirInvenSysId']]['inBound']['IsRefundable'] = $arrRes['IsRefundable'];
$arr[$arrRes['AirInvenSysId']]['inBound']['NoOfSeatAvailable'] = $arrRes['NoOfSeatAvailable'];
$temp = "";
}
}
}
$this->view->arrInterNationalFlightSearchResult = $arr;
$this->render('international-flights');
exit;
} else {
$arrCommonInsVariables = array(
'strTraceId' => $strTraceId,
'localFromDateTime' => $localFromDateTime,
'localToDateTime' => $localToDateTime,
'strSourceAirportCode' => $strSourceAirportCode,
'strDestinationAirportCode' => $strDestinationAirportCode,
'intMemberCount' => $intMemberCount,
'intSourceCityId' => $intSourceCityId,
'intDestinationCityId' => $intDestinationCityId,
'JourneyType' => 2, // For Round Trips API Search
'TripType' => 1,
'interNationalSearch' => isset($interNationalSearch) ? $interNationalSearch : 0
);
$arrOutBoundFlightResults = $apiResponse['OutBoundFlightResults'];
$this->insertUpdateOutBoundFlightAction($arrOutBoundFlightResults, $arrCommonInsVariables); // For One Way Flights...
$arrCommonInsVariables['TripType'] = 2;
$arrInBoundFlightResults = $apiResponse['InBoundFlightResults'];
$this->insertUpdateInBoundFlightAction($arrInBoundFlightResults, $arrCommonInsVariables); // For Return Flights...
//OutBound Flights..
$objFlight->intJourneyType = "2";
$objFlight->intTripType = "1";
$objFlight->intPageNo = $intPageNumber;
$objFlight->intListPerPage = $intLimitPerPage;
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResultCountOutBound = $objFlight->getFlightSearchList();
$this->view->intSearchedFlightResultCount = $arrSearchFlightResultCountOutBound[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCount'] = $arrSearchFlightResultCountOutBound[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPrice'] = $arrSearchFlightResultCountOutBound[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPrice'] = $arrSearchFlightResultCountOutBound[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$objFlight->strSelectedView = "list";
$arrSearchFlightResultOutBound = $objFlight->getFlightSearchList();
if ($intPageNumber == 1) {
$strAirlineSysIds = "";
foreach ($arrSearchFlightResultOutBound as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResultOutBound = Zend_Paginator::factory($arrSearchFlightResultOutBound);
// $arrSearchFlightResultOutBound->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResultOutBound->setCurrentPageNumber($page);
//echo "<pre>";print_r($arrSearchFlightResultOutBound);exit;
//InBound Flights..
$objFlight->intJourneyType = "2";
$objFlight->intTripType = "2";
if ($intPageNumber == 1) {
$objFlight->strSelectedView = "Count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResultCountInBound = $objFlight->getFlightSearchList();
$this->view->intSearchedFlightResultCountInBound = $arrSearchFlightResultCountInBound[0]['total'];
$sessionFlightRecordInfo->params['intTotalRecordCountInBound'] = $arrSearchFlightResultCountInBound[0]['total']; // Set Total Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMinPriceInBound'] = $arrSearchFlightResultCountInBound[0]['minPrice']; // Set minPrice Records on ajax Hit to db...
$sessionFlightRecordInfo->params['intMaxPriceInBound'] = $arrSearchFlightResultCountInBound[0]['maxPrice']; // Set maxPrice Records on ajax Hit to db...
}
$this->view->intSearchedFlightCount = $sessionFlightRecordInfo->params['intTotalRecordCount'] + $sessionFlightRecordInfo->params['intTotalRecordCountInBound'];
$objFlight->strSelectedView = "list";
$arrSearchFlightResultInBound = $objFlight->getFlightSearchList();
if ($intPageNumber == 1) {
foreach ($arrSearchFlightResultInBound as $result) { //echo $result['ArrivalTime']; exit;
$AirlineSysId = trim($result['AirlineSysId']);
if (!empty($AirlineSysId) && strpos($strAirlineSysIds, $AirlineSysId) === false) {
$strAirlineSysIds .= $result['AirlineSysId'] . ",";
}
}
$this->view->strAirlineSysIds = $strAirlineSysIds;
}
// $page = $this->_getParam('page', $intPageNumber);
// $arrSearchFlightResultInBound = Zend_Paginator::factory($arrSearchFlightResultInBound);
// $arrSearchFlightResultInBound->setItemCountPerPage($intLimitPerPage);
// $arrSearchFlightResultInBound->setCurrentPageNumber($page);
$this->view->arrSearchFlightResultOutBound = $arrSearchFlightResultOutBound;
$this->view->arrSearchFlightResultInBound = $arrSearchFlightResultInBound;
$this->render('twoway-all-airlines');
exit;
}
}
} else {
$this->view->ErrorCode = $apiResponse['ErrorCode'];
$this->view->ErrorMessage = $apiResponse['ErrorMessage'];
if ($strFlightRoute == '1') { // for singletrip flights...
$this->render('all-airlines-db');
exit;
} else {
if ($interNationalSearch) { // for roundtrip international...
$this->render('international-flights');
exit;
} else { // for roundtrip domestic...
$this->render('twoway-all-airlines');
exit;
}
}
}
}
}
//exit;
}
}
public function insertUpdateOutBoundFlightAction($data, $arrCommonInsVariables) {
if (!empty($data)) {
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
// Fix Values.....
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strSourceAirportCode'];
$strDestinationAirportCode = $arrCommonInsVariables['strDestinationAirportCode'];
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '0';
$ICSourceSysId = $this->InfoSourceSysId;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
foreach ($data as $result) {
//print_r($arrOutBoundFlights); exit;
$ResultIndex = $result['ResultIndex'];
$Source = $result['Source'];
$IsLCC = $result['IsLCC'];
$IsRefundable = $result['IsRefundable'];
$AirlineRemark = $result['AirlineRemark'];
$LastTicketDate = $result['LastTicketDate'];
$TicketAdvisory = $result['TicketAdvisory'];
$AirlineCode = $result['AirlineCode'];
$ValidatingAirline = $result['ValidatingAirline'];
// Fare
$Currency = $result['Fare']['Currency'];
$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
//$OfferedFare = $result['Fare']['OfferedFare'];
$intCalculatedBaseFare = ($BaseFare + $Tax);
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => $currencySysId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"OfferedFare" => $OfferedFare,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => $IsActive,
"IsMarkForDel" => $IsMarkForDel
);
//echo '<pre>';print_r($arrFairRules);echo '</pre>';
$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
if (!empty($result['Segments'][0])) {
$FlyingMinutes = 0;
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
foreach ($result['Segments'][0] as $segmentsResult) {
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrSegments = array(
"AirInvenAPISysId" => '',
"TripIndicator" => $TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"SegmentIndicator" => $SegmentIndicator,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status
);
// FOR FLIGHT SEGMENTS.....
}
}
// $originDepTime = $segmentsResult['Origin']['DepTime'];
// $destinationArrTime = $segmentsResult['Destination']['ArrTime'];
// Fare
$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
$FlyingMinutes = $FlyingMinutes;
if (!empty($result['Segments'][0]) > 1) {
$SegmentsCount = count($result['Segments'][0]);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
} else {
$StopCount = '0';
$IsDirect = '1';
}
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['IsRefundable'] = $IsRefundable;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $strFareClass;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData['JourneyType'] = $intJourneyType;
$arrInsertFlightData['TripType'] = $intTripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$arrInsertFlightData['IsInternational'] = $interNationalSearch;
//echo '<pre>';print_r($arrInsertFlightData);echo '</pre>';
//echo '<pre>';print_r($arrSegments);echo '</pre>';
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
// FOR FLIGHT FAIR-RULES.....
$arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightFairRuleDetails($arrFairRules);
// FOR FLIGHT FAIR-RULES.....
// FOR FLIGHT SEGMENTS.....
$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $AirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
//echo '<pre>';print_r($arrFareBreakdown);echo '</pre>';
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
if ($IsDirect == 0) {
$tempFlightNumber = "";
$IsFlightChange = 0;
//$changedFlightNumber = "";
$FlyingMinutes = 0;
$intSegmentsCount = 0;
//$firstFlightNumber = "";
foreach ($result['Segments'][0] as $segmentsResult) {
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
// if($firstFlightNumber == ""){
// $firstFlightNumber = $FlightNumber;
// }
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
}
$tempFlightNumber = $FlightNumber;
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $AirInvenSysId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"Sequance" => $SegmentIndicator,
"DestPlaceSysId" => $DestPlaceSysId,
"StayDuration" => $GroundTime,
"FlightDuration" => $Duration,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FlightNumber" => $FlightNumber,
"FareClass" => $FareClass,
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"OriginAirportCode" => $originAirportCode,
"DestinationAirportCode" => $destinationAirportCode,
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => $NewFInvenSysId,
"ArrivalTime" => $originDepTime,
"DepartureTime" => $destinationArrTime,
"HaultInclusions" => '',
"CurrencyType" => $currencySysId,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"CreateDate" => $CreateDate,
"UpdateDate" => $UpdateDate,
"IsActive" => $IsActive,
"IsMarkForDelete" => $IsMarkForDel
);
//echo '<pre>';print_r($arrFlightStopsInsert);echo '</pre>';
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$intSegmentsCount++;
}
}
} // Foreach ends
}
}
public function insertUpdateInBoundFlightAction($data, $arrCommonInsVariables) {
if (!empty($data)) {
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
// Fix Values.....
$strTraceId = $arrCommonInsVariables['strTraceId'];
$localFromDateTime = $arrCommonInsVariables['localFromDateTime'];
$localToDateTime = $arrCommonInsVariables['localToDateTime'];
$strSourceAirportCode = $arrCommonInsVariables['strDestinationAirportCode']; // In case of Return
$strDestinationAirportCode = $arrCommonInsVariables['strSourceAirportCode']; // In case of Return
$intMemberCount = $arrCommonInsVariables['intMemberCount'];
$intSourceCityId = $arrCommonInsVariables['intSourceCityId'];
$intDestinationCityId = $arrCommonInsVariables['intDestinationCityId'];
$intJourneyType = $arrCommonInsVariables['JourneyType'];
$intTripType = $arrCommonInsVariables['TripType'];
$ICSourceSysId = $this->InfoSourceSysId;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
foreach ($data as $result) {
//print_r($arrOutBoundFlights); exit;
$ResultIndex = $result['ResultIndex'];
$Source = $result['Source'];
$IsLCC = $result['IsLCC'];
$IsRefundable = $result['IsRefundable'];
$AirlineRemark = $result['AirlineRemark'];
$LastTicketDate = $result['LastTicketDate'];
$TicketAdvisory = $result['TicketAdvisory'];
$AirlineCode = $result['AirlineCode'];
$ValidatingAirline = $result['ValidatingAirline'];
// Fare
$Currency = $result['Fare']['Currency'];
$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
//$OfferedFare = $result['Fare']['OfferedFare'];
$intCalculatedBaseFare = ($BaseFare + $Tax);
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => $currencySysId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"OfferedFare" => $OfferedFare,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => $IsActive,
"IsMarkForDel" => $IsMarkForDel
);
$AirlineCode = $result['Segments'][0][0]['Airline']['AirlineCode'];
$FlightNumber = $result['Segments'][0][0]['Airline']['FlightNumber'];
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$strFareClass = $result['Segments'][0][0]['Airline']['FareClass'];
if (!empty($result['Segments'][0])) {
$FlyingMinutes = 0;
$initialOriginDepTime = $result['Segments'][0][0]['Origin']['DepTime'];
foreach ($result['Segments'][0] as $segmentsResult) {
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
// FOR FLIGHT SEGMENTS.....
$strBaggage = $segmentsResult['Baggage'];
$strCabinBaggage = $segmentsResult['CabinBaggage'];
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$strAirlineCode = $segmentsResult['Airline']['AirlineCode'];
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$Duration = $segmentsResult['Duration'];
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrSegments = array(
"AirInvenAPISysId" => '',
"TripIndicator" => $TripIndicator,
"Baggage" => $strBaggage,
"CabinBaggage" => $strCabinBaggage,
"SegmentIndicator" => $SegmentIndicator,
"Duration" => $Duration,
"GroundTime" => $GroundTime,
"Mile" => $Mile,
"StopOver" => $StopOver,
"StopPoint" => $StopPoint,
"StopPointArrivalTime" => $StopPointArrivalTime,
"Craft" => $Craft,
"Remark" => $Remark,
"IsETicketEligible" => $IsETicketEligible,
"FlightStatus" => $FlightStatus,
"Status" => $Status
);
// FOR FLIGHT SEGMENTS.....
}
}
// $originDepTime = $segmentsResult['Origin']['DepTime'];
// $destinationArrTime = $segmentsResult['Destination']['ArrTime'];
// Fare
$airlineSysId = !empty($arrAirlineList[$result['AirlineCode']]) ? $arrAirlineList[$result['AirlineCode']] : '0';
$FlyingMinutes = $FlyingMinutes;
if (count($result['Segments'][0]) > 1) {
$SegmentsCount = count($result['Segments'][0]);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
} else {
$StopCount = '0';
$IsDirect = '1';
}
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['IsRefundable'] = $IsRefundable;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $strFareClass;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData['JourneyType'] = $intJourneyType;
$arrInsertFlightData['TripType'] = $intTripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
// FOR FLIGHT FAIR-RULES.....
$arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightFairRuleDetails($arrFairRules);
// FOR FLIGHT FAIR-RULES.....
// FOR FLIGHT SEGMENTS.....
$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $AirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
if ($IsDirect == 0) {
$tempFlightNumber = "";
$IsFlightChange = 0;
//$changedFlightNumber = "";
$FlyingMinutes = 0;
$intSegmentsCount = 0;
//$firstFlightNumber = "";
foreach ($result['Segments'][0] as $segmentsResult) {
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
// if($firstFlightNumber == ""){
// $firstFlightNumber = $FlightNumber;
// }
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
}
$tempFlightNumber = $FlightNumber;
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$NoOfSeatAvailable = !empty($segmentsResult['NoOfSeatAvailable']) ? $segmentsResult['NoOfSeatAvailable'] : 0;
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $AirInvenSysId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"Sequance" => $SegmentIndicator,
"DestPlaceSysId" => $DestPlaceSysId,
"StayDuration" => $GroundTime,
"FlightDuration" => $Duration,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FlightNumber" => $FlightNumber,
"FareClass" => $FareClass,
"OriginAirportCode" => $originAirportCode,
"DestinationAirportCode" => $destinationAirportCode,
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => $NewFInvenSysId,
"ArrivalTime" => $destinationArrTime,
"DepartureTime" => $originDepTime,
"HaultInclusions" => '',
"NoOfSeatAvailable" => $NoOfSeatAvailable,
"CurrencyType" => $currencySysId,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"CreateDate" => $CreateDate,
"UpdateDate" => $UpdateDate,
"IsActive" => $IsActive,
"IsMarkForDelete" => $IsMarkForDel
);
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$intSegmentsCount++;
}
}
} // Foreach ends
}
}
public function insertInterNationalFlightAction($data, $arrCommonInsVariables) {
if (isset($data) && count($data) > 0) {
// echo "<pre>";
// print_r($data);
// exit;
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
//echo "<pre>";print_r($data);exit;
foreach ($data as $result) {
//echo "<pre>";print_r($result);
// Master Entry...
if (isset($result['Segments']) && count($result['Segments']) > 1) {
$AirlineCode = isset($result['AirlineCode']) ? $result['AirlineCode'] : '';
$OriginDepTime = isset($result['Segments'][0][0]['Origin']['DepTime']) ? $result['Segments'][0][0]['Origin']['DepTime'] : '';
$DestinationArrTime = isset($result['Segments'][1][1]['Destination']['ArrTime']) ? $result['Segments'][1][1]['Destination']['ArrTime'] : $result['Segments'][1][0]['Destination']['ArrTime'];
$Currency = $result['Fare']['Currency'];
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = '';
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($arrCommonInsVariables['strTraceId']) ? $arrCommonInsVariables['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = isset($this->InfoSourceSysId) ? $this->InfoSourceSysId : '0';
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = $OriginDepTime;
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = $DestinationArrTime;
$arrInsertFlightData['IsDirect'] = 0;
$arrInsertFlightData['FareClass'] = '';
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = '0';
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
$arrInsertFlightData['DestAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = '0';
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = 0;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$arrInsertFlightData['PublishedFare'] = isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '';
$arrInsertFlightData['CommissionEarned'] = isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '';
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = '0';
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['CreatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $this->intLoggedinUserId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$intFlightParentRecordId = $objFlight->addFlightDetails($arrInsertFlightData);
// Master Entry Ends...
// Master Fare Details...
$arrFairRules = array(
"TBOAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"BaseFare" => isset($result['Fare']['BaseFare']) ? $result['Fare']['BaseFare'] : 0,
"Tax" => isset($result['Fare']['Tax']) ? $result['Fare']['Tax'] : 0,
"YQTax" => isset($result['Fare']['YQTax']) ? $result['Fare']['YQTax'] : 0,
"AdditionalTxnFeeOfrd" => isset($result['Fare']['AdditionalTxnFeeOfrd']) ? $result['Fare']['AdditionalTxnFeeOfrd'] : 0,
"AdditionalTxnFeePub" => isset($result['Fare']['AdditionalTxnFeePub']) ? $result['Fare']['AdditionalTxnFeePub'] : 0,
"OtherCharges" => isset($result['Fare']['OtherCharges']) ? $result['Fare']['OtherCharges'] : 0,
"Discount" => isset($result['Fare']['Discount']) ? $result['Fare']['Discount'] : 0,
"ServiceFee" => isset($result['Fare']['ServiceFee']) ? $result['Fare']['ServiceFee'] : 0,
"PublishedFare" => isset($result['Fare']['PublishedFare']) ? $result['Fare']['PublishedFare'] : 0,
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : 0,
"PLBEarned" => isset($result['Fare']['PLBEarned']) ? $result['Fare']['PLBEarned'] : 0,
"IncentiveEarned" => isset($result['Fare']['IncentiveEarned']) ? $result['Fare']['IncentiveEarned'] : 0,
"OfferedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : 0,
"TdsOnCommission" => isset($result['Fare']['TdsOnCommission']) ? $result['Fare']['TdsOnCommission'] : 0,
"TdsOnPLB" => isset($result['Fare']['TdsOnPLB']) ? $result['Fare']['TdsOnPLB'] : 0,
"TdsOnIncentive" => isset($result['Fare']['TdsOnIncentive']) ? $result['Fare']['TdsOnIncentive'] : 0,
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDel" => 0
);
$objFlight->addFlightFairRuleDetails($arrFairRules);
// Master Fare Details Ends...
// FareBreakdown Details...
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
// FareBreakdown Details Ends...
// // InOutBound/InBound Flights Data...
$arrInsertFlightData = array();
$intSegments = 1;
foreach ($result['Segments'] as $segmentsResult) {
$arrFirstSegments = current($segmentsResult);
$arrLastSegments = end($segmentsResult);
$FlyingMinutesOutBound = 0;
$FlyingMinutesInBound = 0;
foreach ($segmentsResult as $arrSegmentsRes) {
$TripIndicator = isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0';
$Duration = isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0';
$GroundTime = isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0';
if ($TripIndicator == 1) {
$FlyingMinutesOutBound += ($Duration + $GroundTime);
} else {
$FlyingMinutesInBound += ($Duration + $GroundTime);
}
}
$OriginDepTime = isset($arrFirstSegments['Origin']['DepTime']) ? $arrFirstSegments['Origin']['DepTime'] : '';
$DestinationArrTime = isset($arrLastSegments['Destination']['ArrTime']) ? $arrLastSegments['Destination']['ArrTime'] : '';
$AirlineCode = isset($arrFirstSegments['Airline']['AirlineCode']) ? $arrFirstSegments['Airline']['AirlineCode'] : '';
$AirlineName = isset($arrFirstSegments['Airline']['AirlineName']) ? $arrFirstSegments['Airline']['AirlineName'] : '';
$FlightNumber = isset($arrFirstSegments['Airline']['FlightNumber']) ? $arrFirstSegments['Airline']['FlightNumber'] : '';
// $FlyingMinutesOutBound = isset($arrFirstSegments['Duration'])?$arrFirstSegments['Duration']:'';
// $FlyingMinutesInBound = isset($arrLastSegments['Duration'])?$arrLastSegments['Duration']:'';
$NoOfSeatAvailableOutBound = isset($arrFirstSegments['NoOfSeatAvailable']) ? $arrFirstSegments['NoOfSeatAvailable'] : '0';
$NoOfSeatAvailableInBound = isset($arrLastSegments['NoOfSeatAvailable']) ? $arrLastSegments['NoOfSeatAvailable'] : '0';
$SourceAirportCode = isset($arrFirstSegments['Origin']['Airport']['AirportCode']) ? $arrFirstSegments['Origin']['Airport']['AirportCode'] : '';
$DestAirportCode = isset($arrLastSegments['Destination']['Airport']['AirportCode']) ? $arrLastSegments['Destination']['Airport']['AirportCode'] : '';
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
$FareClass = isset($arrFirstSegments['Airline']['FareClass']) ? $arrFirstSegments['Airline']['FareClass'] : '';
if (count($segmentsResult) > 1) {
$IsDirect = 0;
$StopCount = count($segmentsResult) - 1;
} else {
$IsDirect = 1;
$StopCount = 0;
}
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = $intFlightParentRecordId;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($arrCommonInsVariables['strTraceId']) ? $arrCommonInsVariables['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = isset($this->InfoSourceSysId) ? $this->InfoSourceSysId : '0';
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = $OriginDepTime;
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = $DestinationArrTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $FareClass;
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = ($intSegments > 1) ? $FlyingMinutesInBound : $FlyingMinutesOutBound;
if ($intSegments > 1) {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
} else {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
}
$arrInsertFlightData['SourceAirportCode'] = $SourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $DestAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = ($intSegments > 1) ? $NoOfSeatAvailableInBound : $NoOfSeatAvailableOutBound;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$arrInsertFlightData['PublishedFare'] = isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '';
$arrInsertFlightData['CommissionEarned'] = isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '';
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = ($intSegments > 1) ? 2 : 1;
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['CreatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $this->intLoggedinUserId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
// echo '<pre>';
// print_r($arrInsertFlightData);
// echo '</pre>';
$intFlightChildRecordId = $objFlight->addFlightDetails($arrInsertFlightData);
$intSegments++;
if (!empty($segmentsResult)) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
// FOR FLIGHT SEGMENTS.....
$arrSegments = array(
"AirInvenAPISysId" => $intFlightChildRecordId,
"TripIndicator" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Baggage" => isset($arrSegmentsRes['Baggage']) ? $arrSegmentsRes['Baggage'] : '',
"CabinBaggage" => isset($arrSegmentsRes['CabinBaggage']) ? $arrSegmentsRes['CabinBaggage'] : '',
"SegmentIndicator" => isset($arrSegmentsRes['SegmentIndicator']) ? $arrSegmentsRes['SegmentIndicator'] : '0',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"Duration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0',
"GroundTime" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Mile" => isset($arrSegmentsRes['Mile']) ? $arrSegmentsRes['Mile'] : '0',
"StopOver" => isset($arrSegmentsRes['StopOver']) ? $arrSegmentsRes['StopOver'] : '0',
"StopPoint" => isset($arrSegmentsRes['StopPoint']) ? $arrSegmentsRes['StopPoint'] : '0',
"StopPointArrivalTime" => isset($arrSegmentsRes['StopPointArrivalTime']) ? $arrSegmentsRes['StopPointArrivalTime'] : '0',
"Craft" => isset($arrSegmentsRes['Craft']) ? $arrSegmentsRes['Craft'] : '',
"Remark" => isset($arrSegmentsRes['Remark']) ? $arrSegmentsRes['Remark'] : '',
"IsETicketEligible" => isset($arrSegmentsRes['IsETicketEligible']) ? $arrSegmentsRes['IsETicketEligible'] : '0',
"FlightStatus" => isset($arrSegmentsRes['FlightStatus']) ? $arrSegmentsRes['FlightStatus'] : '',
"Status" => isset($arrSegmentsRes['Status']) ? $arrSegmentsRes['Status'] : ''
);
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
}
}
if (count($segmentsResult) > 1) {
$Sequance = 1;
// $tempFlightNumber = "";
// $IsFlightChange = 0;
// $AirInvenSysId = "";
foreach ($segmentsResult as $arrSegmentsRes) {
$FlightNumber = isset($arrSegmentsRes['Airline']['FlightNumber']) ? $arrSegmentsRes['Airline']['FlightNumber'] : 0;
/* if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = 0;
}
$tempFlightNumber = $FlightNumber;
*/
$originAirportCode = $arrSegmentsRes['Origin']['Airport']['AirportCode'];
$destinationAirportCode = $arrSegmentsRes['Destination']['Airport']['AirportCode'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0';
$GroundTime = isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0';
$FlightDuration = $Duration + $GroundTime;
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $intFlightChildRecordId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"DestPlaceSysId" => $DestPlaceSysId,
"Sequance" => $Sequance,
"StayDuration" => isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '',
"FlightDuration" => $FlightDuration,
"AirlineCode" => isset($arrSegmentsRes['Airline']['AirlineCode']) ? $arrSegmentsRes['Airline']['AirlineCode'] : '',
"AirlineName" => isset($arrSegmentsRes['Airline']['AirlineName']) ? $arrSegmentsRes['Airline']['AirlineName'] : '',
"FlightNumber" => isset($arrSegmentsRes['Airline']['FlightNumber']) ? $arrSegmentsRes['Airline']['FlightNumber'] : '',
"FareClass" => isset($arrSegmentsRes['Airline']['FareClass']) ? $arrSegmentsRes['Airline']['FareClass'] : '',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestinationAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"IsFlightChange" => 0,
"NewFInvenSysId" => 0, //!empty($NewFInvenSysId)?$NewFInvenSysId:0,
"DepartureTime" => isset($arrSegmentsRes['Destination']['ArrTime']) ? $arrSegmentsRes['Destination']['ArrTime'] : '',
"ArrivalTime" => isset($arrSegmentsRes['Origin']['DepTime']) ? $arrSegmentsRes['Origin']['DepTime'] : '',
"HaultInclusions" => '',
"NoOfSeatAvailable" => isset($arrSegmentsRes['NoOfSeatAvailable']) ? $arrSegmentsRes['NoOfSeatAvailable'] : '',
"CurrencyType" => isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PublishedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '',
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '',
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDelete" => 0
);
//echo "<pre>";print_r($arrFlightStopsInsert);exit;
$AirStopInvenSysId = $objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$AirInvenSysId = $AirStopInvenSysId;
$Sequance++;
}
}
}
// InOutBound/InBound Flights Data Ends...
}
} // Foreach ends
// exit;
}
}
public function insertInterNationalFlightAction_BKP($data, $arrCommonInsVariables) {
if (!empty($data)) {
//echo "<pre>";print_r($data);
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
//echo "<pre>";print_r($data);exit;
foreach ($data as $result) {
$Currency = $result['Fare']['Currency'];
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"BaseFare" => isset($result['Fare']['BaseFare']) ? $result['Fare']['BaseFare'] : '0',
"Tax" => isset($result['Fare']['Tax']) ? $result['Fare']['Tax'] : '0',
"YQTax" => isset($result['Fare']['YQTax']) ? $result['Fare']['YQTax'] : '0',
"AdditionalTxnFeeOfrd" => isset($result['Fare']['AdditionalTxnFeeOfrd']) ? $result['Fare']['AdditionalTxnFeeOfrd'] : '0',
"AdditionalTxnFeePub" => isset($result['Fare']['AdditionalTxnFeePub']) ? $result['Fare']['AdditionalTxnFeePub'] : '0',
"OtherCharges" => isset($result['Fare']['OtherCharges']) ? $result['Fare']['OtherCharges'] : '0',
"Discount" => isset($result['Fare']['Discount']) ? $result['Fare']['Discount'] : '0',
"ServiceFee" => isset($result['Fare']['ServiceFee']) ? $result['Fare']['ServiceFee'] : '0',
"PublishedFare" => isset($result['Fare']['PublishedFare']) ? $result['Fare']['PublishedFare'] : '0',
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '0',
"PLBEarned" => isset($result['Fare']['PLBEarned']) ? $result['Fare']['PLBEarned'] : '0',
"IncentiveEarned" => isset($result['Fare']['IncentiveEarned']) ? $result['Fare']['IncentiveEarned'] : '0',
"OfferedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '0',
"TdsOnCommission" => isset($result['Fare']['TdsOnCommission']) ? $result['Fare']['TdsOnCommission'] : '0',
"TdsOnPLB" => isset($result['Fare']['TdsOnPLB']) ? $result['Fare']['TdsOnPLB'] : '0',
"TdsOnIncentive" => isset($result['Fare']['TdsOnIncentive']) ? $result['Fare']['TdsOnIncentive'] : '0',
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDel" => 0
);
//$FlyingMinutes = 0;
$intSegments = 0;
$intParentOutBoundFlightId = 0;
//echo "<pre>";print_r($result['Segments']);exit;
foreach ($result['Segments'] as $segmentsResult) {
//echo "<pre>";print_r($segmentsResult);exit;
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$AirlineCode = isset($segmentsResult[0]['Airline']['AirlineCode']) ? $segmentsResult[0]['Airline']['AirlineCode'] : '';
$FlightNumber = isset($segmentsResult[0]['Airline']['FlightNumber']) ? $segmentsResult[0]['Airline']['FlightNumber'] : '';
$strFlightNumber = $AirlineCode . "-" . $FlightNumber;
if (!empty($segmentsResult)) {
$IsDirect = 0;
$StopCount = count($segmentsResult) - 1;
} else {
$IsDirect = 1;
$StopCount = 0;
}
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = $intParentOutBoundFlightId;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($arrCommonInsVariables['strTraceId']) ? $arrCommonInsVariables['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = isset($this->InfoSourceSysId) ? $this->InfoSourceSysId : '0';
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = isset($segmentsResult[0]['Origin']['DepTime']) ? $segmentsResult[0]['Origin']['DepTime'] : '';
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = isset($segmentsResult[1]['Destination']['ArrTime']) ? $segmentsResult[1]['Destination']['ArrTime'] : $segmentsResult[0]['Destination']['ArrTime'];
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = isset($segmentsResult[0]['Airline']['FareClass']) ? $segmentsResult[0]['Airline']['FareClass'] : '';
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
if ($intSegments > 0) {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['SourceAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
$arrInsertFlightData['DestAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
} else {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
$arrInsertFlightData['DestAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
}
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = isset($segmentsResult[0]['NoOfSeatAvailable']) ? $segmentsResult[0]['NoOfSeatAvailable'] : 0;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$arrInsertFlightData['PublishedFare'] = isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '';
$arrInsertFlightData['CommissionEarned'] = isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '';
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = ($intSegments > 1) ? 2 : 1;
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['CreatedByISSysId'] = $this->intLoggedinUserId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $this->intLoggedinUserId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$intParentOutBoundFlightId = $intFlightLastInsertId;
// FOR FLIGHT FAIR-RULES.....
$arrFairRules['TBOAirInvenAPISysId'] = $intFlightLastInsertId;
$objFlight->addFlightFairRuleDetails($arrFairRules);
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightLastInsertId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
if (!empty($segmentsResult)) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
// FOR FLIGHT SEGMENTS.....
//echo "<pre>";print_r($arrSegmentsRes);exit;
$arrSegments = array(
"AirInvenAPISysId" => $intFlightLastInsertId,
"TripIndicator" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Baggage" => isset($arrSegmentsRes['Baggage']) ? $arrSegmentsRes['Baggage'] : '',
"CabinBaggage" => isset($arrSegmentsRes['CabinBaggage']) ? $arrSegmentsRes['CabinBaggage'] : '',
"SegmentIndicator" => isset($arrSegmentsRes['SegmentIndicator']) ? $arrSegmentsRes['SegmentIndicator'] : '0',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"Duration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0',
"GroundTime" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Mile" => isset($arrSegmentsRes['Mile']) ? $arrSegmentsRes['Mile'] : '0',
"StopOver" => isset($arrSegmentsRes['StopOver']) ? $arrSegmentsRes['StopOver'] : '0',
"StopPoint" => isset($arrSegmentsRes['StopPoint']) ? $arrSegmentsRes['StopPoint'] : '0',
"StopPointArrivalTime" => isset($arrSegmentsRes['StopPointArrivalTime']) ? $arrSegmentsRes['StopPointArrivalTime'] : '0',
"Craft" => isset($arrSegmentsRes['Craft']) ? $arrSegmentsRes['Craft'] : '',
"Remark" => isset($arrSegmentsRes['Remark']) ? $arrSegmentsRes['Remark'] : '',
"IsETicketEligible" => isset($arrSegmentsRes['IsETicketEligible']) ? $arrSegmentsRes['IsETicketEligible'] : '0',
"FlightStatus" => isset($arrSegmentsRes['FlightStatus']) ? $arrSegmentsRes['FlightStatus'] : '',
"Status" => isset($arrSegmentsRes['Status']) ? $arrSegmentsRes['Status'] : ''
);
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
}
}
if (count($segmentsResult) > 1) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = !empty($AirInvenSysId) ? $AirInvenSysId : 0;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = !empty($AirInvenSysId) ? $AirInvenSysId : 0;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '0';
}
$tempFlightNumber = $FlightNumber;
$originAirportCode = $arrSegmentsRes['Origin']['Airport']['AirportCode'];
$destinationAirportCode = $arrSegmentsRes['Destination']['Airport']['AirportCode'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $intFlightLastInsertId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"DestPlaceSysId" => $DestPlaceSysId,
"Sequance" => $Sequance,
"StayDuration" => isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '',
"FlightDuration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '',
"AirlineCode" => isset($arrSegmentsRes['Airline']['AirlineCode']) ? $arrSegmentsRes['Airline']['AirlineCode'] : '',
"AirlineName" => isset($arrSegmentsRes['Airline']['AirlineName']) ? $arrSegmentsRes['Airline']['AirlineName'] : '',
"FlightNumber" => isset($arrSegmentsRes['Airline']['FlightNumber']) ? $arrSegmentsRes['Airline']['FlightNumber'] : '',
"FareClass" => isset($arrSegmentsRes['Airline']['FareClass']) ? $arrSegmentsRes['Airline']['FareClass'] : '',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestinationAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => !empty($NewFInvenSysId) ? $NewFInvenSysId : 0,
"DepartureTime" => isset($arrSegmentsRes['Destination']['ArrTime']) ? $arrSegmentsRes['Destination']['ArrTime'] : '',
"ArrivalTime" => isset($arrSegmentsRes['Origin']['DepTime']) ? $arrSegmentsRes['Origin']['DepTime'] : '',
"HaultInclusions" => '',
"NoOfSeatAvailable" => isset($arrSegmentsRes['NoOfSeatAvailable']) ? $arrSegmentsRes['NoOfSeatAvailable'] : '',
"CurrencyType" => isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PublishedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : '',
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : '',
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDelete" => 0
);
//echo "<pre>";print_r($arrFlightStopsInsert);exit;
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$Sequance++;
}
}
// $AirInvenSysId = $intFlightLastInsertId;
//echo "<pre>";print_r($arrFlightStopsInsert);
$intSegments++;
}
//exit;
} // Foreach ends
// exit;
}
}
public function searchResultFromPkgAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$pkgformdata = $this->getRequest()->getPost();
$tpitenarysysID = $pkgformdata['tpintsysID'];
$this->view->tpitenarysysID = $tpitenarysysID;
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
//$this->_helper->layout->disableLayout();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$objAirport = new Travel_Model_TblAirport();
/* Common Variable For API Call */
$tokenId = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->authenticateAPI();
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
if ($strFlightRoute == '1') {
$strTripType = 'OneWayTrip';
} else {
$strTripType = 'RoundTrip';
}
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDepatureDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$origin = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$preferredDepartureTime = $sessionFlightSearchParams->params['departure_dates'];
$preferredArrivalTime = $sessionFlightSearchParams->params['departure_dates'];
$preferredDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredDepartureTime, 'd/m/y') . "T00:00:00";
$preferredArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredArrivalTime, 'd/m/y') . "T00:00:00";
$strReturnOrigin = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$strReturnDestination = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$preferredReturnDepartureTime = $sessionFlightSearchParams->params['return_dates'];
$preferredReturnArrivalTime = $sessionFlightSearchParams->params['return_dates'];
$preferredReturnDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredReturnDepartureTime, 'd/m/y');
$preferredReturnArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredReturnArrivalTime, 'd/m/y');
$preferredFlightClassType = $sessionFlightSearchParams->params['flight_class'];
$this->view->oneWayDestinationCityName = $sessionFlightSearchParams->params['oneWayDestinationCityName'];
$strApiEndPointUrl = 'http://api.tektravels.com/BookingEngineService_Air/AirService.svc/rest/Search/';
/* Common Variable For API Call */
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDepatureDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDepatureDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDepatureDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$FromUTCTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$ToUTCTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$objAirport->strAirportCode = $strSourceAirportCode;
$arrSourceCityId = $objAirport->getAirportList();
$intSourceCityId = $arrSourceCityId[0]['CityId'];
$objAirport->strAirportCode = $strDestinationAirportCode;
$arrDestinationCityId = $objAirport->getAirportList();
$intDestinationCityId = $arrDestinationCityId[0]['CityId'];
if (!empty($sessionFlightSearchParams->params)) {
// Database lookup for flights...
$objFlight = new Travel_Model_TblFlight();
$objFlight2 = new Travel_Model_TblFlight();
$objFlight->strCondition = "";
$objFlight2->strCondition = "";
if ($strFlightRoute == '2') {
if (!empty($strDepatureDate) && !empty($strReturnDepatureDate)) { // swap Ids in case of two way.....
$objFlight->strCondition .= " AND t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
$objFlight2->strCondition .= " AND ( t1.SourcePlaceSysId = '" . $intDestinationCityId . "' OR t1.DestPlaceSysId = '" . $intSourceCityId . "' ) ";
}
} else {
if (!empty($intSourceCityId) && !empty($intDestinationCityId)) {
$objFlight->strCondition .= " AND t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
}
}
if ($strFlightRoute == '2') {
if (!empty($strDepatureDate) && !empty($strReturnDepatureDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strDepatureDate . "'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strReturnDepatureDate . "'";
//$objFlight->strCondition .= " AND ( SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '".$strDepatureDate."' OR SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '".$strReturnDepatureDate."' )";
}
} else {
if (!empty($strDepatureDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strDepatureDate . "'";
}
}
if (!empty($strTripType)) {
$objFlight->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight->strSelectedView = "count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResult = $objFlight->getFlightSearchList();
$intPageNumber = !empty($this->getRequest()->getPost('page')) ? $this->getRequest()->getPost('page') : '1';
$intLimitPerPage = '5';
// Database lookup for flights...
if ($arrSearchFlightResult['total'] > 0) {
// rendering to the respective view according to search type.....
if ($strFlightRoute == '1') {
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
if (empty($arrAirlines) && empty($arrAirStops) && empty($arrFlightTime) && empty($arrFlightPrice)) {
/* For Airline Filters Purpose only */
$sessionFlightSearchResult = new Zend_Session_Namespace('sessionFlightSearchResult');
$sessionFlightSearchResult->params = $arrSearchFlightResult;
/* For Airline Filters Purpose only */
}
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$this->render('all-airlines-pkg-db');
//echo $getsource;
} else if ($strFlightRoute == '2') {
// Single trip
//$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition .= " AND t1.JourneyType = '1'";
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
if (empty($arrAirlines) && empty($arrAirStops) && empty($arrFlightTime) && empty($arrFlightPrice)) {
/* For Airline Filters Purpose only */
$sessionFlightSearchResult = new Zend_Session_Namespace('sessionFlightSearchResult');
$sessionFlightSearchResult->params = $arrSearchFlightResult;
/* For Airline Filters Purpose only */
}
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchSingleTrip = $arrSearchFlightResult;
// Round trip Starts
$intPageNumber2 = !empty($this->getRequest()->getPost('page2')) ? $this->getRequest()->getPost('page2') : '1';
if (!empty($strTripType)) {
$objFlight2->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight2->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight2->strCondition .= " AND t1.JourneyType = '2'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight2->strSelectedView = "list";
$arrSearchFlightResult = $objFlight2->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber2);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchRoundTrip = $arrSearchFlightResult;
$this->render('twoway-all-pkg-airlines');
} else {
$this->render('all-airlines-pkg-db');
}
} else { // API lookup for flights...
if ($strFlightRoute == '1') { // OneWay [ Return ] flight Search
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "1",
"PreferredAirlines" => NULL,
"Segments" => [array(
'Origin' => $origin, 'Destination' => $destination, 'FlightCabinClass' => $preferredFlightClassType, "PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
)],
"Sources" => NULL
);
} else { // TwoWay [ Return ] flight Search
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "2",
"ReturnDate" => $preferredDepartureTime,
"PreferredAirlines" => NULL,
"Segments" => [
array(
'Origin' => $origin,
'Destination' => $destination,
'FlightCabinClass' => $preferredFlightClassType,
"PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
),
array(
'Origin' => $strReturnOrigin,
'Destination' => $strReturnDestination,
'FlightCabinClass' => $preferredFlightClassType,
'PreferredDepartureTime' => $preferredReturnDepartureTime,
'PreferredArrivalTime' => $preferredReturnArrivalTime
)
],
"Sources" => NULL
);
}
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strApiEndPointUrl);
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, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
//'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// Fix Values.....
$ICSourceSysId = $this->InfoSourceSysId;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
$strApiResponseStatus = $response['Response']['ResponseStatus'];
$strTraceId = $response['Response']['TraceId'];
if (!empty($strApiResponseStatus) && $strApiResponseStatus == '1') {
$arrApiResponseResults = $response['Response']['Results'];
if (!empty($arrApiResponseResults)) {
$intJourneyType = 1;
foreach ($arrApiResponseResults as $responseResult) {
foreach ($responseResult as $apiResult) {
$ResultIndex = $apiResult['ResultIndex'];
$Source = $apiResult['Source'];
$IsLCC = $apiResult['IsLCC'];
$IsRefundable = $apiResult['IsRefundable'];
$AirlineRemark = $apiResult['AirlineRemark'];
$LastTicketDate = $apiResult['LastTicketDate'];
$TicketAdvisory = $apiResult['TicketAdvisory'];
$AirlineCode = $apiResult['AirlineCode'];
$ValidatingAirline = $apiResult['ValidatingAirline'];
// Fare
$Currency = $apiResult['Fare']['Currency'];
$objCurrency = new Travel_Model_TblCurrency();
$objCurrency->strCurrencySymbol = $Currency;
$arrCurrencyTypes = $objCurrency->getCurrencyTypes();
if (!empty($arrCurrencyTypes)) {
$intCurrencyType = $arrCurrencyTypes[0]['CurrencyType'];
} else {
$intCurrencyType = '';
}
$BaseFare = $apiResult['Fare']['BaseFare'];
$Tax = $apiResult['Fare']['Tax'];
$intCalculatedBaseFare = round($BaseFare + $Tax);
$YQTax = $apiResult['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $apiResult['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $apiResult['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $apiResult['Fare']['OtherCharges'];
$Discount = $apiResult['Fare']['Discount'];
$PublishedFare = $apiResult['Fare']['PublishedFare'];
$CommissionEarned = $apiResult['Fare']['CommissionEarned'];
$PLBEarned = $apiResult['Fare']['PLBEarned'];
$IncentiveEarned = $apiResult['Fare']['IncentiveEarned'];
$OfferedFare = $apiResult['Fare']['OfferedFare'];
$TdsOnCommission = $apiResult['Fare']['TdsOnCommission'];
$TdsOnPLB = $apiResult['Fare']['TdsOnPLB'];
$TdsOnIncentive = $apiResult['Fare']['TdsOnIncentive'];
$ServiceFee = $apiResult['Fare']['ServiceFee'];
// Fare
if (!empty($AirlineCode)) {
$objAirline = new Travel_Model_TblAirline();
$objAirline->strAlineCode = $AirlineCode;
$arrAirlineResult = $objAirline->getAirlineList();
}
$airline_id = isset($arrAirlineResult[0]['AirlineSysId']) ? $arrAirlineResult[0]['AirlineSysId'] : '0';
$IsDirect = isset($post['IsDirect']) ? $post['IsDirect'] : '0';
$FlyingMinutes = '';
$StopCount = '0';
$Stops = isset($post['Stops']) ? json_encode($post['Stops']) : ''; //isset($post['Stops']) ? $post['Stops'] : '';
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = '';
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airline_id;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $FromUTCTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $ToUTCTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
if ($intJourneyType == '1') {
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
} else if ($intJourneyType == '2') { // just swap the destination and source city ids for return flight
$arrInsertFlightData['SourcePlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['SourceAirportCode'] = $strReturnOrigin;
$arrInsertFlightData['DestAirportCode'] = $strReturnDestination;
}
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = $Stops;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $intCurrencyType;
$arrInsertFlightData['PublishedFare'] = $intCalculatedBaseFare;
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData['JourneyType'] = $intJourneyType;
$arrInsertFlightData['TripType'] = $strTripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
//Segments
$tempFlightNumber = "";
$IsFlightChange = 0;
//$changedFlightNumber = "";
$intSegmentsCount = 0;
$StopCount = count($apiResult['Segments'][0]) - 1;
$FlyingMinutes = 0;
$firstFlightNumber = '';
foreach ($apiResult['Segments'][0] as $segmentsResult) {
$arrFareBreakdown = @$apiResult['FareBreakdown'][$intSegmentsCount];
$Currency = $arrFareBreakdown['Currency'];
$objCurrency = new Travel_Model_TblCurrency();
$objCurrency->strCurrencySymbol = $Currency;
$arrCurrencyTypes = $objCurrency->getCurrencyTypes();
if (!empty($arrCurrencyTypes)) {
$intCurrencyType = $arrCurrencyTypes[0]['CurrencyType'];
} else {
$intCurrencyType = '';
}
$strBaseFare = $arrFareBreakdown['BaseFare'];
$strTax = $arrFareBreakdown['Tax'];
$intPassengerCount = $arrFareBreakdown['PassengerCount'];
if ($intPassengerCount > 0) {
$intFareBreakdownPerPax = round($strBaseFare + $strTax) / $intPassengerCount;
} else {
$intFareBreakdownPerPax = round($strBaseFare + $strTax);
}
//
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
if ($firstFlightNumber == "") {
$firstFlightNumber = $FlightNumber;
}
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
}
$tempFlightNumber = $FlightNumber;
/* if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
} */
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$objAirport->strAirportCode = $originAirportCode;
$arrSourceCityId = $objAirport->getAirportList();
if (count($arrSourceCityId) > 0 && !empty($arrSourceCityId)) {
$SourcePlaceSysId = !empty($arrSourceCityId[0]['CityId']) ? $arrSourceCityId[0]['CityId'] : $intSourceCityId;
} else {
$SourcePlaceSysId = $intSourceCityId;
}
$objAirport->strAirportCode = $destinationAirportCode;
$arrDestinationCityId = $objAirport->getAirportList();
if (count($arrDestinationCityId) > 0 && !empty($arrDestinationCityId)) {
$DestPlaceSysId = !empty($arrDestinationCityId[0]['CityId']) ? $arrDestinationCityId[0]['CityId'] : $intDestinationCityId;
} else {
$DestPlaceSysId = $intDestinationCityId;
}
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $AirInvenSysId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"Sequance" => $SegmentIndicator,
"DestPlaceSysId" => $DestPlaceSysId,
"StayDuration" => $GroundTime,
"FlightDuration" => $Duration,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FlightNumber" => $FlightNumber,
"FareClass" => $FareClass,
"OriginAirportCode" => $originAirportCode,
"DestinationAirportCode" => $destinationAirportCode,
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => $NewFInvenSysId,
"ArrivalTime" => $destinationArrTime,
"DepartureTime" => $originDepTime,
"HaultInclusions" => '',
"CurrencyType" => $intCurrencyType,
"PublishedFare" => $intFareBreakdownPerPax,
//"CommissionEarned" => '',
"CreateDate" => $CreateDate,
"UpdateDate" => $UpdateDate,
"IsActive" => $IsActive,
"IsMarkForDelete" => $IsMarkForDel
);
// echo "<pre>";
// print_r($arrFlightStopsInsert); exit;
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$intSegmentsCount++;
}
$arrUpdateFlight = array();
$arrUpdateFlight['FlightNumber'] = trim($AirlineCode) . trim($firstFlightNumber);
$arrUpdateFlight['StopCount'] = $StopCount;
if ($StopCount > 0) {
$arrUpdateFlight['IsDirect'] = '0';
} else {
$arrUpdateFlight['IsDirect'] = '1';
}
$arrUpdateFlight['FlyingMinutes'] = $FlyingMinutes;
// echo "<pre>";
// print_r($arrUpdateFlight);
$objFlight->updateApiFlightDetails($AirInvenSysId, $arrUpdateFlight);
}
$intJourneyType++;
} //exit;
}
} else {
$this->view->ErrorCode = $response['Response']['Error']['ErrorCode'];
$this->view->ErrorMessage = $response['Response']['Error']['ErrorMessage'];
}
// rendering to the respective view according to search type.....
if ($strFlightRoute == '1') {
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
//$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$this->render('all-airlines-pkg-db');
} else if ($strFlightRoute == '2') {
// Single trip
//$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition .= " AND t1.JourneyType = '1'";
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchSingleTrip = $arrSearchFlightResult;
// Round trip Starts
$intPageNumber2 = !empty($this->getRequest()->getPost('page2')) ? $this->getRequest()->getPost('page2') : '1';
if (!empty($strTripType)) {
$objFlight2->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight2->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight2->strCondition .= " AND t1.JourneyType = '2'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight2->strSelectedView = "list";
$arrSearchFlightResult = $objFlight2->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber2);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchRoundTrip = $arrSearchFlightResult;
$this->render('twoway-all-pkg-airlines');
} else {
$this->render('all-airlines-pkg-db');
}
}
}
}
}
public function searchResultFromInventoryAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$pkgformdata = $this->getRequest()->getPost();
$tpitenarysysID = $pkgformdata['tpintsysID'];
$this->view->tpitenarysysID = $tpitenarysysID;
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
//$this->_helper->layout->disableLayout();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$objAirport = new Travel_Model_TblAirport();
/* Common Variable For API Call */
$tokenId = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->authenticateAPI();
$strFlightRoute = trim($sessionFlightSearchParams->params['route']);
if ($strFlightRoute == '1') {
$strTripType = 'OneWayTrip';
} else {
$strTripType = 'RoundTrip';
}
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$strDepatureDate = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDepatureDate = !empty($sessionFlightSearchParams->params['return_dates']) ? $sessionFlightSearchParams->params['return_dates'] : '';
$adultCount = $sessionFlightSearchParams->params['adults'];
$childCount = $sessionFlightSearchParams->params['child'];
$infantCount = $sessionFlightSearchParams->params['infant'];
$intMemberCount = $adultCount + $childCount + $infantCount;
$origin = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destination = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$preferredDepartureTime = $sessionFlightSearchParams->params['departure_dates'];
$preferredArrivalTime = $sessionFlightSearchParams->params['departure_dates'];
$preferredDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredDepartureTime, 'd/m/y') . "T00:00:00";
$preferredArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredArrivalTime, 'd/m/y') . "T00:00:00";
$strReturnOrigin = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$strReturnDestination = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$preferredReturnDepartureTime = $sessionFlightSearchParams->params['return_dates'];
$preferredReturnArrivalTime = $sessionFlightSearchParams->params['return_dates'];
$preferredReturnDepartureTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredReturnDepartureTime, 'd/m/y');
$preferredReturnArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($preferredReturnArrivalTime, 'd/m/y');
$preferredFlightClassType = $sessionFlightSearchParams->params['flight_class'];
$this->view->oneWayDestinationCityName = $sessionFlightSearchParams->params['oneWayDestinationCityName'];
$strApiEndPointUrl = 'http://api.tektravels.com/BookingEngineService_Air/AirService.svc/rest/Search/';
/* Common Variable For API Call */
$arrDepatureDate = explode("/", $strDepatureDate);
if (!empty($arrDepatureDate)) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
if (!empty($strReturnDepatureDate)) {
$arrReturnDepatureDate = explode("/", $strReturnDepatureDate);
if (!empty($arrReturnDepatureDate)) {
$strReturnDepatureDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
$localFromDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$FromUTCTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$ToUTCTime = date("Y-m-d h:i", strtotime($strDepatureDate));
$objAirport->strAirportCode = $strSourceAirportCode;
$arrSourceCityId = $objAirport->getAirportList();
$intSourceCityId = $arrSourceCityId[0]['CityId'];
$objAirport->strAirportCode = $strDestinationAirportCode;
$arrDestinationCityId = $objAirport->getAirportList();
$intDestinationCityId = $arrDestinationCityId[0]['CityId'];
if (!empty($sessionFlightSearchParams->params)) {
// Database lookup for flights...
$objFlight = new Travel_Model_TblFlight();
$objFlight2 = new Travel_Model_TblFlight();
$objFlight->strCondition = "";
$objFlight2->strCondition = "";
if ($strFlightRoute == '2') {
if (!empty($strDepatureDate) && !empty($strReturnDepatureDate)) { // swap Ids in case of two way.....
$objFlight->strCondition .= " AND t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
$objFlight2->strCondition .= " AND ( t1.SourcePlaceSysId = '" . $intDestinationCityId . "' OR t1.DestPlaceSysId = '" . $intSourceCityId . "' ) ";
}
} else {
if (!empty($intSourceCityId) && !empty($intDestinationCityId)) {
$objFlight->strCondition .= " AND t1.SourcePlaceSysId = '" . $intSourceCityId . "' AND t1.DestPlaceSysId = '" . $intDestinationCityId . "'";
}
}
if ($strFlightRoute == '2') {
if (!empty($strDepatureDate) && !empty($strReturnDepatureDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strDepatureDate . "'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strReturnDepatureDate . "'";
//$objFlight->strCondition .= " AND ( SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '".$strDepatureDate."' OR SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '".$strReturnDepatureDate."' )";
}
} else {
if (!empty($strDepatureDate)) {
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t2.DepartureTime, 120),0,11) = '" . $strDepatureDate . "'";
}
}
if (!empty($strTripType)) {
$objFlight->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight->strSelectedView = "count";
if (!empty($this->intLoggedinAgencyId)) {
$objFlight->AgencySysId = $this->intLoggedinAgencyId;
}
$arrSearchFlightResult = $objFlight->getFlightSearchList();
$intPageNumber = !empty($this->getRequest()->getPost('page')) ? $this->getRequest()->getPost('page') : '1';
$intLimitPerPage = '5';
// Database lookup for flights...
if ($arrSearchFlightResult['total'] > 0) {
// rendering to the respective view according to search type.....
if ($strFlightRoute == '1') {
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
if (empty($arrAirlines) && empty($arrAirStops) && empty($arrFlightTime) && empty($arrFlightPrice)) {
/* For Airline Filters Purpose only */
$sessionFlightSearchResult = new Zend_Session_Namespace('sessionFlightSearchResult');
$sessionFlightSearchResult->params = $arrSearchFlightResult;
/* For Airline Filters Purpose only */
}
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$this->render('all-airlines-pkg-inventory');
//echo $getsource;
} else if ($strFlightRoute == '2') {
// Single trip
//$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition .= " AND t1.JourneyType = '1'";
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
if (empty($arrAirlines) && empty($arrAirStops) && empty($arrFlightTime) && empty($arrFlightPrice)) {
/* For Airline Filters Purpose only */
$sessionFlightSearchResult = new Zend_Session_Namespace('sessionFlightSearchResult');
$sessionFlightSearchResult->params = $arrSearchFlightResult;
/* For Airline Filters Purpose only */
}
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchSingleTrip = $arrSearchFlightResult;
// Round trip Starts
$intPageNumber2 = !empty($this->getRequest()->getPost('page2')) ? $this->getRequest()->getPost('page2') : '1';
if (!empty($strTripType)) {
$objFlight2->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight2->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight2->strCondition .= " AND t1.JourneyType = '2'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight2->strSelectedView = "list";
$arrSearchFlightResult = $objFlight2->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber2);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchRoundTrip = $arrSearchFlightResult;
$this->render('twoway-all-inventory');
} else {
$this->render('all-airlines-pkg-inventory');
}
} else { // API lookup for flights...
if ($strFlightRoute == '1') { // OneWay [ Return ] flight Search
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "1",
"PreferredAirlines" => NULL,
"Segments" => [array(
'Origin' => $origin, 'Destination' => $destination, 'FlightCabinClass' => $preferredFlightClassType, "PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
)],
"Sources" => NULL
);
} else { // TwoWay [ Return ] flight Search
$datah = array(
'EndUserIp' => $_SERVER['REMOTE_ADDR'],
'TokenId' => $tokenId,
"AdultCount" => $adultCount,
"ChildCount" => $childCount,
"InfantCount" => $infantCount,
"DirectFlight" => "false",
"OneStopFlight" => "false",
"JourneyType" => "2",
"ReturnDate" => $preferredDepartureTime,
"PreferredAirlines" => NULL,
"Segments" => [
array(
'Origin' => $origin,
'Destination' => $destination,
'FlightCabinClass' => $preferredFlightClassType,
"PreferredDepartureTime" => $preferredDepartureTime,
'PreferredArrivalTime' => $preferredArrivalTime
),
array(
'Origin' => $strReturnOrigin,
'Destination' => $strReturnDestination,
'FlightCabinClass' => $preferredFlightClassType,
'PreferredDepartureTime' => $preferredReturnDepartureTime,
'PreferredArrivalTime' => $preferredReturnArrivalTime
)
],
"Sources" => NULL
);
}
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strApiEndPointUrl);
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, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
//'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// Fix Values.....
$ICSourceSysId = $this->InfoSourceSysId;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
$strApiResponseStatus = $response['Response']['ResponseStatus'];
$strTraceId = $response['Response']['TraceId'];
if (!empty($strApiResponseStatus) && $strApiResponseStatus == '1') {
$arrApiResponseResults = $response['Response']['Results'];
if (!empty($arrApiResponseResults) > 0) {
$intJourneyType = 1;
foreach ($arrApiResponseResults as $responseResult) {
foreach ($responseResult as $apiResult) {
$ResultIndex = $apiResult['ResultIndex'];
$Source = $apiResult['Source'];
$IsLCC = $apiResult['IsLCC'];
$IsRefundable = $apiResult['IsRefundable'];
$AirlineRemark = $apiResult['AirlineRemark'];
$LastTicketDate = $apiResult['LastTicketDate'];
$TicketAdvisory = $apiResult['TicketAdvisory'];
$AirlineCode = $apiResult['AirlineCode'];
$ValidatingAirline = $apiResult['ValidatingAirline'];
// Fare
$Currency = $apiResult['Fare']['Currency'];
$objCurrency = new Travel_Model_TblCurrency();
$objCurrency->strCurrencySymbol = $Currency;
$arrCurrencyTypes = $objCurrency->getCurrencyTypes();
if (!empty($arrCurrencyTypes)) {
$intCurrencyType = $arrCurrencyTypes[0]['CurrencyType'];
} else {
$intCurrencyType = '';
}
$BaseFare = $apiResult['Fare']['BaseFare'];
$Tax = $apiResult['Fare']['Tax'];
$intCalculatedBaseFare = round($BaseFare + $Tax);
$YQTax = $apiResult['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $apiResult['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $apiResult['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $apiResult['Fare']['OtherCharges'];
$Discount = $apiResult['Fare']['Discount'];
$PublishedFare = $apiResult['Fare']['PublishedFare'];
$CommissionEarned = $apiResult['Fare']['CommissionEarned'];
$PLBEarned = $apiResult['Fare']['PLBEarned'];
$IncentiveEarned = $apiResult['Fare']['IncentiveEarned'];
$OfferedFare = $apiResult['Fare']['OfferedFare'];
$TdsOnCommission = $apiResult['Fare']['TdsOnCommission'];
$TdsOnPLB = $apiResult['Fare']['TdsOnPLB'];
$TdsOnIncentive = $apiResult['Fare']['TdsOnIncentive'];
$ServiceFee = $apiResult['Fare']['ServiceFee'];
// Fare
if (!empty($AirlineCode)) {
$objAirline = new Travel_Model_TblAirline();
$objAirline->strAlineCode = $AirlineCode;
$arrAirlineResult = $objAirline->getAirlineList();
}
$airline_id = isset($arrAirlineResult[0]['AirlineSysId']) ? $arrAirlineResult[0]['AirlineSysId'] : '0';
$IsDirect = isset($post['IsDirect']) ? $post['IsDirect'] : '0';
$FlyingMinutes = '';
$StopCount = '0';
$Stops = isset($post['Stops']) ? json_encode($post['Stops']) : ''; //isset($post['Stops']) ? $post['Stops'] : '';
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = '';
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airline_id;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $FromUTCTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $ToUTCTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
if ($intJourneyType == '1') {
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
} else if ($intJourneyType == '2') { // just swap the destination and source city ids for return flight
$arrInsertFlightData['SourcePlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['SourceAirportCode'] = $strReturnOrigin;
$arrInsertFlightData['DestAirportCode'] = $strReturnDestination;
}
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = $Stops;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $intCurrencyType;
$arrInsertFlightData['PublishedFare'] = $intCalculatedBaseFare;
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $ResultIndex;
$arrInsertFlightData['JourneyType'] = $intJourneyType;
$arrInsertFlightData['TripType'] = $strTripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
//Segments
$tempFlightNumber = "";
$IsFlightChange = 0;
//$changedFlightNumber = "";
$intSegmentsCount = 0;
$StopCount = count($apiResult['Segments'][0]) - 1;
$FlyingMinutes = 0;
$firstFlightNumber = '';
foreach ($apiResult['Segments'][0] as $segmentsResult) {
$arrFareBreakdown = @$apiResult['FareBreakdown'][$intSegmentsCount];
$Currency = $arrFareBreakdown['Currency'];
$objCurrency = new Travel_Model_TblCurrency();
$objCurrency->strCurrencySymbol = $Currency;
$arrCurrencyTypes = $objCurrency->getCurrencyTypes();
if (!empty($arrCurrencyTypes)) {
$intCurrencyType = $arrCurrencyTypes[0]['CurrencyType'];
} else {
$intCurrencyType = '';
}
$strBaseFare = $arrFareBreakdown['BaseFare'];
$strTax = $arrFareBreakdown['Tax'];
$intPassengerCount = $arrFareBreakdown['PassengerCount'];
if ($intPassengerCount > 0) {
$intFareBreakdownPerPax = round($strBaseFare + $strTax) / $intPassengerCount;
} else {
$intFareBreakdownPerPax = round($strBaseFare + $strTax);
}
//
$TripIndicator = $segmentsResult['TripIndicator'];
$SegmentIndicator = $segmentsResult['SegmentIndicator'];
$FlightNumber = $segmentsResult['Airline']['FlightNumber'];
if ($firstFlightNumber == "") {
$firstFlightNumber = $FlightNumber;
}
if (!empty($tempFlightNumber) && $tempFlightNumber != $FlightNumber) {
$IsFlightChange = 1;
$NewFInvenSysId = $AirInvenSysId;
} elseif (!empty($tempFlightNumber) && $tempFlightNumber == $FlightNumber) {
$IsFlightChange = 2;
$NewFInvenSysId = $AirInvenSysId;
} else {
$IsFlightChange = 0;
$NewFInvenSysId = '';
}
$tempFlightNumber = $FlightNumber;
$AirlineName = $segmentsResult['Airline']['AirlineName'];
$FareClass = $segmentsResult['Airline']['FareClass'];
$originAirportCode = $segmentsResult['Origin']['Airport']['AirportCode'];
$originDepTime = $segmentsResult['Origin']['DepTime'];
$destinationAirportCode = $segmentsResult['Destination']['Airport']['AirportCode'];
$destinationArrTime = $segmentsResult['Destination']['ArrTime'];
$objAirport->strAirportCode = $originAirportCode;
$arrSourceCityId = $objAirport->getAirportList();
if (!empty($arrSourceCityId)) {
$SourcePlaceSysId = !empty($arrSourceCityId[0]['CityId']) ? $arrSourceCityId[0]['CityId'] : $intSourceCityId;
} else {
$SourcePlaceSysId = $intSourceCityId;
}
$objAirport->strAirportCode = $destinationAirportCode;
$arrDestinationCityId = $objAirport->getAirportList();
if (!empty($arrDestinationCityId)) {
$DestPlaceSysId = !empty($arrDestinationCityId[0]['CityId']) ? $arrDestinationCityId[0]['CityId'] : $intDestinationCityId;
} else {
$DestPlaceSysId = $intDestinationCityId;
}
$Duration = $segmentsResult['Duration'];
$FlyingMinutes = $FlyingMinutes + ((isset($segmentsResult['Duration']) ? $segmentsResult['Duration'] : 0) + (!empty($segmentsResult['GroundTime']) ? $segmentsResult['GroundTime'] : (isset($segmentsResult['AccumulatedDuration']) ? $segmentsResult['AccumulatedDuration'] : 0)));
$GroundTime = $segmentsResult['GroundTime'];
$Mile = $segmentsResult['Mile'];
$StopOver = $segmentsResult['StopOver'];
$StopPoint = $segmentsResult['StopPoint'];
$StopPointArrivalTime = $segmentsResult['StopPointArrivalTime'];
$StopPointDepartureTime = $segmentsResult['StopPointDepartureTime'];
$Craft = $segmentsResult['Craft'];
$Remark = $segmentsResult['Remark'];
$IsETicketEligible = $segmentsResult['IsETicketEligible'];
$FlightStatus = $segmentsResult['FlightStatus'];
$Status = $segmentsResult['Status'];
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $AirInvenSysId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"Sequance" => $SegmentIndicator,
"DestPlaceSysId" => $DestPlaceSysId,
"StayDuration" => $GroundTime,
"FlightDuration" => $Duration,
"AirlineCode" => $AirlineCode,
"AirlineName" => $AirlineName,
"FlightNumber" => $FlightNumber,
"FareClass" => $FareClass,
"OriginAirportCode" => $originAirportCode,
"DestinationAirportCode" => $destinationAirportCode,
"IsFlightChange" => $IsFlightChange,
"NewFInvenSysId" => $NewFInvenSysId,
"ArrivalTime" => $destinationArrTime,
"DepartureTime" => $originDepTime,
"HaultInclusions" => '',
"CurrencyType" => $intCurrencyType,
"PublishedFare" => $intFareBreakdownPerPax,
//"CommissionEarned" => '',
"CreateDate" => $CreateDate,
"UpdateDate" => $UpdateDate,
"IsActive" => $IsActive,
"IsMarkForDelete" => $IsMarkForDel
);
$objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$intSegmentsCount++;
}
$arrUpdateFlight = array();
$arrUpdateFlight['FlightNumber'] = trim($AirlineCode) . trim($firstFlightNumber);
$arrUpdateFlight['StopCount'] = $StopCount;
if ($StopCount > 0) {
$arrUpdateFlight['IsDirect'] = '0';
} else {
$arrUpdateFlight['IsDirect'] = '1';
}
$arrUpdateFlight['FlyingMinutes'] = $FlyingMinutes;
// echo "<pre>";
// print_r($arrUpdateFlight);
$objFlight->updateApiFlightDetails($AirInvenSysId, $arrUpdateFlight);
}
$intJourneyType++;
} //exit;
}
} else {
$this->view->ErrorCode = $response['Response']['Error']['ErrorCode'];
$this->view->ErrorMessage = $response['Response']['Error']['ErrorMessage'];
}
// rendering to the respective view according to search type.....
if ($strFlightRoute == '1') {
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
//$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchFlightResult = $arrSearchFlightResult;
$this->render('all-airlines-pkg-db');
} else if ($strFlightRoute == '2') {
// Single trip
//$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition .= " AND t1.JourneyType = '1'";
$objFlight->strSelectedView = "list";
$arrSearchFlightResult = $objFlight->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchSingleTrip = $arrSearchFlightResult;
// Round trip Starts
$intPageNumber2 = !empty($this->getRequest()->getPost('page2')) ? $this->getRequest()->getPost('page2') : '1';
if (!empty($strTripType)) {
$objFlight2->strCondition .= " AND t1.TripType = '" . $strTripType . "'";
}
if (!empty($intMemberCount)) {
$objFlight2->strCondition .= " AND t1.TotalFlightMembers = '" . $intMemberCount . "'";
}
$objFlight2->strCondition .= " AND t1.JourneyType = '2'";
$objFlight2->strCondition .= " AND SUBSTRING(convert(varchar, t1.CreateDate, 120),0,11) = '" . date('Y-m-d') . "' ";
$objFlight2->strSelectedView = "list";
$arrSearchFlightResult = $objFlight2->getFlightSearchList();
$page = $this->_getParam('page', $intPageNumber2);
$arrSearchFlightResult = Zend_Paginator::factory($arrSearchFlightResult);
$arrSearchFlightResult->setItemCountPerPage($intLimitPerPage);
$arrSearchFlightResult->setCurrentPageNumber($page);
$this->view->arrSearchRoundTrip = $arrSearchFlightResult;
$this->render('twoway-all-inventory');
} else {
$this->render('all-airlines-pkg-inventory');
}
}
}
}
}
public function displaySelectedFlightsInfoAction() {
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$intGoingFlightId = !empty($this->getRequest()->getParam('intGoingFlightId')) ? $this->getRequest()->getParam('intGoingFlightId') : 0;
$intReturnFlightId = !empty($this->getRequest()->getParam('intReturnFlightId')) ? $this->getRequest()->getParam('intReturnFlightId') : 0;
$intFlightType = $this->getRequest()->getParam('intFlightType');
// echo '<pre>';print_r($intGoingFlightId);echo '</pre>';
// echo '<pre>';print_r($intReturnFlightId);echo '</pre>';
// echo '<pre>';print_r($intFlightType);echo '</pre>';
$objFlight = new Travel_Model_TblFlight();
$arrGoingFlightDetails = $objFlight->getFlightDetailsForRoundTripHeader($intGoingFlightId);
$arrReturnFlightDetails = $objFlight->getFlightDetailsForRoundTripHeader($intReturnFlightId);
$strTotalFare = 0;
if (!empty($arrGoingFlightDetails) && !empty($arrReturnFlightDetails)) {
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intAdultsCT = $sessionFlightSearchParams->params['adults'];
$intChildsCT = $sessionFlightSearchParams->params['child'];
$intInfantsCT = $sessionFlightSearchParams->params['infant'];
$route = $sessionFlightSearchParams->params['route'];
$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
/* Outbound Price Calculations */
$intPublishedFareOutBound = $arrGoingFlightDetails[0]['PublishedFare'];
$intOfferedFareOutBound = $arrGoingFlightDetails[0]['OfferedFare'];
$intCommissionEarnedOutBound = $arrGoingFlightDetails[0]['CommissionEarned'];
$intPLBEarnedOutBound = $arrGoingFlightDetails[0]['PLBEarned'];
$intIncentiveEarnedOutBound = $arrGoingFlightDetails[0]['IncentiveEarned'];
$arrAllCommissionsOutBound = array(
'intCommissionEarned' => $intCommissionEarnedOutBound,
'intPLBEarned' => $intPLBEarnedOutBound,
'intIncentiveEarned' => $intIncentiveEarnedOutBound
);
$arrPriceAndMarkUpsOutBound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissionsOutBound, $intOfferedFareOutBound);
//echo "<pre>";print_r($arrPriceAndMarkUpsOutBound);echo "</pre>";
$intOfferedFareOutBound = $arrPriceAndMarkUpsOutBound['intOfferedFare'];
if (!empty($interNationalSearch)) {
$intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp));
}
$intAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intCommisionEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intCommisionEarnedForAgency'];
$intPLBEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound;
$intGSTOnAgencyCommisionEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarningsOutBound = $intGSTOnAgencyCommisionEarnedOutBound + $intGSTOnAgencyPLBEarnedOutBound + $intGSTOnAgencyIncentiveEarnedOutBound;
$intPublishFareOutBound = $intOfferedFareOutBound + $intGTXMarkUpOutBound + $intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound + $intCommisionEarnedForAgencyOutBound + $intPLBEarnedForAgencyOutBound + $intIncentiveEarnedForAgencyOutBound + $intTotalGSTAgencyEarningsOutBound;
/* Outbound Price Calculations Ends */
/* Inbound Price Calculations */
$intPublishedFareInBound = $arrReturnFlightDetails[0]['PublishedFare'];
$intOfferedFareInBound = $arrReturnFlightDetails[0]['OfferedFare'];
$intCommissionEarnedInBound = $arrReturnFlightDetails[0]['CommissionEarned'];
$intPLBEarnedInBound = $arrReturnFlightDetails[0]['PLBEarned'];
$intIncentiveEarnedInBound = $arrReturnFlightDetails[0]['IncentiveEarned'];
$arrAllCommissionsInBound = array(
'intCommissionEarned' => $intCommissionEarnedInBound,
'intPLBEarned' => $intPLBEarnedInBound,
'intIncentiveEarned' => $intIncentiveEarnedInBound
);
$arrPriceAndMarkUpsInBound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissionsInBound, $intOfferedFareInBound);
//echo "<pre>";print_r($arrPriceAndMarkUpsInBound);echo "</pre>";
$intOfferedFareInBound = $arrPriceAndMarkUpsInBound['intOfferedFare'];
if (!empty($interNationalSearch)) {
$intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp));
}
$intAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intCommisionEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intCommisionEarnedForAgency'];
$intPLBEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgencyInBound = $arrPriceAndMarkUpsInBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound;
$intGSTOnAgencyCommisionEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarningsInBound = $intGSTOnAgencyCommisionEarnedInBound + $intGSTOnAgencyPLBEarnedInBound + $intGSTOnAgencyIncentiveEarnedInBound;
$intPublishFareInBound = $intOfferedFareInBound + $intGTXMarkUpInBound + $intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound + $intCommisionEarnedForAgencyInBound + $intPLBEarnedForAgencyInBound + $intIncentiveEarnedForAgencyInBound + $intTotalGSTAgencyEarningsInBound;
/* Inbound Price Calculations Ends */
//$strGoingFlightFare = !empty($arrGoingFlightDetails[0]['PublishedFare'])?$arrGoingFlightDetails[0]['PublishedFare']:0;
//$strReturnFlightFare = !empty($arrReturnFlightDetails[0]['PublishedFare'])?$arrReturnFlightDetails[0]['PublishedFare']:0;
//echo $intTotalGSTAgencyEarningsOutBound.'=='.$intTotalGSTAgencyEarningsInBound;
//echo $intPublishFareOutBound.'=='.$intPublishFareInBound;
$strTotalFare = $intPublishFareOutBound + $intPublishFareInBound;
$strTotalFare = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->roundOff($strTotalFare);
}
$BaseUrl = $this->view->baseUrl();
//$strTotalFare = 0;
if ($intFlightType == '1') {
// $strGoingFlightFare = !empty($arrGoingFlightDetails[0]['PublishedFare'])?$arrGoingFlightDetails[0]['PublishedFare']:0;
// $strTotalFare = $strGoingFlightFare;
$strAirlineCode = explode("-", trim($arrGoingFlightDetails[0]['FlightNumber']));
$strAirlineCode = $strAirlineCode[0];
$strAirlineName = $arrGoingFlightDetails[0]['AirlineName'];
$strFlightNumber = $arrGoingFlightDetails[0]['FlightNumber'];
$intStopCount = $arrGoingFlightDetails[0]['StopCount'];
$flightArrivalTime = (array) $arrGoingFlightDetails[0]['ArrivalTime'];
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightArrivalTime['date']);
$flightDepartureTime = (array) $arrGoingFlightDetails[0]['DepartureTime'];
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightDepartureTime['date']);
$strFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->convertMinutesToHoursFormat($arrGoingFlightDetails[0]['FlightDuration']);
$strAirlineCode = trim($strAirlineCode);
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
if (file_exists($filePath . $strAirlineCode . ".gif")) {
$strAirlineLogo = $strAirlineCode . ".gif";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".png")) {
$strAirlineLogo = $strAirlineCode . ".png";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpg")) {
$strAirlineLogo = $strAirlineCode . ".jpg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpeg")) {
$strAirlineLogo = $strAirlineCode . ".jpeg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} else {
$filePath = $BaseUrl . '/public/upload/AirlineLogo/noimage.png';
}
$strGoingFlight = "";
$strGoingFlight = '<tr>
<td style="border-top:none;"><img width="30" src="' . $filePath . '" title="' . $strAirlineName . '"></td>
<td style="border-top:none;" class="small"><span class="graytxt alert-white"> <strong class="text-danger">' . $strAirlineName . '</strong><br>
' . $strFlightNumber . '<br>
' . $strArrivalDtTime . ' – ' . $strDepartureDtTime . '<br>
' . $strFlightDuration . ' | ' . ($intStopCount > 1 ? ($intStopCount - 1) . " Stop" : "Non Stop") . ' </span></td>
</tr>';
echo $strGoingFlight . '###' . $strTotalFare;
} else if ($intFlightType == '2') {
$strAirlineCode = explode("-", trim($arrReturnFlightDetails[0]['FlightNumber']));
$strAirlineCode = $strAirlineCode[0];
$strAirlineName = $arrReturnFlightDetails[0]['AirlineName'];
$strFlightNumber = $arrReturnFlightDetails[0]['FlightNumber'];
$intStopCount = $arrReturnFlightDetails[0]['StopCount'];
$flightArrivalTime = (array) $arrReturnFlightDetails[0]['ArrivalTime'];
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightArrivalTime['date']);
$flightDepartureTime = (array) $arrReturnFlightDetails[0]['DepartureTime'];
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightDepartureTime['date']);
$strFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->convertMinutesToHoursFormat($arrReturnFlightDetails[0]['FlightDuration']);
$strAirlineCode = trim($strAirlineCode);
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
if (file_exists($filePath . $strAirlineCode . ".gif")) {
$strAirlineLogo = $strAirlineCode . ".gif";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".png")) {
$strAirlineLogo = $strAirlineCode . ".png";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpg")) {
$strAirlineLogo = $strAirlineCode . ".jpg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpeg")) {
$strAirlineLogo = $strAirlineCode . ".jpeg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} else {
$filePath = $BaseUrl . '/public/upload/AirlineLogo/noimage.png';
}
$strReturnFlight = "";
$strReturnFlight = '<tr>
<td style="border-top:none;"><img width="30" src="' . $filePath . '" title="' . $strAirlineName . '"></td>
<td style="border-top:none;" class="small"><span class="graytxt alert-white"> <strong class="text-danger">' . $strAirlineName . '</strong><br>
' . $strFlightNumber . '<br>
' . $strArrivalDtTime . ' – ' . $strDepartureDtTime . '<br>
' . $strFlightDuration . ' | ' . ($intStopCount > 1 ? ($intStopCount - 1) . " Stop" : "Non Stop") . ' </span></td>
</tr>';
echo $strReturnFlight . '###' . $strTotalFare;
} else {
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intAdultsCT = $sessionFlightSearchParams->params['adults'];
$intChildsCT = $sessionFlightSearchParams->params['child'];
$intInfantsCT = $sessionFlightSearchParams->params['infant'];
$route = $sessionFlightSearchParams->params['route'];
$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
$strGoingFlight = "";
$strTotalFare = 0;
if (!empty($arrGoingFlightDetails)) {
/* Outbound Price Calculations */
$intPublishedFareOutBound = $arrGoingFlightDetails[0]['PublishedFare'];
$intOfferedFareOutBound = $arrGoingFlightDetails[0]['OfferedFare'];
$intCommissionEarnedOutBound = $arrGoingFlightDetails[0]['CommissionEarned'];
$intPLBEarnedOutBound = $arrGoingFlightDetails[0]['PLBEarned'];
$intIncentiveEarnedOutBound = $arrGoingFlightDetails[0]['IncentiveEarned'];
$arrAllCommissionsOutBound = array(
'intCommissionEarned' => $intCommissionEarnedOutBound,
'intPLBEarned' => $intPLBEarnedOutBound,
'intIncentiveEarned' => $intIncentiveEarnedOutBound
);
$arrPriceAndMarkUpsOutBound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissionsOutBound, $intOfferedFareOutBound);
//echo "<pre>";print_r($arrPriceAndMarkUpsOutBound);echo "</pre>";
// $intOfferedFareOutBound = $arrPriceAndMarkUpsOutBound['intOfferedFare'];
// if(!empty($interNationalSearch)){
// $intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp']*$intTatalPaxCTForMarkUp)*$route);
// $intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp']*$intTatalPaxCTForMarkUp)*$route);
// }else{
// $intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp']*$intTatalPaxCTForMarkUp));
// $intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp']*$intTatalPaxCTForMarkUp));
// }
// $intAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intAgencyFixMarkUp']*$intTatalPaxCTForMarkUp);
// $intSTaxOnAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intSTaxOnAgencyFixMarkUp']*$intTatalPaxCTForMarkUp);
// $intCommisionEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intCommisionEarnedForAgency'];
// $intPLBEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intPLBEarnedForAgency'];
// $intIncentiveEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intIncentiveEarnedForAgency'];
// $intTotalEarningsForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound;
// $intPublishFareOutBound = $intOfferedFareOutBound + $intGTXMarkUpOutBound +$intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound + $intCommisionEarnedForAgencyOutBound + $intPLBEarnedForAgencyOutBound + $intIncentiveEarnedForAgencyOutBound;
//
// $strTotalFare = $intPublishFareOutBound;
$intOfferedFareOutBound = $arrPriceAndMarkUpsOutBound['intOfferedFare'];
if (!empty($interNationalSearch)) {
$intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnGTXMarkUpOutBound = (($arrPriceAndMarkUpsOutBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp));
}
$intAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUpOutBound = ($arrPriceAndMarkUpsOutBound['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intCommisionEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intCommisionEarnedForAgency'];
$intPLBEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgencyOutBound = $arrPriceAndMarkUpsOutBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound;
$intGSTOnAgencyCommisionEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarnedOutBound = $arrPriceAndMarkUpsOutBound['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarningsOutBound = $intGSTOnAgencyCommisionEarnedOutBound + $intGSTOnAgencyPLBEarnedOutBound + $intGSTOnAgencyIncentiveEarnedOutBound;
$intPublishFareOutBound = $intOfferedFareOutBound + $intGTXMarkUpOutBound + $intAgencyFixMarkUpOutBound + $intSTaxOnAgencyFixMarkUpOutBound + $intCommisionEarnedForAgencyOutBound + $intPLBEarnedForAgencyOutBound + $intIncentiveEarnedForAgencyOutBound + $intTotalGSTAgencyEarningsOutBound;
$strTotalFare = $intPublishFareOutBound;
/* Outbound Price Calculations Ends */
$strAirlineCode = explode("-", trim($arrGoingFlightDetails[0]['FlightNumber']));
$strAirlineCode = $strAirlineCode[0];
$strFlightNumber = $arrGoingFlightDetails[0]['FlightNumber'];
$strAirlineName = $arrGoingFlightDetails[0]['AirlineName'];
$strFlightNumber = $arrGoingFlightDetails[0]['FlightNumber'];
$intStopCountGo = $arrGoingFlightDetails[0]['StopCount'];
$flightArrivalTime = (array) $arrGoingFlightDetails[0]['ArrivalTime'];
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightArrivalTime['date']);
$flightDepartureTime = (array) $arrGoingFlightDetails[0]['DepartureTime'];
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightDepartureTime['date']);
$strFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->convertMinutesToHoursFormat($arrGoingFlightDetails[0]['FlightDuration']);
$strAirlineCode = trim($strAirlineCode);
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
if (file_exists($filePath . $strAirlineCode . ".gif")) {
$strAirlineLogo = $strAirlineCode . ".gif";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".png")) {
$strAirlineLogo = $strAirlineCode . ".png";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpg")) {
$strAirlineLogo = $strAirlineCode . ".jpg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpeg")) {
$strAirlineLogo = $strAirlineCode . ".jpeg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} else {
$filePath = $BaseUrl . '/public/upload/AirlineLogo/noimage.png';
}
$strGoingFlight = '<tr>
<td style="border-top:none;"><img width="30" src="' . $filePath . '" title="' . $strAirlineName . '"></td>
<td style="border-top:none;" class="small"><span class="graytxt alert-white"> <strong class="text-danger">' . $strAirlineName . '</strong><br>
' . $strFlightNumber . '<br>
' . $strArrivalDtTime . ' – ' . $strDepartureDtTime . '<br>
' . $strFlightDuration . ' | ' . ($intStopCountGo > 1 ? ($intStopCountGo - 1) . " Stop" : "Non Stop") . ' </span></td>
</tr>';
}
$strReturnFlight = "";
if (!empty($arrReturnFlightDetails)) {
/* Inbound Price Calculations */
$intPublishedFareInBound = $arrReturnFlightDetails[0]['PublishedFare'];
$intOfferedFareInBound = $arrReturnFlightDetails[0]['OfferedFare'];
$intCommissionEarnedInBound = $arrReturnFlightDetails[0]['CommissionEarned'];
$intPLBEarnedInBound = $arrReturnFlightDetails[0]['PLBEarned'];
$intIncentiveEarnedInBound = $arrReturnFlightDetails[0]['IncentiveEarned'];
$arrAllCommissionsInBound = array(
'intCommissionEarned' => $intCommissionEarnedInBound,
'intPLBEarned' => $intPLBEarnedInBound,
'intIncentiveEarned' => $intIncentiveEarnedInBound
);
$arrPriceAndMarkUpsInBound = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissionsInBound, $intOfferedFareInBound);
//echo "<pre>";print_r($arrPriceAndMarkUpsInBound);echo "</pre>";
// $intOfferedFareInBound = $arrPriceAndMarkUpsInBound['intOfferedFare'];
// if(!empty($interNationalSearch)){
// $intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp']*$intTatalPaxCTForMarkUp)*$route);
// $intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp']*$intTatalPaxCTForMarkUp)*$route);
// }else{
// $intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp']*$intTatalPaxCTForMarkUp));
// $intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp']*$intTatalPaxCTForMarkUp));
// }
// $intAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intAgencyFixMarkUp']*$intTatalPaxCTForMarkUp);
// $intSTaxOnAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intSTaxOnAgencyFixMarkUp']*$intTatalPaxCTForMarkUp);
// $intCommisionEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intCommisionEarnedForAgency'];
// $intPLBEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intPLBEarnedForAgency'];
// $intIncentiveEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intIncentiveEarnedForAgency'];
// $intTotalEarningsForAgencyInBound = $arrPriceAndMarkUpsInBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound;
// $intPublishFareInBound = $intOfferedFareInBound + $intGTXMarkUpInBound +$intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound + $intCommisionEarnedForAgencyInBound + $intPLBEarnedForAgencyInBound + $intIncentiveEarnedForAgencyInBound;
//
// $strTotalFare = $strTotalFare + $intPublishFareInBound;
$intOfferedFareInBound = $arrPriceAndMarkUpsInBound['intOfferedFare'];
if (!empty($interNationalSearch)) {
$intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnGTXMarkUpInBound = (($arrPriceAndMarkUpsInBound['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp));
}
$intAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUpInBound = ($arrPriceAndMarkUpsInBound['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intCommisionEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intCommisionEarnedForAgency'];
$intPLBEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgencyInBound = $arrPriceAndMarkUpsInBound['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgencyInBound = $arrPriceAndMarkUpsInBound['intTotalEarningsForAgency'] + $intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound;
$intGSTOnAgencyCommisionEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarnedInBound = $arrPriceAndMarkUpsInBound['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarningsInBound = $intGSTOnAgencyCommisionEarnedInBound + $intGSTOnAgencyPLBEarnedInBound + $intGSTOnAgencyIncentiveEarnedInBound;
$intPublishFareInBound = $intOfferedFareInBound + $intGTXMarkUpInBound + $intAgencyFixMarkUpInBound + $intSTaxOnAgencyFixMarkUpInBound + $intCommisionEarnedForAgencyInBound + $intPLBEarnedForAgencyInBound + $intIncentiveEarnedForAgencyInBound + $intTotalGSTAgencyEarningsInBound;
$strTotalFare = $strTotalFare + $intPublishFareInBound;
/* Inbound Price Calculations Ends */
$strAirlineCode = explode("-", trim($arrReturnFlightDetails[0]['FlightNumber']));
$strAirlineCode = $strAirlineCode[0];
$strAirlineName = $arrReturnFlightDetails[0]['AirlineName'];
$strFlightNumber = $arrReturnFlightDetails[0]['FlightNumber'];
$intStopCountReturn = $arrReturnFlightDetails[0]['StopCount'];
$flightArrivalTime = (array) $arrReturnFlightDetails[0]['ArrivalTime'];
$strArrivalDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightArrivalTime['date']);
$flightDepartureTime = (array) $arrReturnFlightDetails[0]['DepartureTime'];
$strDepartureDtTime = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getArrivalDepartureIndianFormat($flightDepartureTime['date']);
$strFlightDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->convertMinutesToHoursFormat($arrReturnFlightDetails[0]['FlightDuration']);
$strAirlineCode = trim($strAirlineCode);
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/public/upload/AirlineLogo/";
if (file_exists($filePath . $strAirlineCode . ".gif")) {
$strAirlineLogo = $strAirlineCode . ".gif";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".png")) {
$strAirlineLogo = $strAirlineCode . ".png";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpg")) {
$strAirlineLogo = $strAirlineCode . ".jpg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} elseif (file_exists($filePath . $strAirlineCode . ".jpeg")) {
$strAirlineLogo = $strAirlineCode . ".jpeg";
$filePath = $BaseUrl . '/public/upload/AirlineLogo/' . $strAirlineLogo;
} else {
$filePath = $BaseUrl . '/public/upload/AirlineLogo/noimage.png';
}
$strReturnFlight = '<tr>
<td style="border-top:none;"><img width="30" src="' . $filePath . '" title="' . $strAirlineName . '"> </td>
<td style="border-top:none;" class="small"><span class="graytxt alert-white"> <strong class="text-danger">' . $strAirlineName . '</strong><br>
' . $strFlightNumber . '<br>
' . $strArrivalDtTime . ' – ' . $strDepartureDtTime . '<br>
' . $strFlightDuration . ' | ' . ($intStopCountReturn > 1 ? ($intStopCountReturn - 1) . " Stop" : "Non Stop") . ' </span></td>
</tr>';
}
echo $strGoingFlight . '###' . $strReturnFlight . '###' . $strTotalFare;
}
exit;
}
}
public function getFlightItineraryAction() {
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$AirInvenSysId = trim($this->getRequest()->getParam('AirInvenSysId'));
$IsInterNational = trim($this->getRequest()->getParam('IsInterNational'));
if (!empty($AirInvenSysId)) {
$objFlight = new Travel_Model_TblFlight();
$arrFlightItenairy = $objFlight->getFlightItinerary($AirInvenSysId, $IsInterNational);
$this->view->arrFlightItenairy = $arrFlightItenairy;
$this->render('get-flight-itinerary');
}
}
}
public function getFlightFareRuleAction() {
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$AirInvenSysId = trim($this->getRequest()->getParam('AirInvenSysId'));
if (!empty($AirInvenSysId)) {
$objFlight = new Travel_Model_TblFlight();
$arrFlightFareRule = $objFlight->getFlightFareRuleInformation($AirInvenSysId);
//echo "<pre>"; print_r($arrFlightFareRule); exit;
$this->view->arrFlightFareRule = $arrFlightFareRule;
$objCity = new Travel_Model_TblCity();
$SourcePlaceSysId = $arrFlightFareRule[0]['SourcePlaceSysId'];
if (!empty($SourcePlaceSysId)) {
$this->view->strSourceCity = $strSourceCity = $objCity->getCityNameById($SourcePlaceSysId);
}
$DestPlaceSysId = $arrFlightFareRule[0]['DestPlaceSysId'];
if (!empty($DestPlaceSysId)) {
$this->view->strDestinationCity = $strDestinationCity = $objCity->getCityNameById($DestPlaceSysId);
}
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $AirInvenSysId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
//echo "<pre>";print_r($arrSelectedFlightDetails);exit;
if (!empty($arrSelectedFlightDetails)) {
$TraceId = trim($arrSelectedFlightDetails[0]['apiTraceId']);
$ResultIndex = trim($arrSelectedFlightDetails[0]['ApiResultIndex']);
$data = array(
"TraceId" => $TraceId,
"ResultIndex" => $ResultIndex
);
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->fareRuleDetails($data);
if (isset($response['Response']['Error']['ErrorCode']) && $response['Response']['Error']['ErrorCode'] == '0') {
$this->view->FareRuleDetail = isset($response['Response']['FareRules'][0]['FareRuleDetail']) ? $response['Response']['FareRules'][0]['FareRuleDetail'] : '';
}
//echo "<pre>";print_r($response);exit;
}
}
$this->render('get-flight-fare-rule');
}
}
public function getFlightBaggageInformationAction() {
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$AirInvenSysId = trim($this->getRequest()->getParam('AirInvenSysId'));
$IsInterNational = trim($this->getRequest()->getParam('IsInterNational'));
if (!empty($AirInvenSysId)) {
$objFlight = new Travel_Model_TblFlight();
$arrFlightBaggage = $objFlight->getFlightBaggageInformation($AirInvenSysId, $IsInterNational);
$this->view->arrFlightBaggage = $arrFlightBaggage;
}
$this->render('get-flight-baggage-information');
}
}
public function updatepnrAction() {
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getPost();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$TPSysId = $arrCustomerInvoiceData[0]['TPSysId'];
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$TPIntSysId = $arrCustomerInvoiceData[0]['TPIntSysId'];
$LeadSourceSysId = $arrCustomerInvoiceData[0]['LeadSourceSysId'];
$LeadSource = isset($arrCustomerInvoiceData[0]['LeadSource']) ? $arrCustomerInvoiceData[0]['LeadSource'] : '';
$APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
$bookingId_TJ = $APIBookingRes['value']['bookingId_TJ'];
$IsB2bSite = $this->agencyDetails['IsB2bSite'];
$IsB2bSiteURL = $this->agencyDetails['IsB2bSiteURL'];
$IsB2CSiteURL = $this->agencyDetails['Url'];
$GetFlightTempData = $objFlight->GetFlightTempDataByTPSysId($TPSysId);
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($TPSysId);
$arrUrlData = [];
if ($GetFlightTempData && ($LeadSourceSysId == 24 || $LeadSource == 'Agency-Proposal')) {
$ConfirmTicket = $post['ConfirmTicket'];
$arrUrlData = json_decode($GetFlightTempData['APIBookingData'], true);
$intOutBoundId = $arrUrlData['intOutBoundId'];
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$booking_ids = $intOutBoundId[0]['bookingId'];
$ICSourceSysId_ = isset($intOutBoundId[0]['ICSourceSysId']) ? $intOutBoundId[0]['ICSourceSysId'] : 0;
$ForCustomerSession = $arrUrlData['ForCustomerSession'];
$SearchTraceId = $arrUrlData['sessionFlightSearchParams']['SearchTraceId'];
echo "<pre>";
print_r($arrUrlData);
die;
if ($ConfirmTicket) {
$Newpnrnumber = $post['Newpnrnumber'];
$bookingIds = $post['bookingIds'];
if (empty(trim($bookingIds))) {
$Return = array('success' => false, 'message' => 'Please enter booking ID.', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
if (empty(trim($Newpnrnumber))) {
$Return = array('success' => false, 'message' => 'Please enter PNR number.', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
$intOutBoundId[0]['bookingId'] = $bookingIds;
$intOutBoundId[0]['OnwardGroupPNR'] = $Newpnrnumber;
if (isset($intOutBoundId[1]) && !empty($intOutBoundId[1])) {
$intOutBoundId[1]['bookingId'] = $bookingIds;
$intOutBoundId[1]['OnwardGroupPNR'] = $Newpnrnumber;
}
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($intOutBoundId, $ForCustomerSession);
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
$Passengers = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
$statusMap = [];
$TicketId = [];
$TicketNumber = [];
if ($Passengers) {
foreach ($Passengers as $pax) {
$statusMap = implode('-', isset($pax['statusMap']) ? $pax['statusMap'] : []);
$TicketId = implode('-', $pax['pnrDetails']);
$statusMap = implode('-', isset($pax['statusMap']) ? $pax['statusMap'] : []);
$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
}
}
$pnr = explode('-', $TicketId);
if (count($pnr) > 2) {
$PNR_Number = $pnr[0] . '-' . $pnr[1];
} else {
$PNR_Number = $pnr[0];
}
if ($intOutBoundId) {
foreach ($intOutBoundId as $k => $value) {
if ($ICSourceSysId_ == 7 || $ICSourceSysId_ == 8) {
$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
$PNR_Number = isset($pnr[$k]) ? $pnr[$k] : '';
} else {
$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
}
$TPintSysId = $arrIntTpAirId[$k];
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => $PNR_Number,
"XRefBookingId" => $strBookingIdLCC,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
}
}
if (isset($arrTrevllerList) && !empty($arrTrevllerList) && $ResponseStatus == 1) {
foreach ($arrTrevllerList as $key => $value) {
$pax = $Passengers[$key];
$TicketId = implode('-', $pax['pnrDetails']);
$statusMap = implode('-', $pax['statusMap']);
$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
$data = array(
"TicketId" => !empty($TicketId) ? $TicketId : '',
"TicketNumber" => $TicketNumber,
"TicketFullJson" => json_encode($Passengers)
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
$arrUrlData['tripType'] = 1;
$arrUrlData['intOutBoundId'] = $intOutBoundId;
$arrUrlData['arrBookingResponse'] = json_encode($response);
$arrUrlData['intTPSysId'] = $intTPSysId;
$arrUrlData['arrIntTpAirId'] = $arrIntTpAirId;
$arrUrlData['IsTripjack'] = true;
$arrUrlData['guid'] = $guid;
$arrUrlData['TrxSysId'] = $TrxSysId;
$arrUrlData['IsTripjack'] = true;
$tempData = array(
'TPSysId' => $TPSysId,
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
$response = array('success' => true, 'message' => 'Ticket generate successfull', 'LeadSourceSysId' => '');
echo json_encode($response);
exit;
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('FlightBookingData' => $intOutBoundId, 'ForCustomerSession' => $ForCustomerSession, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle));
$bodyText = $html->render('updatepnrview.phtml');
$Return = array('success' => true, 'message' => 'done', 'LeadSourceSysId' => $LeadSourceSysId, 'booking_ids' => $booking_ids, 'bodyText' => $bodyText);
echo json_encode($Return);
exit;
}
if (!empty($bookingId_TJ)) {
$bookingId_TJ = $bookingId_TJ;
} else {
$bookingId_TJ = $APIBookingRes['value']['bookingId'];
}
$APIBookingRes['value']['OnwardAutoTicket'] = 1;
$APIBookingData['value'] = $APIBookingRes['value'];
$Bookres = array(
'bookingId' => $bookingId_TJ,
'status' => array(
'success' => true,
'httpStatus' => 200
),
);
$strFilePath = "flight/updatepnr/" . $bookingId_TJ . '_' . date('Y-m-d-H-i-s') . "_api_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($Bookres));
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres, $this->intLoggedinAgencyId);
// echo "<pre>";print_r($response);
// die;
$strFilePath = "flight/updatepnr/" . $bookingId_TJ . '_' . date('Y-m-d-H-i-s') . "_api_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($response));
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
$OrderStatus = isset($response['order']['status']) ? $response['order']['status'] : '';
$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
if ($ResponseStatus == 1 && ($OrderStatus == 'SUCCESS')) {
$APIBookingData['response'] = $response;
$finalpnr = [];
if ($APIBookingData['value']['Segments']) {
foreach ($APIBookingData['value']['Segments'] as $seg) {
$originAirportCode = $seg['originAirportCode'];
$destinationAirportCode = $seg['destinationAirportCode'];
$AirportCode = $originAirportCode . '-' . $destinationAirportCode;
$finalpnr[] = isset($strTicketPNRLCC[$AirportCode]) ? $strTicketPNRLCC[$AirportCode] : '';
}
}
$finalpnr = $this->checkArrayKeyExist($finalpnr);
$PNRNew = !empty($finalpnr) ? implode(',', $finalpnr) : '';
if (trim($IsB2bSite) == 1 || $LeadSource == 'Website') {
try {
$dataUpdate = array(
"AirlineRefPNR" => $PNRNew,
"APIBookingRes" => json_encode($APIBookingData),
);
$objFlight->updateInvnItemSysIdData($dataUpdate, $TPIntSysId);
$PaymentStatus = 130;
$StatusType = 104;
$BookingStatus = 142;
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => $StatusType, 'PaymentStatus' => $PaymentStatus, 'BookingStatus' => $BookingStatus), $TPSysId, $MasterTPSysId); // FOR BOOKING CONFIRMED
$DataB2B['status'] = 1;
$DataB2B['bookingId'] = $bookingId_TJ;
$DataB2B['response'] = json_encode($response);
$DataB2B['APIBookingData'] = json_encode($APIBookingData);
$strFilePath = "flight/updatepnr/site/" . date('Y-m-d-H-i-s') . "_site_request.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($DataB2B));
// $this->postFields = "";
// $this->postFields .= "&AgencySysId=" . $this->intLoggedinAgencyId;
// $this->postFields .= "&AgentSysId=" . $this->intLoggedinUserId;
// $this->postFields .= "&bookingId=" . $bookingId_TJ;
// $this->postFields .= "&data=" . json_encode($APIBookingData);
// $url = trim($IsB2bSiteURL) . "gtxwebservices/index/updatepnr";
//$url = "http://local.superdmc.com/gtxwebservices/index/updatepnr";
if ($LeadSource == 'Website') {
$url = trim($IsB2CSiteURL) . "gtxwebservices/index/updatestatus";
} else {
$url = trim($IsB2bSiteURL) . "gtxwebservices/index/updatestatus";
}
$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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $DataB2B);
$output = curl_exec($ch);
$UpdateRes = json_decode($output, true);
$strFilePath = "flight/updatepnr/site/" . date('Y-m-d-H-i-s') . "_site_response.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $output);
if ($UpdateRes['success'] == 1) {
$Return = array('success' => true, 'message' => 'Update PNR successfully done', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
} else {
$Return = array('success' => false, 'message' => $UpdateRes['message'], 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
} catch (Zend_Exception $ex) {
$strFilePath = "flight/updatepnr/" . date('Y-m-d-H-i-s') . "_error.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, json_encode($ex->getMessage()));
$ex->getMessage();
$Return = array('success' => false, 'message' => 'failed to update. try again.', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
} else {
$Return = array('success' => false, 'message' => 'failed to update. make sure url is maped', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
} else {
$Return = array('success' => false, 'message' => 'failed to get PNR. try again.', 'LeadSourceSysId' => '');
echo json_encode($Return);
exit;
}
echo "<pre>";
print_r($IsB2bSite);
echo "<pre>";
print_r($IsB2bSiteURL);
exit;
echo "<pre>";
print_r($APIBookingData);
exit;
echo "<pre>";
print_r($response);
exit;
}
}
public function updatepnrapiAction() {
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getPost();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['TPSysId' => $intTPSysId, 'version' => null];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightBookingData = isset($apiResponse['FlightBookingData'])?$apiResponse['FlightBookingData']:[];
$passengerData = isset($apiResponse['customer'])?$apiResponse['customer']:[];
// echo "<pre>";
// print_r(($apiResponse));die;
$B2BAgencySysId = isset($FlightBookingData[0]['B2BAgencySysId'])?$FlightBookingData[0]['B2BAgencySysId']:'';
$ICSourceSysId = isset($FlightBookingData[0]['ICSourceSysId'])?$FlightBookingData[0]['ICSourceSysId']:'';
$Booking_RefNo = isset($FlightBookingData[0]['XRefBookingId'])?$FlightBookingData[0]['XRefBookingId']:'';
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($B2BAgencySysId);
$B2BSearch = array(
'B2BAgencySysIdKey' => $B2bAgencyDetailById['SecurityKey'],
'B2CAgencySysIdKey' => $this->agencyDetails['SecurityKey'],
'MasterAgencySysId' => $this->agencyDetails['AgencySysId'],
);
if($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14){
$request = array(
'Auth_Header'=>array(
"IP_Address" => $_SERVER['REMOTE_ADDR'],
"Request_Id" => $Booking_RefNo,
"IMEI_Number" => "3434334343111"
),
'Booking_RefNo'=>$Booking_RefNo,
'Airline_PNR'=>'',
);
$DataS = array(
'apidata'=>$request,
'memberCount'=>0,
'JourneyType'=>0,
'interNationalSearch'=>false,
'searchID'=>$Booking_RefNo,
'B2B'=>$B2BSearch,
'ICSourceSysId'=>$ICSourceSysId,
);
$url = GTX_API_URL . '/flight/v3/reprint';
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$getData['ICSourceSysId'] = $ICSourceSysId;
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
$AirPNRDetails = isset($response['results']['AirPNRDetails']) ? $response['results']['AirPNRDetails'] : [];
$bookingId = isset($response['results']['Booking_RefNo']) ? $response['results']['Booking_RefNo'] : '';
$BookStatus = isset($response['results']['Response_Header']['Status_Id']) ? $response['results']['Response_Header']['Status_Id'] : 0;
$ticketNumberDetails = [];
$pnrDetails = [];
$segmentArray = [];
if($AirPNRDetails){
foreach($AirPNRDetails as $k=>$val){
$Airline_PNR = $val['Airline_PNR'];
if($val['PAXTicketDetails']){
foreach($val['PAXTicketDetails'] as $k=>$value){
if($value['TicketDetails']){
foreach($value['TicketDetails'] as $val){
if($val['SegemtWiseChanges']){
foreach($val['SegemtWiseChanges'] as $va){
$Origin = $va['Origin'];
$Destination = $va['Destination'];
$secKey = $Origin.'-'.$Destination;
$ticketNumberDetails[$k][$secKey] = $val['Ticket_Number'];
$pnrDetails[$k][$secKey] = $Airline_PNR;
$segmentArray[$secKey] = $secKey;
}
}
}
}
}
}
}
}
$PNRArray = [];
$passanger = [];
if($passengerData){
foreach ($passengerData as $key => $val) {
$ticketNumber = isset($ticketNumberDetails[$key])?$ticketNumberDetails[$key]:[];
$pnrDetails_ = isset($pnrDetails[$key])?$pnrDetails[$key]:[];
$PNR_Number = array_values($pnrDetails_);
$TicketNumber_ = array_values($ticketNumber);
$PNRArray[$key]['PNR_Number'] = implode('-', $PNR_Number);
$PNRArray[$key]['TicketId'] = implode('-', $PNR_Number);
$PNRArray[$key]['TicketNumber'] = implode('-', $TicketNumber_);
$PNRArray[$key]['sectors'] = implode('@@', $segmentArray);
$passanger[] = array(
'pnrDetails' => $pnrDetails_,
'ticketNumberDetails' => $ticketNumber,
);
}
}
if ($BookStatus == 22) {
$status = 'PENDING';
$success = true;
} elseif ($BookStatus == 33) {
$status = 'BLOCK';
$success = true;
} elseif ($BookStatus == 11) {
$status = 'SUCCESS';
$success = true;
}else{
$status = 'FAILED';
$success = false;
}
$strTicketPNRLCC = isset($passanger[0]['pnrDetails']) ? array_values($passanger[0]['pnrDetails']) : '';
if($FlightBookingData && $success == 1 && $status == 'SUCCESS'){
$model = new Gtxwebservices_Model_Webservices();
foreach($FlightBookingData as $k=>$value){
$Ticket_Status_Id = isset($AirPNRDetails[$k]['Ticket_Status_Id']) ? $AirPNRDetails[$k]['Ticket_Status_Id'] : 0;
$Ticket_Status_Desc = isset($AirPNRDetails[$k]['Ticket_Status_Desc']) ? $AirPNRDetails[$k]['Ticket_Status_Desc'] : 0;
if($Ticket_Status_Id == 4){
$postFieldArray = array(
'MasterTPSysId' => $value['MasterTPSysId'],
'TPSysId' => $value['TPSysId'],
'VersionId' => $value['AirVersionId'],
'BookingId' => $bookingId,
'APIBookingId' => $bookingId,
'PNRNumber' => implode('-',array_unique($strTicketPNRLCC)),
'customerpnr' => ($PNRArray),
'ErrorCode' => 0,
'IsBookingStatus' => 1,
'OnwardAutoTicket' => ($status == 'PENDING')?0:1
);
$result = $model->UPDATE_PNR_API($postFieldArray);
$updateResponse = json_decode($result,1);
$strFilePath = "flight/SearchParam/" . $intTPSysId . "/UPDATEPNR/" . time() . "_update_pnr.json";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, ($result));
$Return = array('success' => true, 'message' => 'Update PNR successfully done', 'SearchTraceId' => $intTPSysId);
echo json_encode($Return);
exit;
}else{
$Return = array('success' => true, 'message' => 'failed to update. Current booking status is: - ' . $Ticket_Status_Desc, 'SearchTraceId' => $TPSysId);
echo json_encode($Return);
exit;
}
}
}else{
$Return = array('success' => false, 'message' => 'failed to update. Current booking status is: - ' . $status);
echo json_encode($Return);
exit;
}
}elseif($ICSourceSysId == 7){
$request = array(
'bookingId' => str_replace('DMC','TJ',$Booking_RefNo),
'status' => array(
'success' => true,
'httpStatus' => 200
),
);
$DataS = array(
'apidata'=>$request,
'memberCount'=>0,
'JourneyType'=>0,
'interNationalSearch'=>false,
'searchID'=>$Booking_RefNo,
'B2B'=>$B2BSearch,
'ICSourceSysId'=>$ICSourceSysId,
);
$url = GTX_API_URL . '/flight/v3/reprint';
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$getData['ICSourceSysId'] = $ICSourceSysId;
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($DataS, $getData, $url);
echo "<pre>";print_r($response);
die;
}
}
}
public function ExtraAddAddons($UpdateData) {
if ($UpdateData && !empty($UpdateData)) {
$objPackage = new Travel_Model_TblPackage();
$addonFlightData = [
'AgencySysId' => (int) $UpdateData['AgencySysId'],
'TPSysId' => (int) $UpdateData['TPSysId'],
'CustomerSysId' => (int) $UpdateData['CustomerSysId'],
'SupplierSysId' => 0,
'PlanType' => 1,
'InvnSysId' => 0,
'ServiceTitle' => $UpdateData['ServiceTitle'],
'CurrencyType' => $UpdateData['CurrencyType'], // Currency Id
'GSTTYPE' => $UpdateData['GSTTYPE'], // GST 18,15
'Tax' => (float) ($UpdateData['Tax']), // GST Tax
'Cost' => ($UpdateData['Cost']),
'Markup' => (float) $UpdateData['Markup'],
'TotalCost' => (int) ($UpdateData['TotalCost']),
'IsActive' => 1,
'IsApplyTax' => 0,
];
// echo "<pre>";
// print_r($addonFlightData);
$objPackage->saveAddonServicesData($addonFlightData);
}
}
public function bookFlightAction() {
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getPost();
$strTrxStatus = !empty($this->getRequest()->getParam('trxstatus')) ? $this->getRequest()->getParam('trxstatus') : '';
$TrxSysId = $this->getRequest()->getParam('TrxSysId');
$TPSysId = $this->getRequest()->getParam('TPSysId');
$guid = $this->getRequest()->getParam('guid');
$param = $this->getRequest()->getParams();
if ($strTrxStatus == "success") { // Payment success case
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgentDetailById = $crmcustomerObj->getAgentDetailById($this->intLoggedinUserId);
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$IsAllowFlightBooking = isset($getAgentDetailById[0]['IsAllowFlightBooking']) ? $getAgentDetailById[0]['IsAllowFlightBooking'] : 0;
$IsCheckWallet = isset($this->agencyDetails['IsCheckWallet']) ? $this->agencyDetails['IsCheckWallet'] : 0;
$strUrlData = $TrackId = $this->getRequest()->getParam('strUrlData');
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
if (!empty($TrxSysId)) {
$TrxSysId = $TrxSysId;
} else {
$TrxSysId = $arrUrlData['TrxSysId'];
}
$route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : '';
$bookingAllowed = isset($sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : 0;
$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : '';
$ForCustomerSession = !empty($arrUrlData['ForCustomerSession']) ? $arrUrlData['ForCustomerSession'] : 0;
$GstNumber = !empty($ForCustomerSession[0]['GstNumber']) ? $ForCustomerSession[0]['GstNumber'] : '';
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$MasterTPSysId = isset($arrCustomerInvoiceData[0]['MasterTPSysId']) ? $arrCustomerInvoiceData[0]['MasterTPSysId'] : 0;
$intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$ICSourceSysId_ = isset($intOutBoundId[0]['ICSourceSysId']) ? $intOutBoundId[0]['ICSourceSysId'] : 0;
$SelectedBaggSessionNew = isset($arrUrlData['SelectedBaggSessionNew']) ? $arrUrlData['SelectedBaggSessionNew'] : 0;
$SelectedMealSessionNew = isset($arrUrlData['SelectedMealSessionNew']) ? $arrUrlData['SelectedMealSessionNew'] : 0;
$selectedSeatSession = isset($arrUrlData['selectedSeatSession']) ? $arrUrlData['selectedSeatSession'] : 0;
$paymentModebyUser = (isset($arrUrlData['paymentModebyUser']) && !empty($arrUrlData['paymentModebyUser'])) ? $arrUrlData['paymentModebyUser'] : 1;
$checkPaymentStatus = $this->paymentMdl->checkPaymentStatus($this->intLoggedinAgencyId, $intTPSysId);
if ($interNationalSearch == "1" && $route == "2" && $ICSourceSysId_ != 9) {
if ($ICSourceSysId_ == '3') {
$BookingData[] = isset($intOutBoundId[0]) ? $intOutBoundId[0] : '';
} else {
$BookingData[] = isset($intOutBoundId[0]['InternationalData']) ? $intOutBoundId[0]['InternationalData'] : '';
}
} else {
$BookingData = $intOutBoundId;
}
$ServiceTaxNo = $this->agencyDetails['ServiceTaxNo'];
$gstvalidate = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->gstvalidate($GstNumber, $ServiceTaxNo);
$session_UserData = $_SESSION['sessionLogin_user'];
$GSTTYPE = ($session_UserData['agencyDetails']['TaxLabelId'] == 1) ? '18' : '5';
$CurrencyType = isset($BookingData[0]['currencySysId']) ? $BookingData[0]['currencySysId'] : $BookingData[0]['CurrencyType'];
$this->CurrencyRate = isset($BookingData[0]['FairRules']['CurrencyRate']) ? $BookingData[0]['FairRules']['CurrencyRate'] : 1;
$bookingId = isset($BookingData[0]['bookingId']) ? $BookingData[0]['bookingId'] : $strUrlData;
// echo "<pre>";
// print_r($BookingData);
// die;
$TaxTotal = 0;
$CostTotal = 0;
$MarkupTotal = 0;
$TotalCostTotal = 0;
$PublishedFare = 0;
$TotalDiscount = 0;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
$B2BWalletbalance_ = 0;
$misxItems_name = [];
if ($BookingData) {
foreach ($BookingData as $k => $value) {
if ($value['Segments'] && $ICSourceSysId_ == 9) {
foreach ($value['Segments'] as $Segments) {
if ($Segments['MEALARRAY']) {
foreach ($Segments['MEALARRAY'] as $m => $meals) {
$MealPrice += isset($meals['Price']) ? $meals['Price'] : 0;
}
}
if ($Segments['SEATARRAY']) {
foreach ($Segments['SEATARRAY'] as $m => $seat) {
$SeatPrice += isset($seat['Price']) ? $seat['Price'] : 0;
}
}
if ($Segments['BAGGAGEARRAY']) {
foreach ($Segments['BAGGAGEARRAY'] as $b => $bag) {
$BagPrice += isset($bag['Price']) ? $bag['Price'] : 0;
}
}
}
}
$TotalCostTotal += $value['FairRules']['PublishedFare'];
if ($value['FairRules']['FareBreakdown']) {
foreach ($value['FairRules']['FareBreakdown'] as $kb => $breack) {
$BaseFare_ = $breack['BaseFare'];
$FixedMarkUp_ = $breack['FixedMarkUp'];
$GSTOnMarkUp_ = $breack['GSTOnMarkUp'] * $this->CurrencyRate;
$intTotalGST_ = $breack['intTotalGST'] * $this->CurrencyRate;
$CostTotal += $BaseFare_;
$MarkupTotal += $FixedMarkUp_;
$PBaseFare = $breack['BaseFare'];
$TaxIN = $breack['TaxIN'];
$IntCommission = $breack['IntCommission'];
$CommEarned = $breack['CommEarned'];
$CommissionEarned = $breack['CommissionEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$TotalExtraMarkup += isset($breack['ExtraMarkup']) ? $breack['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST += isset($breack['ExtraMarkupOnGST']) ? $breack['ExtraMarkupOnGST'] : 0;
$TotalExtraMarkup__ = isset($breack['ExtraMarkup']) ? $breack['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST__ = isset($breack['ExtraMarkupOnGST']) ? $breack['ExtraMarkupOnGST'] : 0;
$TaxTotal += $intTotalGST_ + $TotalExtraMarkupOnGST__;
$intGTXMarkUp = $breack['intGTXMarkUp'];
$GTXMarkUpGST = $breack['GTXMarkUpGST'];
$apiTaxOnMarkup = $breack['apiTaxOnMarkup'];
$intTotalGST = $breack['intTotalGST'];
$apiMarkup = $breack['apiMarkup'];
$DiscountValue_ = isset($breack['DiscountValue']) ? $breack['DiscountValue'] : 0;
$CommisionPass = isset($breack['CommisionPass']) ? $breack['CommisionPass'] : 0;
$OtherCharges_ = isset($breack['OtherCharges']) ? $breack['OtherCharges'] : 0;
$TDS = $breack['TDS'];
$MF = $breack['MF']; //Management Fee
$YQ = $breack['YQ']; //Fuel Surcharge
$AGST = $breack['AGST']; //Airline GST Component
$MFT = $breack['MFT']; //Management Fee Tax
$OT = $breack['OT']; //Other Charges
$MU = $breack['MU']; //Markup
$YR = $breack['YR']; //Carrier Misc Fee
$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
if ($ICSourceSysId_ == 3) {
$otherCharge = ($AGST + $MFT + $MF + $OT + $YR);
}
$FixedMarkUp = $breack['FixedMarkUp'];
$GSTOnMarkUp = $breack['GSTOnMarkUp'];
$paxPublishedFare = ($PBaseFare);
$PassengerType = $breack['PassengerType'];
$PassengerCount = $breack['PassengerCount'];
$BaseFare = ($breack['BaseFare'] / $PassengerCount);
$TaxesFees = ($MF + $YQ + $AGST + $MFT + $OT + $MU + $YR + $FixedMarkUp + $GSTOnMarkUp);
$PublishedFared = ($breack['BaseFareCal'] - $TaxIN - $FixedMarkUp - $GSTOnMarkUp);
$Total_CommiErn += ($CommEarned);
$TotalBaseFare += $PublishedFared;
if ($ICSourceSysId_ == 3) {
$B2BWalletbalance_ += ((($PBaseFare + $otherCharge + $TotalExtraMarkup__ + $TotalExtraMarkupOnGST__ + $FixedMarkUp + $GSTOnMarkUp + $OtherCharges_ + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST - $CommisionPass)) - $DiscountValue_);
} else {
$B2BWalletbalance_ += ((($PBaseFare + $otherCharge + $TotalExtraMarkup__ + $TotalExtraMarkupOnGST__ + $FixedMarkUp + $GSTOnMarkUp + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST)) - $DiscountValue_);
}
}
}
$ExtraMarkup__ = isset($value['FairRules']['ExtraMarkup']) ? $value['FairRules']['ExtraMarkup'] * $this->CurrencyRate : 0;
$ExtraMarkupOnGST__ = isset($value['FairRules']['ExtraMarkupOnGST']) ? $value['FairRules']['ExtraMarkupOnGST'] * $this->CurrencyRate : 0;
$DiscountValue__ = isset($value['FairRules']['DiscountValue']) ? $value['FairRules']['DiscountValue'] * $this->CurrencyRate : 0;
$PublishedFare__ = isset($value['FairRules']['PublishedFare']) ? $value['FairRules']['PublishedFare'] : 0;
$FixedMarkUp__ = isset($value['FairRules']['FixedMarkUp']) ? $value['FairRules']['FixedMarkUp'] * $this->CurrencyRate : 0;
$GSTOnMarkUp__ = isset($value['FairRules']['GSTOnMarkUp']) ? $value['FairRules']['GSTOnMarkUp'] * $this->CurrencyRate : 0;
$intTotalGST__ = isset($value['FairRules']['intTotalGST']) ? $value['FairRules']['intTotalGST'] * $this->CurrencyRate : 0;
$apiMarkup__ = isset($value['FairRules']['apiMarkup']) ? $value['FairRules']['apiMarkup'] * $this->CurrencyRate : 0;
$SourceAirportCode = $value['SourceAirportCode'];
$DestAirportCode = $value['DestAirportCode'];
$FlightNumber = $value['FlightNumber'];
$AirlineName = $value['AirlineName'];
$FixedMarkUp__ = $FixedMarkUp__ + $ExtraMarkup__;
$intTotalGST__ = $intTotalGST__ + $ExtraMarkupOnGST__;
$PublishedFare__ = $PublishedFare__ + $ExtraMarkup__ + $ExtraMarkupOnGST__ - $DiscountValue__;
$Description = $SourceAirportCode . '-' . $DestAirportCode . '-' . $AirlineName . ' ' . $FlightNumber;
$TotalFare = ($PublishedFare__ - $FixedMarkUp__ - $intTotalGST__ - $apiMarkup__);
$TotalAmount = $PublishedFare__;
$TotalGST = ($intTotalGST__);
$SubTotal = ($PublishedFare__ - $TotalGST);
$TotalFixedMarkUp = $FixedMarkUp__ + $apiMarkup__;
$TotalcouponVal = $DiscountValue__;
$PublishedFare += $PublishedFare__;
$TotalDiscount += $DiscountValue__;
$misxItems_name[] = [
'AgencySysId' => $this->intLoggedinAgencyId,
'AgentSysId' => $this->intLoggedinUserId,
'MisxItems_name' => 'Flight',
'Description' => $Description,
'ItemQty' => 1,
'ItemRates' => round(($TotalFare), 2),
'Total' => round(($TotalFare), 2),
'DiscountType' => 1,
'Discount' => 1,
'TotalDiscount' => round(($TotalcouponVal), 2),
'TotalAmount' => round(($TotalAmount), 2),
'MarkupType' => '',
'Markup' => round(($TotalFixedMarkUp), 2),
'TotalMarkup' => round(($TotalFixedMarkUp), 2),
'SubTotal' => round(($SubTotal), 2),
'ServiceFeeTotal' => 0,
'GSTPercentage' => '18',
'TotalGST' => round($TotalGST, 2),
'SGST' => round((($TotalGST / 2)), 2),
'CGST' => round((($TotalGST / 2)), 2),
'IGST' => round(($TotalGST), 2),
'ItemsSACCode' => '',
];
}
}
// echo "<pre>";
// print_r($TotalCostTotal);
// die;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$AgencySysId__ = isset($customerDetails['AgencySysId']) ? $customerDetails['AgencySysId'] : 0;
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$IsEnabledWallet = isset($customerDetails['IsEnabledWallet']) ? $customerDetails['IsEnabledWallet'] : 0;
$CustomerSysId = isset($customerDetails['CustomerSysId']) ? $customerDetails['CustomerSysId'] : 0;
$agencyMarkUpGST = $TaxTotal;
$TotalDiscount = 0;
$PublishedFare = ($PublishedFare + $BagPrice + $MealPrice + $SeatPrice);
$B2BWalletbalance = $PublishedFare;//($PublishedFare + $BagPrice + $MealPrice + $SeatPrice);
// if ($IsB2BCustomer == 1) {
// $B2BWalletbalance = ($PublishedFare + $BagPrice + $MealPrice + $SeatPrice);
// }
$TotalInvoiceValue = ($PublishedFare - $agencyMarkUpGST);
// echo "<pre>";
// print_r($B2BWalletbalance);
// echo "<pre>";
// print_r($PublishedFare);
// die;
$model = new Gtxwebservices_Model_Webservices();
if ($IsB2BCustomer == 1) {
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId__);
$AgentUserDetail = $crmcustomerObj->getAgentDetailById($AgencySysId__);
$UserSysId = isset($AgentUserDetail[0]['UserSysId']) ? $AgentUserDetail[0]['UserSysId'] : 0;
$B2BAgencySysIdKey = $getAgencyDetail['SecurityKey'];
$B2CAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$apiDataIV = array(
"B2BAgencySysIdKey" => $B2BAgencySysIdKey,
"B2CAgencySysIdKey" => $B2CAgencySysIdKey,
);
$result = json_decode($model->GetB2Bbalance($apiDataIV), true);
$creditBalance = isset($result['creditBalance']) ? $result['creditBalance'] : 0;
// if ($IsB2BCustomer == 1 && $paymentModebyUser == 2) {
// $addCreditBalance = ($B2BWalletbalance - $creditBalance);
// if ($addCreditBalance > 0) {
// $B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId__);
// $B2BAgencySysIdKey = $getAgencyDetail['SecurityKey'];
// $B2CAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
// $UpdateCreditData = array(
// "remark" => 'Add Fund',
// "b2bSecurityKey" => $B2CAgencySysIdKey,
// "CreditAmount" => $addCreditBalance,
// "agentId" => $AgencySysId__,
// "PaymentMode" => 'Add Credit Pay Later',
// "PlanType" => 1,
// "RefrenceNo" => $bookingId,
// );
// $UpdateCredit = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->UpdateCredit($UpdateCreditData, $B2BAgencySysIdKey);
// $UpdateCreditStatus = (isset($UpdateCredit['status']) && !empty($UpdateCredit['status'])) ? $UpdateCredit['status'] : 0;
// if ($UpdateCreditStatus == 0) {
// $response = array('success' => false, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => 'Oops something went wrong. We are wroking on it.');
// echo json_encode($response);
// exit;
// }
// }
// }
//if($paymentModebyUser == 1){
// $result = json_decode($model->GetB2Bbalance($apiDataIV), true);
//git $B2BwalletBalanceAmount = isset($result['creditBalance']) ? $result['creditBalance'] : 0;
$URL_ = $this->baseUrl . '/webservice/credit-balance/update-credit-balance-for-offline-request/';
// if ($B2BwalletBalanceAmount >= $B2BWalletbalance) {
$updateCreditBalance = array(
'B2BAgencySysIdKey' => $B2BAgencySysIdKey,
'B2CAgencySysIdKey' => $B2CAgencySysIdKey,
'Remark' => 'Flight Booking ',
'Amount' => $B2BWalletbalance,
'PlanType' => 1, // for flight
'UserSysId' => $UserSysId,
'PaymentMode' => 'Online Wallet',
'RefrenceNo' => $bookingId,
'CurrencyType' => $this->CurrencyId,
'FlightTraceId' => $strUrlData,
'IsPayLater' => true
);
//echo "<pre>";print_r($updateCreditBalance);die;
$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->DebitFromWallet($updateCreditBalance, $URL_, $AgencySysId__);
$TransactionId = isset($updateBalance['TransactionId']) ? $updateBalance['TransactionId'] : 0;
// } else {
// $response = array('success' => false, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => 'Agent does not have sufficient Credit Balance. Use Pay Later or Ask agent to top up balance.', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId . "");
// echo json_encode($response);
// exit;
// }
//}
} elseif ($IsEnabledWallet == 1 && $paymentModebyUser == 1) {
$apiDataIV = array(
"CustomerSysId" => $CustomerSysId,
);
$result = json_decode($model->GetB2Cbalance($apiDataIV, $this->agencyDetails['SecurityKey']), true);
$walletstatus = (isset($result['status']) && !empty($result['status'])) ? $result['status'] : 0;
$walletBalanceAmount = (isset($result['WalletBalance'][0]['BalanceAmount']) && !empty($result['WalletBalance'][0]['BalanceAmount'])) ? $result['WalletBalance'][0]['BalanceAmount'] : 0;
if ($walletstatus == 1) {
if ($walletBalanceAmount >= $PublishedFare) {
$DebitFromWallet = array(
'Remark' => 'Flight Booking ',
'Amount' => $PublishedFare,
'CustomerSysId' => $CustomerSysId,
'PlanType' => 1,
'PaymentMode' => 'Online Wallet',
'ReferenceNo' => $intTPSysId,
'CurrencyType' => $this->CurrencyId,
'FlightTraceId' => $strUrlData,
);
$URL_ = $this->baseUrl . '/gtxwebservices/customer-wallet/update-b2c-wallet-balance/';
$updateBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->B2CDebitFromWallet($DebitFromWallet, $URL_, $this->intLoggedinAgencyId, $this->agencyDetails['SecurityKey']);
$TransactionId = isset($updateBalance['TransactionId']) ? $updateBalance['TransactionId'] : 0;
} else {
$response = array('success' => false, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => 'Agent does not have sufficient Credit Balance. Use Pay Later or Ask customer to top up balance.', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId . "");
echo json_encode($response);
exit;
}
}
}
// echo "<pre>";
// print_r($PublishedFare);
// die;
$itemCount = count($misxItems_name);
if (!empty($BagPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Baggage',
'ItemQty' => 1,
'ItemRates' => ($BagPrice),
'Total' => $BagPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $BagPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$itemCount = count($misxItems_name);
if (!empty($MealPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Meal',
'ItemQty' => 1,
'ItemRates' => ($MealPrice),
'Total' => $MealPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $MealPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$itemCount = count($misxItems_name);
if (!empty($SeatPrice)) {
$misxItems_name[$itemCount] = array(
'MisxItems_name' => 'Add ons',
'Description' => 'Seat',
'ItemQty' => 1,
'ItemRates' => ($SeatPrice),
'Total' => $SeatPrice,
'DiscountType' => 0,
'Discount' => 0,
'TotalDiscount' => 0,
'TotalAmount' => 0,
'MarkupType' => '',
'Markup' => 0,
'TotalMarkup' => 0,
'SubTotal' => $SeatPrice,
'ServiceFeeTotal' => 0,
'GSTPercentage' => 0,
'TotalGST' => 0,
'SGST' => 0,
'CGST' => 0,
'IGST' => 0,
'ItemsSACCode' => '',
);
}
$Invoicedata = [
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $intCustomerSysId,
'TPSysId' => $intTPSysId,
'MasterTPSysId' => $MasterTPSysId,
'ProposalID' => $intTPSysId . '/V1',
'InvoiceDate' => date('Y-m-d'),
'isDisplayMarkup' => true,
'PaymentDueDate' => date('Y-m-d'),
'PaymentDate' => date('Y-m-d'),
'ClientGST' => $isgstapply,
'ClientGSTNumber' => $GstNumber,
'Currency' => $CurrencyType,
'TotalInvoiceValue' => round(($TotalInvoiceValue), 2),
'InvoiceStatus' => ($checkPaymentStatus == 1) ? 1 : 5,
'TotalSGST' => ($gstvalidate['SGST'] == 1) ? round((($agencyMarkUpGST / 2)), 2) : 0,
'TotalCGST' => ($gstvalidate['CGST'] == 1) ? round((($agencyMarkUpGST / 2)), 2) : 0,
'TotalIGST' => ($gstvalidate['IGST'] == 1) ? round(($agencyMarkUpGST), 2) : 0,
'SumdiscountItem' => 0,
'OtherDiscount' => round(($TotalDiscount), 2),
'otherDiscountVal' => round(($TotalDiscount), 2),
'TotalAdvance' => ($checkPaymentStatus == 1) ? round(($PublishedFare), 2) : 0,
'TotalDueAmount' => ($checkPaymentStatus == 1) ? 0 : round(($PublishedFare), 2),
'InvoiceValue' => round(($PublishedFare), 2),
'notes' => 'Flight Ticket',
'termsandcondition' => '',
'client_state' => '',
'Advance' => 0,
'PaymentType' => 4,
'paymentNote' => 'Online',
'misxItems_name' => $misxItems_name,
];
$addonFlightData = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'TPSysId' => $TPSysId,
'CustomerSysId' => $intCustomerSysId,
'CurrencyType' => $CurrencyType,
'GSTTYPE' => $GSTTYPE,
'ServiceTitle' => 'Flight',
'Tax' => $TaxTotal,
'Cost' => ($TotalCostTotal - $TaxTotal - $MarkupTotal),
'Markup' => $MarkupTotal,
'TotalCost' => $TotalCostTotal,
);
$this->ExtraAddAddons($addonFlightData);
if ($BagPrice && $BagPrice > 0) {
$addonFlightData = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'TPSysId' => $TPSysId,
'CustomerSysId' => $intCustomerSysId,
'CurrencyType' => $CurrencyType,
'GSTTYPE' => $GSTTYPE,
'ServiceTitle' => 'Baggage',
'Tax' => 0,
'Cost' => ($BagPrice),
'Markup' => 0,
'TotalCost' => $BagPrice,
);
$this->ExtraAddAddons($addonFlightData);
}
if ($MealPrice && $MealPrice > 0) {
$addonFlightData = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'TPSysId' => $TPSysId,
'CustomerSysId' => $intCustomerSysId,
'CurrencyType' => $CurrencyType,
'GSTTYPE' => $GSTTYPE,
'ServiceTitle' => 'Meal',
'Tax' => 0,
'Cost' => ($MealPrice),
'Markup' => 0,
'TotalCost' => $MealPrice,
);
$this->ExtraAddAddons($addonFlightData);
}
if ($SeatPrice && $SeatPrice > 0) {
$addonFlightData = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'TPSysId' => $TPSysId,
'CustomerSysId' => $intCustomerSysId,
'CurrencyType' => $CurrencyType,
'GSTTYPE' => $GSTTYPE,
'ServiceTitle' => 'Seat',
'Tax' => 0,
'Cost' => ($SeatPrice),
'Markup' => 0,
'TotalCost' => $SeatPrice,
);
$this->ExtraAddAddons($addonFlightData);
}
$IsSeriesFareData = isset($intOutBoundId[0]['IsSeriesFareData']) ? $intOutBoundId[0]['IsSeriesFareData'] : 0;
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1 && $route == 1) {
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$SecurityKey = $arrAgentDetail['SecurityKey'];
Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($intOutBoundId[0]['bookingId'], $SecurityKey);
}
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1 && $route == 2) {
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$SecurityKey = $arrAgentDetail['SecurityKey'];
Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckSoldInventory($intOutBoundId[1]['bookingId'], $SecurityKey);
}
$intInBoundId = !empty($arrUrlData['intInBoundId']) ? $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$IsTripjack = isset($arrUrlData['IsTripjack']) ? $arrUrlData['IsTripjack'] : 0;
$SearchTraceId = $intOutBoundId[0]['SearchTraceId'];
$IsTJFlightAPI = isset($intOutBoundId[0]['IsTJFlightAPI']) ? $intOutBoundId[0]['IsTJFlightAPI'] : 0;
$AirInvenSysIdArr = $arrUrlData['AirInvenSysIdArr'];
$TravelArray = [];
if ($arrTrevllerList) {
foreach ($arrTrevllerList as $KT => $travel) {
$TravelArray[$travel['IsReturn']][$KT] = $travel;
}
}
$TrevllerList = array_map('array_values', $TravelArray);
try {
$IsTripjack = 1;
if ($IsTripjack == 1) {
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$BookingdataAPI = array(
'FlightBookingData' => $intOutBoundId,
'IsInternational' => $intOutBoundId[0]['IsInternational'],
'CustomerSession' => $arrTrevllerDetails,
'ForCustomerSession' => $ForCustomerSession[0],
'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
);
if ($IsSeriesFareData == 1 || $ICSourceSysId_ == 9) {
$Bookres = [
'status' => array('success' => true),
];
} else {
if ($IsTJFlightAPI == 1) {
$Bookres = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicketTripJack($BookingdataAPI, $this->intLoggedinAgencyId);
} else { //// TBO booking start
$IsLCC__ = false;
if ($BookingData) {
$IsLCC__ = false;
$travelPlanDetais = $this->_crmcusttravelplan->CheckCustomerWithLeadId($intTPSysId);
$FlightBookingTicketArr = [];
$PassengerArray = [];
$responseReturn = [];
$CreditIntoWallet = [];
foreach ($BookingData as $k => $value) {
$Sectorss = [];
$SeatPrice = 0;
$BagPrice = 0;
$MealPrice = 0;
$SelectedBagAr = [];
$SelectedMealAr = [];
$SelectedSeatAr = [];
if($value['Segments']){
foreach($value['Segments'] as $seg){
$Sectorss[] = $seg['originAirportCode'].'-'.$seg['destinationAirportCode'];
$originAirportCode = $seg['originAirportCode'];
$destinationAirportCode = $seg['destinationAirportCode'];
if (!empty($selectedSeatSession) && isset($selectedSeatSession[$seg['segmentid']]) && !empty($selectedSeatSession[$seg['segmentid']])) {
$selectedSeat = $selectedSeatSession[$seg['segmentid']];
foreach ($selectedSeat as $val) {
$SeatPrice += $val['amount'];
$Orgin = $val['Origin'];
$Destination = $val['Destination'];
$SelectedSeatAr[$Orgin.'-'.$Destination][] = $val;
}
}
if (!empty($SelectedBaggSessionNew) && isset($SelectedBaggSessionNew[$seg['segmentid']]) && !empty($SelectedBaggSessionNew[$seg['segmentid']])) {
$selectedBag = $SelectedBaggSessionNew[$seg['segmentid']];
foreach ($selectedBag as $val) {
$BagPrice += $val['Price'];
$Orgin = $val['Origin'];
$Destination = $val['Destination'];
$SelectedBagAr[$Orgin.'-'.$Destination][] = $val;
}
}
if (!empty($SelectedMealSessionNew) && isset($SelectedMealSessionNew[$seg['segmentid']]) && !empty($SelectedMealSessionNew[$seg['segmentid']])) {
$selectedMeal = $SelectedMealSessionNew[$seg['segmentid']];
foreach ($selectedMeal as $val) {
$MealPrice += $val['Price'];
$Orgin = $val['Origin'];
$Destination = $val['Destination'];
$SelectedMealAr[$Orgin.'-'.$Destination][] = $val;
}
}
}
}
$TPintSysId = isset($arrIntTpAirId[$k])?$arrIntTpAirId[$k]:0;
$checkNonLccBooking = $objFlight->checkNonLccBooking($TPintSysId);
$APIBookingRes__ = isset($checkNonLccBooking['APIBookingRes']) ? json_decode($checkNonLccBooking['APIBookingRes'], true) : [];
$IsBookingStatus = isset($checkNonLccBooking['IsBookingStatus']) ? $checkNonLccBooking['IsBookingStatus'] : 0;
$BookingdataAPI = array(
'FlightBookingData' => $value,
'sessionFlightSearchParams' => $sessionFlightSearchParams,
'ForCustomerSession' => $ForCustomerSession,
'CustomerSession' => $arrTrevllerDetails,
'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
);
if ($value['IsLCC'] == 1 || $value['IsLCC'] == '1') {
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($BookingdataAPI, $this->intLoggedinAgencyId);
} else {
$IsLCC__ = false;
$API_Response_Ticket = $APIBookingRes__['response']; //Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $this->intLoggedinAgencyId);
$apiTraceId = isset($API_Response_Ticket['Response']['TraceId']) ? $API_Response_Ticket['Response']['TraceId'] : '0';
$strBookingIdLCC = isset($API_Response_Ticket['Response']['Response']['BookingId']) ? $API_Response_Ticket['Response']['Response']['BookingId'] : '';
$strTicketPNRLCC = isset($API_Response_Ticket['Response']['Response']['PNR']) ? $API_Response_Ticket['Response']['Response']['PNR'] : '';
$dataTicket = [
"TraceId" => $apiTraceId,
"PNR" => $strTicketPNRLCC,
"BookingId" => $strBookingIdLCC,
"FlightBookingData" => $value,
];
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($dataTicket, $this->intLoggedinAgencyId);
}
///echo "<pre>";print_r(json_encode($response));
//$apiFlightTicketTemp = new Zend_Session_Namespace('apiFlightTicketTemp');
//$response = $apiFlightTicketTemp->params[$k];
// $apiFlightTicket = new Zend_Session_Namespace('apiFlightTicket');
// $response = $apiFlightTicket->params;
$FlightBookingTicketArr[$k] = $response;
$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
$Passenger = $PassengerArray[] = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : '';
$SegmentsAPI = isset($response['Response']['Response']['FlightItinerary']['Segments']) ? $response['Response']['Response']['FlightItinerary']['Segments'] : '';
$statusType = 1;
$customerpnr = [];
$GDSpnr = [];
if ($Passenger) {
$PNR_Number = [];
$kkkk = 0;
foreach($Sectorss as $sgvl){
$PNR_Number[] = $strTicketPNRLCC;
if((isset($SegmentsAPI[$kkkk]['AirlinePNR']) && !empty($SegmentsAPI[$kkkk]['AirlinePNR']))){
$GDSpnr[] = (isset($SegmentsAPI[$kkkk]['AirlinePNR']) && !empty($SegmentsAPI[$kkkk]['AirlinePNR']))?$SegmentsAPI[$kkkk]['AirlinePNR']:'';
}
$kkkk++;
}
foreach ($Passenger as $pk => $pax) {
$PaxType = $pax['PaxType'];
$TicketId = $pax['Ticket']['TicketId'];
$TicketNumber = [];
$TicketId = [];
$ValidatingAirline = (isset($pax['Ticket']['ValidatingAirline']) && !empty($pax['Ticket']['ValidatingAirline']))?$pax['Ticket']['ValidatingAirline']:'';
foreach($Sectorss as $sgvl){
$TicketNumber[] = $pax['Ticket']['TicketNumber'];
$TicketId[] = $pax['Ticket']['TicketId'];
}
$customerpnr[$pk]['PNR_Number'] = implode('-', $PNR_Number);
$customerpnr[$pk]['TicketId'] = implode('-', $TicketId);
$customerpnr[$pk]['TicketNumber'] = implode('-', $TicketNumber);
$customerpnr[$pk]['sectors'] = implode('@@', $Sectorss);
$SelectedBag_ = [];
$SelectedMeal_ = [];
$SelectedSeat_ = [];
$BagPrice_ = 0;
$MealPrice_ = 0;
$SeatPrice_ = 0;
if($SelectedBagAr){
foreach($SelectedBagAr as $scs=>$vall){
$SelectedBag_[$scs][] = !empty($vall[$pk])?$vall[$pk]:[];
$BagPrice_ += !empty($vall[$pk]['Price'])?$vall[$pk]['Price']:0;
}
}
if($SelectedMealAr){
foreach($SelectedMealAr as $scs=>$vall){
$SelectedMeal_[$scs][] = !empty($vall[$pk])?$vall[$pk]:[];
$MealPrice_ += !empty($vall[$pk]['Price'])?$vall[$pk]['Price']:0;
}
}
if($SelectedSeatAr){
foreach($SelectedSeatAr as $scs=>$vall){
$SelectedSeat_[$scs][] = !empty($vall[$pk])?$vall[$pk]:[];
$SeatPrice_ += !empty($vall[$pk]['amount'])?$vall[$pk]['amount']:0;
}
}
if($PaxType != 3){
$customerpnr[$pk]['SelectedBag'] = !empty($SelectedBag_) ? json_encode($SelectedBag_) :'';
$customerpnr[$pk]['SelectedMeal'] = !empty($SelectedMeal_) ? json_encode($SelectedMeal_) :'';
$customerpnr[$pk]['SelectedSeat'] = !empty($SelectedSeat_) ? json_encode($SelectedSeat_) :'';
$customerpnr[$pk]['BagPrice'] = !empty($BagPrice_) ? ($BagPrice_) :0;
$customerpnr[$pk]['MealPrice'] = !empty($MealPrice_) ? ($MealPrice_) :0;
$customerpnr[$pk]['SeatPrice'] = !empty($SeatPrice_) ? ($SeatPrice_) :0;
}
}
}
if ($ResponseStatus == 1) {
if ($k == 0) {
if ($checkPaymentStatus == 0) {
$modelAgency = new Travel_Model_TblAgencyCustomerTrx();
$modelAgency->updateFirstEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId);
} else {
$modelAgency = new Travel_Model_TblAgencyCustomerTrx();
$modelAgency->updateFirstEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId);
$modelAgency->updateSecondEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId, $TrxSysId, $PublishedFare);
}
}
Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData, $this->agencyDetails['SecurityKey'], $this->intLoggedinAgencyId);
if ($checkPaymentStatus == 0) {
$PaymentStatus = 122; //($ICSourceSysId_ == 9)?122:23;
$StatusType = 104; //($ICSourceSysId_ == 9)?104:13;
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => $StatusType, 'PaymentStatus' => $PaymentStatus, 'BookingStatus' => 142), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
} else {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17', 'PaymentStatus' => 130, 'BookingStatus' => 142), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
}
//echo "<pre>";print_r($intTPSysId);die;
///$TPintSysId = $arrIntTpAirId[$k];
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => $strTicketPNRLCC,
"XRefBookingId" => $strBookingIdLCC,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
// UPDATE WALLET REFERENCE NUMBER 03-03-2023
if ($TransactionId && $k == 0 && $IsB2BCustomer == 1) {
$dataTrans = array(
"RefrenceNo" => $strBookingIdLCC,
);
$objFlight->updateWalletData($dataTrans, $TransactionId);
}
if (isset($TrevllerList[$k]) && !empty($TrevllerList[$k]) && $ResponseStatus == 1) {
foreach ($TrevllerList[$k] as $key => $value) {
$paxPNRData = $customerpnr[$key];
$pax = $Passenger[$key];
$TicketId = $pax['Ticket']['TicketId'];
$TicketNumber = $pax['Ticket']['TicketNumber'];
$data = array(
"TicketId" => !empty($TicketId) ? $TicketId : '',
"TicketNumber" => $TicketNumber,
"Sectors" =>implode('@@',$Sectorss),
"TicketFullJson" => json_encode($pax)
);
if(isset($customerpnr[$key]['TicketId']) && !empty($customerpnr[$key]['TicketId'])){
$data['TicketId'] = $customerpnr[$key]['TicketId'];
}
if(isset($customerpnr[$key]['TicketNumber']) && !empty($customerpnr[$key]['TicketNumber'])){
$data['TicketNumber'] = $customerpnr[$key]['TicketNumber'];
}
if(isset($customerpnr[$key]['sectors']) && !empty($customerpnr[$key]['sectors'])){
$data['Sectors'] = $customerpnr[$key]['sectors'];
}
if(isset($customerpnr[$key]['SelectedBag']) && !empty($customerpnr[$key]['SelectedBag'])){
$data['SelectedBag'] = $customerpnr[$key]['SelectedBag'];
}
if(isset($customerpnr[$key]['SelectedMeal']) && !empty($customerpnr[$key]['SelectedMeal'])){
$data['SelectedMeal'] = $customerpnr[$key]['SelectedMeal'];
}
if(isset($customerpnr[$key]['SelectedSeat']) && !empty($customerpnr[$key]['SelectedSeat'])){
$data['SelectedSeat'] = $customerpnr[$key]['SelectedSeat'];
}
if(isset($customerpnr[$key]['BagPrice']) && !empty($customerpnr[$key]['BagPrice'])){
$data['BagPrice'] = $BagPrice;
}
if(isset($customerpnr[$key]['MealPrice']) && !empty($customerpnr[$key]['MealPrice'])){
$data['MealPrice'] = $MealPrice;
}
if(isset($customerpnr[$key]['SeatPrice']) && !empty($customerpnr[$key]['SeatPrice'])){
$data['SeatPrice'] = $SeatPrice;
}
//echo "<pre>";print_r($data);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']); // FOR TRAVELLERS DETAILS CONFIRMED
}
}
$responseReturn[$k] = array('success' => true, 'message' => $ErrorMessage, 'IsLCC' => $IsLCC__);
} else {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '70', 'PaymentStatus' => 22, 'BookingStatus' => 141), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING Fail
if ($IsB2BCustomer == 1 && $k == 0) {
$dataArray = array(
'B2BAgencySysIdKey' => $B2CAgencySysIdKey,
'B2CAgencySysIdKey' => $B2BAgencySysIdKey,
'PaymentMode' => 'Wallet Refund',
'Amount' => $B2BWalletbalance,
'RefrenceNo' => $bookingId,
'CreditDate' => date('Y-m-d'),
'Remark' => 'Refund',
'PlanType' => 7,
'CurrencyType' => $this->CurrencyId,
'UserSysId' => $UserSysId,
'FlightTraceId' => $strUrlData,
);
$URL_CREDIT = $this->baseUrl . '/webservice/credit-balance/save-online-request/';
$CreditIntoWallet = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreditIntoWallet($dataArray, $URL_CREDIT, $AgencySysId__);
} elseif ($IsEnabledWallet == 1 && $paymentModebyUser == 1 && $k == 0) {
$DebitFromWallet = array(
'Remark' => 'Refund',
'Amount' => $PublishedFare,
'CustomerSysId' => $CustomerSysId,
'PlanType' => 1,
'PaymentMode' => 'Wallet Refund',
'ReferenceNo' => $intTPSysId,
'CurrencyType' => $this->CurrencyId,
'FlightTraceId' => $strUrlData,
);
$URL_ = $this->baseUrl . '/gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
$CreditIntoWallet = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->B2CDebitFromWallet($DebitFromWallet, $URL_, $this->intLoggedinAgencyId, $this->agencyDetails['SecurityKey']);
}
$TPintSysId = $arrIntTpAirId[$k];
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => '',
"XRefBookingId" => $strBookingIdLCC,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => '',
"IsBookingStatus" => 0
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING FAILED
$responseReturn[$k] = array('success' => false, 'message' => $ErrorMessage, 'IsLCC' => $IsLCC__);
}
}
// echo "<pre>";print_r($responseReturn);
// echo "<pre>";print_r($IsLCC__);
// die('s');
$apiFlightTicketTemp = new Zend_Session_Namespace('apiFlightTicketTemp');
$apiFlightTicketTemp->params = $FlightBookingTicketArr;
$TrxStatus = array(
'TrxStatus' => 1,
'IsActive' => 1,
);
$TrxStatusCustomer = array(
'TrxStatus' => ($checkPaymentStatus == 0) ? 0 : 1,
'IsActive' => 1,
);
$objFlight->updateCustomerTrx($TrxStatusCustomer, $TrxSysId);
//$objFlight->updateCustomerTrx($TrxStatus, $TrxSysId);
$objFlight->updatetbtrx($TrxStatus, $TrxSysId);
$arrUrlData['customerSysId'] = $intCustomerSysId;
$arrUrlData['TPSysId'] = $TPSysId;
$arrUrlData['guid'] = $guid;
$arrUrlData['TrxSysId'] = $TrxSysId;
$arrUrlData['tripType'] = 1;
$arrUrlData['arrBookingResponse'] = json_encode($FlightBookingTicketArr);
$arrUrlData['CreditIntoWallet'] = json_encode($CreditIntoWallet);
$arrUrlData['intTPSysId'] = $intTPSysId;
$arrUrlData['arrIntTpAirId'] = $arrIntTpAirId;
$arrUrlData['TrxSysId'] = $TrxSysId;
$arrUrlData['IsTripjack'] = false;
$arrUrlData['responseReturn'] = $responseReturn;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrUrlData);
$arrUrlData['urlData'] = $strUrlData;
$arrUrlData['Invoicedata'] = $Invoicedata;
$arrUrlData['paymentModebyUser'] = $paymentModebyUser;
$arrUrlData['walletTransactionId'] = $TransactionId;
//echo "<pre>";print_r($arrUrlData);exit;
$tempData = array(
'TPSysId' => $TPSysId,
'TraceId' => $TrackId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($TrackId);
$objFlight->insertFlightTempData($tempData);
$response = array('success' => true, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => '', 'IsLCC' => $IsLCC__, 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId . "?status=true");
echo json_encode($response);
exit;
}
}
}
//$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($intOutBoundId, $ForCustomerSession);
// echo "<pre>";print_r($Bookres);
// echo "<pre>";print_r($response);
// die;
//$FlightBookingTicket = new Zend_Session_Namespace('FlightBookingTicket');
//$Bookres = $FlightBookingTicket->params;
// echo "<pre>";print_r($Bookres);
// die('s');
$BookStatus = $Bookres['status']['success'];
$BookErrorMessage = $Bookres['errors'][0]['message'];
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$travelPlanDetais = $this->_crmcusttravelplan->CheckCustomerWithLeadId($intTPSysId);
if ($BookStatus == 1) {
if ($checkPaymentStatus == 0) {
$modelAgency = new Travel_Model_TblAgencyCustomerTrx();
$modelAgency->updateFirstEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId);
} else {
$modelAgency = new Travel_Model_TblAgencyCustomerTrx();
$modelAgency->updateFirstEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId);
$modelAgency->updateSecondEntryInBalanceSheet($intTPSysId, $this->intLoggedinAgencyId, $TrxSysId, $PublishedFare);
}
//if($bookingAllowed != 2){ // As per discussion with PK & GG
// New Invoice Entry
Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->InvoiceCreate($Invoicedata, $BookingData, $this->agencyDetails['SecurityKey'], $this->intLoggedinAgencyId);
//}
$objTrx = new Travel_Model_TblAgencyCustomerTrx();
// comment by prashant
//$strInvoiceNumber = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->generateInvoiceNumbers($this->intLoggedinAgencyId);
//$data = array("InvoiceId" => $strInvoiceNumber);
//$objTrx->updateInvoiceNumber($data, $TrxSysId);
//$dataInvoice = [
//"AgencySysId" => $this->intLoggedinAgencyId,
//"InvoiceNumber" => $strInvoiceNumber,
//"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
//];
// $objTrx->insertInvoiceNumber($dataInvoice);
if ($IsSeriesFareData == 1 || $ICSourceSysId_ == 9) {
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsSeriesFareNew($intOutBoundId, $ForCustomerSession);
} else {
$Bookres['FlightBookingData'] = $intOutBoundId;
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres, $this->intLoggedinAgencyId);
}
// echo "<pre>dd";echo json_encode($response);die;
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$ResponseStatus = isset($response['status']['success']) ? $response['status']['success'] : '0';
$strTicketPNRLCC = isset($response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails']) ? $response['itemInfos']['AIR']['travellerInfos'][0]['pnrDetails'] : '';
$Passengers = isset($response['itemInfos']['AIR']['travellerInfos']) ? $response['itemInfos']['AIR']['travellerInfos'] : '';
$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
$ErrorMessage = isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '';
if ($checkPaymentStatus == 0) {
$PaymentStatus = 122; //($ICSourceSysId_ == 9)?122:23;
$StatusType = 104; //($ICSourceSysId_ == 9)?104:13;
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => $StatusType, 'PaymentStatus' => $PaymentStatus, 'BookingStatus' => 142), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
} else {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17', 'PaymentStatus' => 130, 'BookingStatus' => 142), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
}
$statusMap = [];
$TicketId = [];
$TicketNumber = [];
if ($Passengers) {
foreach ($Passengers as $pax) {
$statusMap = implode('-', isset($pax['statusMap']) ? $pax['statusMap'] : []);
$TicketId = implode('-', $pax['pnrDetails']);
$statusMap = implode('-', isset($pax['statusMap']) ? $pax['statusMap'] : []);
$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
}
}
$pnr = explode('-', $TicketId);
if (count($pnr) > 2) {
$PNR_Number = $pnr[0] . '-' . $pnr[1];
} else {
$PNR_Number = $pnr[0];
}
if ($BookingData) {
foreach ($BookingData as $k => $value) {
// Booking details to transaction table...
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1 || $ICSourceSysId_ == 9) {
$strBookingIdLCC = isset($response['order']['bookingId'][$k]) ? $response['order']['bookingId'][$k] : '0';
$PNR_Number = isset($pnr[$k]) ? $pnr[$k] : '';
} else {
$strBookingIdLCC = isset($response['order']['bookingId']) ? $response['order']['bookingId'] : '0';
}
$TPintSysId = $arrIntTpAirId[$k];
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => $PNR_Number,
"XRefBookingId" => $strBookingIdLCC,
// "XRefBookingId" => $strBookingIdLCC.'/'.$PNR_Number,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
}
}
$TrxStatus = array(
'TrxStatus' => 1,
'IsActive' => 1,
);
if ($ICSourceSysId_ != 9) {
}
$TrxStatusCustomer = array(
'TrxStatus' => ($checkPaymentStatus == 0) ? 0 : 1,
'IsActive' => 1,
);
$objFlight->updateCustomerTrx($TrxStatusCustomer, $TrxSysId);
$objFlight->updatetbtrx($TrxStatus, $TrxSysId);
if (isset($arrTrevllerList) && !empty($arrTrevllerList) && $ResponseStatus == 1) {
foreach ($arrTrevllerList as $key => $value) {
$pax = $Passengers[$key];
$flipsector = [];
if($pax['pnrDetails']){
foreach($pax['pnrDetails'] as $ksec=>$ab){
$flipsector[] = $ksec;
}
}
$TicketId = implode('-', $pax['pnrDetails']);
$statusMap = implode('-', $pax['statusMap']);
$Sectors = implode('@@', $flipsector);
$TicketNumber = isset($pax['ticketNumberDetails']) ? implode('-', $pax['ticketNumberDetails']) : '';
$data = array(
"TicketId" => !empty($TicketId) ? $TicketId : '',
"TicketNumber" => $TicketNumber,
"Sectors" => $Sectors,
"TicketFullJson" => json_encode($Passengers)
);
// echo "<pre>";print_r($data);
// die('s');
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
$arrUrlData['customerSysId'] = $intCustomerSysId;
$arrUrlData['TPSysId'] = $TPSysId;
$arrUrlData['guid'] = $guid;
$arrUrlData['TrxSysId'] = $TrxSysId;
$arrUrlData['tripType'] = 1;
$arrUrlData['arrBookingResponse'] = json_encode($response);
$arrUrlData['intTPSysId'] = $intTPSysId;
$arrUrlData['arrIntTpAirId'] = $arrIntTpAirId;
$arrUrlData['IsTripjack'] = true;
$arrUrlData['Invoicedata'] = $Invoicedata;
$arrUrlData['paymentModebyUser'] = $paymentModebyUser;
$arrUrlData['walletTransactionId'] = $TransactionId;
$arrUrlData['guid'] = $guid;
$arrUrlData['TrxSysId'] = $TrxSysId;
$arrUrlData['IsTripjack'] = true;
//echo "<pre>";print_r($arrUrlData);exit;
$tempData = array(
'TPSysId' => $TPSysId,
'TraceId' => $TrackId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($TrackId);
$objFlight->insertFlightTempData($tempData);
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => '', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId . "?status=true");
echo json_encode($response);
exit;
} else {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '70', 'PaymentStatus' => 22, 'BookingStatus' => 141), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING Fail CAse
// Booking details to transaction table...
if ($IsB2BCustomer == 1) {
$dataArray = array(
'B2BAgencySysIdKey' => $B2CAgencySysIdKey,
'B2CAgencySysIdKey' => $B2BAgencySysIdKey,
'PaymentMode' => 'Wallet Refund',
'Amount' => $B2BWalletbalance,
'RefrenceNo' => $bookingId,
'CreditDate' => date('Y-m-d'),
'Remark' => 'Refund',
'PlanType' => 7,
'CurrencyType' => $this->CurrencyId,
'UserSysId' => $UserSysId,
'FlightTraceId' => $strUrlData,
);
$URL_CREDIT = $this->baseUrl . '/webservice/credit-balance/save-online-request/';
$CreditIntoWallet = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CreditIntoWallet($dataArray, $URL_CREDIT, $AgencySysId__);
} elseif ($IsEnabledWallet == 1 && $paymentModebyUser == 1) {
$DebitFromWallet = array(
'Remark' => 'Refund',
'Amount' => $PublishedFare,
'CustomerSysId' => $CustomerSysId,
'PlanType' => 1,
'PaymentMode' => 'Wallet Refund',
'ReferenceNo' => $intTPSysId,
'CurrencyType' => $this->CurrencyId,
'FlightTraceId' => $strUrlData,
);
$URL_ = $this->baseUrl . '/gtxwebservices/customer-wallet/add-b2c-wallet-balance/';
$CreditIntoWallet = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->B2CDebitFromWallet($DebitFromWallet, $URL_, $this->intLoggedinAgencyId, $this->agencyDetails['SecurityKey']);
}
if ($BookingData) {
foreach ($BookingData as $k => $value) {
// Booking details to transaction table...
$TPintSysId = $arrIntTpAirId[$k];
$responseArray = array(
'value' => $value,
'response' => $Bookres
);
$data = array(
"XRefBookingId" => '',
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => '',
"IsBookingStatus" => 0
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING FAILED
}
}
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = 0;
$arrData['outBoundIdForRefund'] = $intOutBoundId;
$arrData['inBoundIdForRefund'] = 0;
$arrData['arrBookingResponse'] = json_encode($Bookres);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
$arrData['AirInvenSysIdArr'] = $AirInvenSysIdArr;
$arrData['SelectedBaggSessionNew'] = $SelectedBaggSessionNew;
$arrData['SelectedMealSessionNew'] = $SelectedMealSessionNew;
$arrData['selectedSeatSession'] = $selectedSeatSession;
$arrData['sessionFlightSearchParams'] = $sessionFlightSearchParams;
$arrData['IsTripjack'] = true;
$arrData['walletTransactionId'] = $TransactionId;
$arrData['CreditIntoWallet'] = json_encode($CreditIntoWallet);
if ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1) {
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => $BookErrorMessage, 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId);
echo json_encode($response);
exit;
} else {
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'TrackId' => $TrackId, 'IsTJFlightAPI' => $IsTJFlightAPI, 'msg' => $BookErrorMessage, 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
}
}
//echo '<pre>';print_r($arrUrlData);echo '</pre>';
// die('fdgdf');
} else {
//Invoice Number...
$objTrx = new Travel_Model_TblAgencyCustomerTrx();
// comment by prashant
// $strInvoiceNumber = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->generateInvoiceNumbers($this->intLoggedinAgencyId);
// $data = array("InvoiceId" => $strInvoiceNumber);
// $objTrx->updateInvoiceNumber($data, $TrxSysId);
// $dataInvoice = [
// "AgencySysId" => $this->intLoggedinAgencyId,
// "InvoiceNumber" => $strInvoiceNumber,
// "CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
// ];
// $objTrx->insertInvoiceNumber($dataInvoice);
//Invoice Number...
// Getting travel plan details...
$objFlight = new Travel_Model_TblFlight();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$travelPlanDetais = $this->_crmcusttravelplan->CheckCustomerWithLeadId($intTPSysId);
// Getting travel plan details Ends...
if (!empty($intOutBoundId) && !empty($intInBoundId)) { // For OneWay Flight Only...
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intOutBoundId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
if (!empty($arrSelectedFlightDetails)) {
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $intOutBoundId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
$data = array();
$arrBookingId = array();
$arrBookingResponse = array();
$apiTraceId = trim($arrSelectedFlightDetails[0]['apiTraceId']);
$ApiResultIndex = trim($arrSelectedFlightDetails[0]['ApiResultIndex']);
$SourceAirportCode = trim($arrSelectedFlightDetails[0]['SourceAirportCode']);
$DestAirportCode = trim($arrSelectedFlightDetails[0]['DestAirportCode']);
$IsLCC = trim($arrSelectedFlightDetails[0]['IsLCC']);
$JourneyType = trim($arrSelectedFlightDetails[0]['JourneyType']);
$TripType = trim($arrSelectedFlightDetails[0]['TripType']);
$IsInternational = isset($arrSelectedFlightDetails[0]['IsInternational']) ? trim($arrSelectedFlightDetails[0]['IsInternational']) : '0';
$IsGSTMandatory = isset($arrSelectedFlightDetails[0]['IsGSTMandatory']) ? trim($arrSelectedFlightDetails[0]['IsGSTMandatory']) : '0';
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$data = array(
"TraceId" => $apiTraceId,
"ResultIndex" => $ApiResultIndex,
"Origin" => $SourceAirportCode,
"Destination" => $DestAirportCode,
"JourneyType" => $JourneyType,
"TripType" => $TripType,
"IsLCC" => $IsLCC,
"arrFairDetails" => $arrSelectedFlightFareDetails,
"arrTrevllerDetails" => $arrTrevllerDetails,
"IsInternational" => $IsInternational,
"agencyEmailId" => $this->intLoggedinUserEmailId
);
if ($IsGSTMandatory == 1) {
$data['getAgencyDetail'] = $getAgencyDetail;
}
//echo "<pre>";print_r($arrSelectedFlightDetails);exit;
if ($IsLCC == '1') { //For LCC Flights Direct Ticket Method Called According to API...
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightTicket($data);
//echo "<pre>";print_r($response);exit;
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
//$arrBookingId[] = $strBookingId."/".$strTicketPNR;
if ($ErrorCode == 0) {
$arrBookingResponse[0]['ErrorCode'] = $ErrorCode;
$arrBookingResponse[0]['ErrorMessage'] = $ErrorMessage;
$arrBookingResponse[0]['BookingId'] = $strBookingIdLCC . "/" . $strTicketPNRLCC;
$arrBookingResponse[0]['BookingResponse'] = json_encode($response);
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
} else {
//echo "<pre>";print_r($response);exit;
$arrBookingResponse[0]['ErrorCode'] = $ErrorCode;
$arrBookingResponse[0]['ErrorMessage'] = $ErrorMessage;
$arrBookingResponse[0]['BookingId'] = $strBookingIdLCC . "/" . $strTicketPNRLCC;
$arrBookingResponse[0]['BookingResponse'] = json_encode($response);
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '7'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING Fail CAse
}
if ($ErrorCode == 0 && $ErrorMessage == "") {
// Booking details to transaction table...
$TPintSysId = $arrIntTpAirId[0];
$data = array(
"XRefBookingId" => $strBookingIdLCC . "/" . $strTicketPNRLCC,
"APIBookingRes" => json_encode($response),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
} else {
// Booking details to transaction table...
$TPintSysId = $arrIntTpAirId[0];
$data = array(
"XRefBookingId" => '',
"APIBookingRes" => json_encode($response),
"XRefPNR" => '',
"IsBookingStatus" => 0
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
}
if (isset($arrTrevllerList) && !empty($arrTrevllerList) && $ErrorCode == 0) {
$Passenger = $response['Response']['Response']['FlightItinerary']['Passenger'];
foreach ($arrTrevllerList as $key => $value) {
$Ticket = $Passenger[$key]['Ticket'];
$data = array(
"TicketId" => $Ticket['TicketId'],
"TicketNumber" => $Ticket['TicketNumber'],
"TicketFullJson" => json_encode($Passenger[$key])
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
// Booking details to transaction Ends...
//echo "<pre>";print_r($response);die('1');
//echo "<pre>";print_r($arrBookingId);exit;
} else { //For Non LCC Flights Booking Method Called Then it the Ticket Method According to API...
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($data);
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingId = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
/* $TraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '';
if ($ErrorCode == 0) {
$response = [];
$data = [
"TraceId" => $TraceId,
"PNR" => $strTicketPNR,
"BookingId" => $strBookingId
];
$strJsonResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($data);
$response = json_decode($strJsonResponse,true);
//echo "<pre>";print_r();exit;
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingId = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
$TicketStatus = isset($response['Response']['Response']['TicketStatus']) ? $response['Response']['Response']['TicketStatus'] : '';
if($TicketStatus!= 1){
$ErrorCode = $TicketStatus;
$ErrorMessage = isset($response['Response']['Response']['ErrorMessage']) ? $response['Response']['Response']['Message'] : '';
}
}
*/
if ($ErrorCode == 0) {
$arrBookingResponse[0]['ErrorCode'] = $ErrorCode;
$arrBookingResponse[0]['ErrorMessage'] = $ErrorMessage;
$arrBookingResponse[0]['BookingId'] = $strBookingId . "/" . $strTicketPNR;
$arrBookingResponse[0]['BookingResponse'] = json_encode($response);
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
} else {
$arrBookingResponse[0]['ErrorCode'] = $ErrorCode;
$arrBookingResponse[0]['ErrorMessage'] = $ErrorMessage;
$arrBookingResponse[0]['BookingId'] = $strBookingId . "/" . $strTicketPNR;
$arrBookingResponse[0]['BookingResponse'] = json_encode($response);
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '7'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING Fail CAse
}
if ($ErrorCode == 0 && $ErrorMessage == "") {
// Booking details to transaction table...
$TPintSysId = $arrIntTpAirId[0];
$data = array(
"XRefBookingId" => $strBookingId . "/" . $strTicketPNR,
"APIBookingRes" => json_encode($response),
"XRefPNR" => '',
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
// Booking details to transaction Ends...
} else {
// Booking details to transaction table...
$TPintSysId = $arrIntTpAirId[0];
$data = array(
"XRefBookingId" => '',
"APIBookingRes" => json_encode($response),
"XRefPNR" => '',
"IsBookingStatus" => 0
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
// Booking details to transaction Ends...
}
}
if ($ErrorCode == 0 && $ErrorMessage == "") {
//Update travelling customer data after successfull booking.
//Mail Booking Itenary To Customer
$objFlight = new Travel_Model_TblFlight();
$arrFlightFare = $objFlight->customerInvoiceData($intTPSysId);
if ($arrFlightFare && $IsLCC == '1') {
foreach ($arrFlightFare as $k => $values) {
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $values['AirVersionId']);
//echo '<pre>';print_r($arrCustomerInvoiceData);echo '</pre>';
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetailsNew = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$html->assign('type', 'mailToCustomer');
$html->assign('arrResponse', $response);
$html->assign('arrTrevllerDetails', $arrTrevllerDetailsNew);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$bodyText = $html->render('mail-booking-content-new.phtml');
$subject = "Flight Booking Itinerary From " . $SourceAirportCode . " To " . $DestAirportCode;
$customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId']) ? $arrTrevllerDetails[0][0]['EmailId'] : '';
$emailData = array('fromEmail' => trim($this->intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $this->intLoggedinUserEmailId, "gaurav@hellogtx.com", "prashant@catpl.co.in"), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $TPintSysId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics);
} catch (Exception $err) {
print_r($err, true);
}
}
}
//Mail Booking Itenary To Customer
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = 0;
$arrData['outBoundIdForRefund'] = $intOutBoundId;
$arrData['inBoundIdForRefund'] = 0;
$arrData['arrBookingResponse'] = json_encode($response);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'msg' => '', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation");
echo json_encode($response);
exit;
} else {
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = 0;
$arrData['outBoundIdForRefund'] = $intOutBoundId;
$arrData['inBoundIdForRefund'] = 0;
$arrData['arrBookingResponse'] = json_encode($response);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
//echo "<pre>";print_r($arrData);exit;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
// Proccess Refund Ends Here.......
}
} else { // Flight details not found in DB then Process refund....
$arrError = [
"Response" => [
"Error" => [
"ErrorCode" => 2,
"ErrorMessage" => "Oops! There might be some technical error. Please contact administrator for more information."
]
]
];
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = 0;
$arrData['outBoundIdForRefund'] = $intOutBoundId;
$arrData['inBoundIdForRefund'] = 0;
$arrData['arrBookingResponse'] = json_encode($arrError);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
//echo "<pre>";print_r($arrData);exit;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
// Proccess Refund Ends Here.......
}
} else if (!empty($intOutBoundId) && !empty($intInBoundId)) { // For RoundTrip Flights...
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intOutBoundId . "','" . $intInBoundId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$SourceAirportCode = trim($arrSelectedFlightDetails[0]['SourceAirportCode']);
$DestAirportCode = trim($arrSelectedFlightDetails[0]['DestAirportCode']);
$IsLCC = trim($arrSelectedFlightDetails[0]['IsLCC']);
$responseMain = $this->bookRoundTripFlightsAction();
$outBoundId = 0;
$inBoundId = 0;
if ($responseMain) {
foreach ($responseMain as $keys => $response) {
$response = json_decode($response, true);
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
//echo $k.'-'.$arrIntTpAirId[$k];
if ($keys == 0) {
if ($ErrorCode != 0) {
$outBoundId = $intOutBoundId;
}
} else {
if ($ErrorCode != 0) {
$inBoundId = $intInBoundId;
}
}
if ($ErrorCode == 0 && $ErrorMessage == "") {
$Arrticket = [];
$ArrPassenger = [];
$Passenger = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : array();
if ($Passenger) {
foreach ($Passenger as $k => $val) {
$Arrticket[] = isset($val['Ticket']) ? $val['Ticket'] : '';
$ArrPassenger[] = $val;
}
}
$strBookingId = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$data = array(
"XRefBookingId" => $strBookingId . "/" . $strTicketPNR,
"APIBookingRes" => json_encode($response),
"IsBookingStatus" => 1
);
if ($IsLCC == '1') {
$data['XRefPNR'] = 1;
} else {
$data['XRefPNR'] = '';
}
$objFlight->updateBookingDetails($data, $arrIntTpAirId[$keys]);
if (isset($arrTrevllerList) && !empty($arrTrevllerList)) {
foreach ($arrTrevllerList as $key => $value) {
if (isset($Arrticket[$key])) {
$Ticket = $Arrticket[$key];
$dataTravel = array(
"TicketId" => isset($Ticket['TicketId']) ? $Ticket['TicketId'] : '',
"TicketNumber" => isset($Ticket['TicketNumber']) ? $Ticket['TicketNumber'] : '',
"TicketFullJson" => json_encode(isset($ArrPassenger[$key]) ? $ArrPassenger[$key] : [])
);
$objFlight->updateTravelPlanPax($dataTravel, $value['TPPaxSysId']);
}
}
}
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
//echo '<pre>';print_r($inBoundId);echo '</pre>';
} else {
$data = array(
"XRefBookingId" => '',
"APIBookingRes" => json_encode($response),
"XRefPNR" => '',
"IsBookingStatus" => 0
);
$objFlight->updateBookingDetails($data, $arrIntTpAirId[$keys]);
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '7'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
}
//echo '<pre>';print_r($response);echo '</pre>';
}
}
// echo '<pre>';print_r($arrFlightFare);
// echo '<pre>';print_r($inBoundId);die;
if ($outBoundId == 0 || $inBoundId == 0) {
//Mail Booking Itenary To Customer
$objFlight = new Travel_Model_TblFlight();
$arrFlightFare = $objFlight->customerInvoiceData($intTPSysId);
if ($arrFlightFare && $IsLCC == '1') {
foreach ($arrFlightFare as $k => $values) {
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $values['AirVersionId']);
//echo '<pre>';print_r($arrCustomerInvoiceData);echo '</pre>';
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetailsNew = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$html->assign('type', 'mailToCustomer');
$html->assign('arrResponse', $response);
$html->assign('arrTrevllerDetails', $arrTrevllerDetailsNew);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$bodyText = $html->render('mail-booking-content-new.phtml');
$subject = "Flight Booking Itinerary From " . $SourceAirportCode . " To " . $DestAirportCode;
$customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId']) ? $arrTrevllerDetails[0][0]['EmailId'] : '';
$emailData = array('fromEmail' => trim($this->intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $this->intLoggedinUserEmailId, "gaurav@hellogtx.com", "prashant@catpl.co.in"), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $intTPSysId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics);
} catch (Exception $err) {
print_r($err, true);
}
}
}
}
if ($outBoundId == 0 && $inBoundId == 0) {
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = $intInBoundId;
$arrData['tripType'] = 2;
$arrData['arrBookingResponse'] = json_encode($responseMain);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'msg' => '', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation");
echo json_encode($response);
exit;
} else {
//$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '7'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = $intInBoundId;
$arrData['outBoundIdForRefund'] = $outBoundId;
$arrData['inBoundIdForRefund'] = $inBoundId;
$arrData['tripType'] = 2;
$arrData['arrBookingResponse'] = json_encode($responseMain);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
//echo "<pre>";print_r($arrData);exit;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
// Proccess Refund Ends Here.......
}
die;
//echo '<pre>';print_r($response);
if ($response && $IsLCC == '1') {
foreach ($response as $value) {
$valuedE = json_decode($value, TRUE);
$Passenger = isset($valuedE['Response']['Response']['FlightItinerary']['Passenger']) ? $valuedE['Response']['Response']['FlightItinerary']['Passenger'] : array();
if ($Passenger) {
foreach ($Passenger as $k => $val) {
$Arrticket[] = isset($val['Ticket']) ? $val['Ticket'] : '';
$ArrPassenger[] = $val;
}
}
}
}
$i = 0;
$outBoundId = 0;
$inBoundId = 0;
foreach ($arrIntTpAirId as $TPintSysId) {
// Booking details to transaction table...
if ($i == 0) {
$strBookingId = isset($arrDepartureResponse['Response']['Response']['BookingId']) ? $arrDepartureResponse['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($arrDepartureResponse['Response']['Response']['PNR']) ? $arrDepartureResponse['Response']['Response']['PNR'] : '';
$ErrorCode = isset($arrDepartureResponse['Response']['Error']['ErrorCode']) ? $arrDepartureResponse['Response']['Error']['ErrorCode'] : '0';
if ($arrDepartureResponse['Response']['Error']['ErrorCode'] != 0) {
$outBoundId = $intOutBoundId;
}
$ErrorMessage = isset($arrDepartureResponse['Response']['Error']['ErrorMessage']) ? $arrDepartureResponse['Response']['Error']['ErrorMessage'] : '';
} else {
$strBookingId = isset($arrReturnResponse['Response']['Response']['BookingId']) ? $arrReturnResponse['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($arrReturnResponse['Response']['Response']['PNR']) ? $arrReturnResponse['Response']['Response']['PNR'] : '';
$ErrorCode = isset($arrReturnResponse['Response']['Error']['ErrorCode']) ? $arrReturnResponse['Response']['Error']['ErrorCode'] : '0';
if ($arrReturnResponse['Response']['Error']['ErrorCode'] != 0) {
$inBoundId = $intInBoundId;
}
$ErrorMessage = isset($arrReturnResponse['Response']['Error']['ErrorMessage']) ? $arrReturnResponse['Response']['Error']['ErrorMessage'] : '';
}
$data = array(
"XRefBookingId" => $strBookingId . "/" . $strTicketPNR,
"APIBookingRes" => ($response[$i])
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
if (isset($arrTrevllerList) && !empty($arrTrevllerList && $IsLCC == '1')) {
foreach ($arrTrevllerList as $key => $value) {
if (isset($Arrticket[$key])) {
$Ticket = $Arrticket[$key];
$data = array(
"TicketId" => $Ticket['TicketId'],
"TicketNumber" => $Ticket['TicketNumber'],
"TicketFullJson" => json_encode(isset($ArrPassenger[$key]) ? $ArrPassenger[$key] : [])
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
}
// Booking details to transaction Ends...
//Mail Booking Itenary To Customer
if ($ErrorCode == 0 && $ErrorMessage == "") {
$objFlight = new Travel_Model_TblFlight();
$arrFlightFare = $objFlight->customerInvoiceData($intTPSysId);
//echo '<pre>';print_r($arrFlightFare[$i]);echo '</pre>';
//if($arrFlightFare){
//foreach($arrFlightFare as $k=>$values){
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $arrFlightFare[$i]['AirVersionId']);
//echo '<pre>';print_r($arrCustomerInvoiceData);echo '</pre>';
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetailsNew = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$html->assign('type', 'mailToCustomer');
$html->assign('arrResponse', $response);
$html->assign('arrTrevllerDetails', $arrTrevllerDetailsNew);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$bodyText = $html->render('mail-booking-content-new.phtml');
if ($i == 0) {
$subject = "Flight Booking Itinerary From " . $SourceAirportCode . " To " . $DestAirportCode;
} else {
$subject = "Flight Booking Itinerary From " . $DestAirportCode . " To " . $SourceAirportCode;
}
//$subject = "Flight Booking Itinerary From ".$SourceAirportCode." To ".$DestAirportCode;
$customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId']) ? $arrTrevllerDetails[0][0]['EmailId'] : '';
$emailData = array('fromEmail' => trim($this->intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $this->intLoggedinUserEmailId, "gaurav@hellogtx.com", "prashant@catpl.co.in"), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $TPintSysId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics);
} catch (Exception $err) {
print_r($err, true);
}
// }
//}
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// $crmcustomerObj = new Travel_Model_CRM_Customer();
// $arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
// $html->assign('type', 'mailToCustomer');
// if($i == 0){
// $html->assign('arrResponse', $arrDepartureResponse);
// }else{
// $html->assign('arrResponse', $arrReturnResponse);
// }
// $html->assign('arrAgencyDetail', $arrAgencyDetail);
// $html->assign('arrFlightFare', $arrFlightFare[$i]);
// $bodyText = $html->render('mail-booking-content.phtml');
// if($i == 0){
// $subject = "Flight Booking Itinerary From ".$SourceAirportCode." To ".$DestAirportCode;
// }else{
// $subject = "Flight Booking Itinerary From ".$DestAirportCode." To ".$SourceAirportCode;
// }
//
//
// $customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId'])?$arrTrevllerDetails[0][0]['EmailId']:'';
// $emailData = array('fromEmail'=>trim($this->intLoggedinUserEmailId),'fromName'=>trim($arrAgencyDetail['DisplayName']),'subject'=> $subject,'to'=>array($customerEmailId,$this->intLoggedinUserEmailId,"gaurav@hellogtx.com","prashant@catpl.co.in"),'bodyHtml'=>$bodyText,'bodyText'=>'');
// //$emailData = array('fromEmail'=>trim($this->intLoggedinUserEmailId),'fromName'=>trim($arrAgencyDetail['DisplayName']),'subject'=> $subject,'to'=>array($customerEmailId),'bodyHtml'=>$bodyText,'bodyText'=>'');
// try {
// // Added By Pardeep Panchal For Email Count...
// $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
// $arrEmailStatistics = array(
// "TPSysId" => $TPintSysId,
// "TypeSysId" => 1, // 1 For Email 2 For SMS
// "AgencySysId" => $this->intLoggedinAgencyId,
// "AgentSysId" => $this->intLoggedinUserId,
// "Title" => $subject,
// "Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
// "Status" => 0,
// "RefSysId" => "",
// "RefSysStatus" => "",
// "CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
// );
//
// // Added By Pardeep Panchal For Email Count Ends...
// $this->mailSentByElastice($emailData,$arrEmailStatistics);
// } catch (Exception $err) {
// print_r($err, true);
// }
}
//Mail Booking Itenary To Customer
$i++;
}
//echo '<pre>';print_r($travelPlanDetais[0]);die;
if ($outBoundId == 0 || $inBoundId == 0) {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
} else {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '7'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
}
if ($outBoundId == 0 && $inBoundId == 0) {
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '17'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR BOOKING CONFIRMED
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = $intInBoundId;
$arrData['tripType'] = 2;
$arrData['arrBookingResponse'] = json_encode($response);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'msg' => '', 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation");
echo json_encode($response);
exit;
} else {
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = $intInBoundId;
$arrData['outBoundIdForRefund'] = $outBoundId;
$arrData['inBoundIdForRefund'] = $inBoundId;
$arrData['tripType'] = 2;
$arrData['arrBookingResponse'] = json_encode($response);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
//echo "<pre>";print_r($arrData);exit;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
// Proccess Refund Ends Here.......
}
} else { // if its not a Outbound Flight or both...
$arrError = [
"Response" => [
"Error" => [
"ErrorCode" => 2,
"ErrorMessage" => "Oops! Flight details not found. Please contact administrator for more information."
]
]
];
// Proccess Refund Starts.......
$arrData['customerSysId'] = $intCustomerSysId;
$arrData['TPSysId'] = $TPSysId;
$arrData['guid'] = $guid;
$arrData['TrxSysId'] = $TrxSysId;
$arrData['intOutBoundId'] = $intOutBoundId;
$arrData['intInBoundId'] = $intInBoundId;
$arrData['outBoundIdForRefund'] = $intOutBoundId;
$arrData['inBoundIdForRefund'] = $intInBoundId;
$arrData['arrBookingResponse'] = json_encode($arrError);
$arrData['intTPSysId'] = $intTPSysId;
$arrData['arrIntTpAirId'] = $arrIntTpAirId;
//echo "<pre>";print_r($arrData);exit;
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/process-refund");
echo json_encode($response);
exit;
// Proccess Refund Ends Here.......
}
}
} catch (Zend_Exception $e) {
print_r($e->getMessage());
exit;
}
} else { // Case Payment Failed.......
//echo "<pre>";print_r($_REQUEST);exit;
$strUrlData = $this->getRequest()->getParam('strUrlData');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$urlData = [
"TrxSysId" => $this->getRequest()->getParam('TrxSysId'),
"guid" => $this->getRequest()->getParam('guid')
];
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($urlData);
// Getting travel plan details...
$objFlight = new Travel_Model_TblFlight();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$travelPlanDetais = $this->_crmcusttravelplan->CheckCustomerWithLeadId($intTPSysId);
// Getting travel plan details Ends...
$objFlight->updateBookingStatusTravelPlan(array("StatusType" => '6'), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']); // FOR Payment Failed...
$response = array('success' => false, 'msg' => 'Error', 'urlData' => $strUrlData, 'formAction' => "/flight/payment-failed");
echo json_encode($response);
exit;
}
exit;
} else {
$this->view->status = !empty($this->getRequest()->getParam('status')) ? $this->getRequest()->getParam('status') : '';
$this->view->strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$this->view->TrxSysId = $this->getRequest()->getParam('TrxSysId');
$this->view->TPSysId = $this->getRequest()->getParam('TPSysId');
$this->view->guid = $this->getRequest()->getParam('guid');
}
}
public function processRefundAction() {
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
// $this->view->intOutBoundId = $intGoingFlightId = !empty($arrUrlData['intOutBoundId'])?$arrUrlData['intOutBoundId']:0;
// $this->view->intOutBoundId = $intReturnFlightId = !empty($arrUrlData['intInBoundId'])?$arrUrlData['intInBoundId']:0;
$this->view->intOutBoundId = $intGoingFlightId = !empty($arrUrlData['outBoundIdForRefund']) ? $arrUrlData['outBoundIdForRefund'] : 0;
$this->view->intOutBoundId = $intReturnFlightId = !empty($arrUrlData['inBoundIdForRefund']) ? $arrUrlData['inBoundIdForRefund'] : 0;
$this->view->IsTripjack = $IsTripjack = !empty($arrUrlData['IsTripjack']) ? $arrUrlData['IsTripjack'] : 0;
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams = !empty($arrUrlData['sessionFlightSearchParams']) ? $arrUrlData['sessionFlightSearchParams'] : 0;
$SearchTraceId = $sessionFlightSearchParams['SearchTraceId'];
//echo "<pre>";print_r($sessionFlightSearchParams);exit;
$this->view->tripType = $tripType = !empty($arrUrlData['tripType']) ? $arrUrlData['tripType'] : 1;
$this->view->intCustomerSysId = $intCustomerSysId = $arrUrlData['customerSysId'];
$this->view->intTpSysId = $intTpSysId = $arrUrlData['TPSysId'];
$this->view->guid = $strGuid = $arrUrlData['guid'];
$this->view->TrxSysId = $TrxSysId = $arrUrlData['TrxSysId'];
$this->view->AirInvenSysIdArr = $AirInvenSysIdArr = implode(',', $arrUrlData['AirInvenSysIdArr']);
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$SelectedBaggSessionNew = !empty($this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew']) ? $this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'] : 0;
$SelectedMealSessionNew = !empty($this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew']) ? $this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'] : 0;
$selectedSeatSession = !empty($this->view->selectedSeatSession = $arrUrlData['selectedSeatSession']) ? $this->view->selectedSeatSession = $arrUrlData['selectedSeatSession'] : 0;
$this->view->FlightBookingData = $BookingData = $intGoingFlightId;
// Booking details to transaction table...
foreach ($arrIntTpAirId as $TPintSysId) {
$data = array(
"XRefBookingId" => "",
"APIBookingRes" => json_encode($arrUrlData['arrBookingResponse'])
);
$objFlight = new Travel_Model_TblFlight();
$objFlight->updateBookingDetails($data, $TPintSysId);
}
// Booking details to transaction Ends...
$strReturnUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrUrlData);
$sessionReturnUrlData = new Zend_Session_Namespace('sessionReturnUrlData');
$sessionReturnUrlData->params['data'] = '';
$sessionReturnUrlData->params['data'] = $strReturnUrlData;
if ($tripType == 2) {
$arrBookingResponse = json_decode($arrUrlData['arrBookingResponse'], true);
if (!empty($intGoingFlightId)) {
$arrBookingResponse = json_decode($arrBookingResponse[0], true);
$this->view->ErrorMessage = isset($arrBookingResponse['Response']['Error']['ErrorMessage']) ? $arrBookingResponse['Response']['Error']['ErrorMessage'] : '';
} else if (!empty($intReturnFlightId)) {
$arrBookingResponse = json_decode($arrBookingResponse[1], true);
$this->view->ErrorMessage = isset($arrBookingResponse['Response']['Error']['ErrorMessage']) ? $arrBookingResponse['Response']['Error']['ErrorMessage'] : '';
}
} else {
$this->view->ErrorMessage = isset($arrUrlData['arrBookingResponse'][0]['ErrorMessage']) ? $arrUrlData['arrBookingResponse'][0]['ErrorMessage'] : '';
if (empty($this->view->ErrorMessage)) {
$this->view->ErrorMessage = isset($arrUrlData['arrBookingResponse'][1]['ErrorMessage']) ? $arrUrlData['arrBookingResponse'][1]['ErrorMessage'] : '';
}
}
$fullBaseUrl = $this->view->baseUrl();
$this->view->refundUrl = $fullBaseUrl . "/payment/booking-refund";
$this->view->strReturnURL = $fullBaseUrl . "/flight/booking-confirmation/data/" . $SearchTraceId;
$this->view->strErrorURL = $fullBaseUrl . "/flight/booking-confirmation/data/" . $SearchTraceId;
$this->view->intPlanType = "1";
$this->view->strTrxType = "R";
if (!empty($intCustomerSysId)) {
// for CRM Member Details
$objBuyHotel = new Travel_Model_TblBuyHotel();
$getCustomerDetail = $objBuyHotel->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTpSysId);
$this->view->CustomerFirstName = $getCustomerDetail['FirstName'];
}
if ($IsTripjack == 1) {
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenAPISysId IN (" . $AirInvenSysIdArr . ") ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
} else {
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
}
//echo "<pre>";print_r($arrSelectedFlightFareDetails);
$arrFlightFare = array();
$arrFlightFareNew = array();
if (!empty($arrSelectedFlightFareDetails)) {
$j = 0;
$temp = "";
foreach ($arrSelectedFlightFareDetails as $value) {
if (!empty($temp) && $temp != trim($value['TBQAirInvenAPISysId'])) {
$j = 0;
}
$temp = $intTBQAirInvenAPISysId = trim($value['TBQAirInvenAPISysId']);
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['Currency'] = $value['Currency'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['Tax'] = $value['Tax'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['YQTax'] = $value['YQTax'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['OtherCharges'] = $value['OtherCharges'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['Discount'] = $value['Discount'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['ServiceFee'] = $value['ServiceFee'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['PublishedFare'] = $value['PublishedFare'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['CommissionEarned'] = $value['CommissionEarned'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['PLBEarned'] = $value['PLBEarned'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['IncentiveEarned'] = $value['IncentiveEarned'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['OfferedFare'] = $value['OfferedFare'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['TdsOnCommission'] = $value['TdsOnCommission'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['TdsOnPLB'] = $value['TdsOnPLB'];
$arrFlightFareNew[$intTBQAirInvenAPISysId][$j]['TdsOnIncentive'] = $value['TdsOnIncentive'];
$j++;
}
}
//echo "<pre>";print_r($arrFlightFare);die;
if (!empty($arrSelectedFlightFareDetails)) {
$j = 0;
$i = 0;
$temp = "";
foreach ($arrSelectedFlightFareDetails as $value) {
$intTBQAirInvenAPISysId = trim($value['TBQAirInvenAPISysId']);
if (!empty($temp) && $temp != $intTBQAirInvenAPISysId) {
$i++;
$j = 0;
$temp = "";
}
if ($temp == "") {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
} else if ($temp == trim($value['TBQAirInvenAPISysId'])) {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
}
$arrFlightFare[$i][$j]['OtherCharges'] = $value['OtherCharges'];
$arrFlightFare[$i][$j]['Discount'] = $value['Discount'];
$arrFlightFare[$i][$j]['ServiceFee'] = $value['ServiceFee'];
$arrFlightFare[$i][$j]['PublishedFare'] = $value['PublishedFare'];
$arrFlightFare[$i][$j]['CommissionEarned'] = $value['CommissionEarned'];
$arrFlightFare[$i][$j]['PLBEarned'] = $value['PLBEarned'];
$arrFlightFare[$i][$j]['IncentiveEarned'] = $value['IncentiveEarned'];
$arrFlightFare[$i][$j]['OfferedFare'] = $value['OfferedFare'];
$arrFlightFare[$i][$j]['TdsOnCommission'] = $value['TdsOnCommission'];
$arrFlightFare[$i][$j]['TdsOnPLB'] = $value['TdsOnPLB'];
$arrFlightFare[$i][$j]['TdsOnIncentive'] = $value['TdsOnIncentive'];
$j++;
}
}
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams->params['child']) ? $sessionFlightSearchParams->params['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams->params['infant']) ? $sessionFlightSearchParams->params['infant'] : 0;
$this->view->route = $route = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : 0;
$intTatalPaxCTForMarkUp = $adultCount + $childCount + $infantCount;
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
if ($IsTripjack == 1) {
$PublishedFare = 0;
$GrandTotalBaseFare = 0;
$TotalTaxsandFees = 0;
$Total_CommiErn = 0;
$Total_Profit = 0;
$Total_TaxIN = 0;
$Total_FixedMarkUp = 0;
$Total_GSTOnMarkUp = 0;
$Total_GTXMarkup = 0;
$intNetPublishedFare = 0;
$AdditionalTxnFeePub = 0;
$TotalExtraMarkup = 0;
$TotalExtraMarkupOnGST = 0;
$showintax = isset($FlightBookingData[0]['FairRules']['showintax']) ? $FlightBookingData[0]['FairRules']['showintax'] : 0;
if ($BookingData) {
foreach ($BookingData as $amount) {
$PublishedFare += $amount['FairRules']['OfferedFare'];
$agencyMarkUp += $amount['FairRules']['FixedMarkUp'];
$gtxMarkup += $amount['FairRules']['intGTXMarkUp'];
$offerFare += $amount['FairRules']['OfferedFare'];
$gtxMarkupGST += $amount['FairRules']['GTXMarkUpGST'];
$agencyMarkUpGST += $amount['FairRules']['GSTOnMarkUp'];
if ($amount['FairRules']['FareBreakdown']) {
foreach ($amount['FairRules']['FareBreakdown'] as $key => $value) {
$PBaseFare = $value['BaseFare'];
$TaxIN = $value['TaxIN'];
$IntCommission = $value['IntCommission'];
$CommEarned = $value['CommEarned'];
$CommissionEarned = $value['CommissionEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$TotalExtraMarkup += isset($value['ExtraMarkup']) ? $value['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST += isset($value['ExtraMarkupOnGST']) ? $value['ExtraMarkupOnGST'] : 0;
$intGTXMarkUp = $value['intGTXMarkUp'];
$GTXMarkUpGST = $value['GTXMarkUpGST'];
$intTotalGST = $value['intTotalGST'];
$apiMarkup = $value['apiMarkup'];
$MF = $value['MF']; //Management Fee
$YQ = $value['YQ']; //Fuel Surcharge
$AGST = $value['AGST']; //Airline GST Component
$MFT = $value['MFT']; //Management Fee Tax
$OT = $value['OT']; //Other Charges
$MU = $value['MU']; //Markup
$YR = $value['YR']; //Carrier Misc Fee
$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$paxPublishedFare = ($PBaseFare);
$PassengerType = $value['PassengerType'];
$PassengerCount = $value['PassengerCount'];
$BaseFare = ($value['BaseFare'] / $PassengerCount);
$TaxesFees = ($MF + $YQ + $AGST + $MFT + $OT + $MU + $YR + $FixedMarkUp + $GSTOnMarkUp);
$PublishedFare = ($value['BaseFareCal'] - $TaxIN - $FixedMarkUp - $GSTOnMarkUp);
$Total_CommiErn += ($CommEarned);
$Total_Profit += ($IntCommission);
$Total_FixedMarkUp += ($FixedMarkUp);
$Total_GSTOnMarkUp += ($GSTOnMarkUp);
$Total_GTXMarkup += ($value['intGTXMarkUp'] + $value['GTXMarkUpGST']);
$TotalBaseFare += $PublishedFare;
$GrandTotalBaseFare += (($PBaseFare + $otherCharge + $FixedMarkUp + $apiMarkup + $intTotalGST + $intGTXMarkUp + $GTXMarkUpGST) - $customerDiscount);
//$GrandTotalBaseFare += ($PBaseFare + $otherCharge + $FixedMarkUp + $apiMarkup + $intTotalGST + $intGTXMarkUp + $GTXMarkUpGST);
}
}
}
}
$OtherCharges = ($TotalExtraMarkup + $TotalExtraMarkupOnGST);
$TotalExtraCharge = ($TotalExtraMarkup + $TotalExtraMarkupOnGST);
if ($showintax == 1) {
$OtherCharges = $OtherCharges;
$ExtraMarkup = 0;
$ExtraMarkupOnGST = 0;
} else {
$ExtraMarkup = $TotalExtraMarkup;
$ExtraMarkupOnGST = $TotalExtraMarkupOnGST;
$OtherCharges = 0;
}
//echo '<pre>';print_r($BookingData);echo '</pre>';die;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$PublishedFare = ($GrandTotalBaseFare - $Total_CommiErn + $BaggFare + $MealFare + $SeatPrice);
$GetFlightCostingArr['TotalChargeFromWallet'] = $PublishedFare;
$GetFlightCostingArr['FixedMarkUp'] = $Total_FixedMarkUp;
$GetFlightCostingArr['intintGTXMarkUpAmount'] = $Total_GTXMarkup;
$GetFlightCostingArr['GSTOnMarkUp'] = $Total_GSTOnMarkUp;
//echo "<pre>";print_r($GetFlightCostingArr);echo "</pre>";die('dd');
} else {
$GetFlightCostingArr = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->GetFlightCostingArr($arrFlightFareNew, $sessionFlightSearchParams);
}
$TotalBaseFare = 0;
$intGTXMarkUp = 0;
$intAgencyMarkUp = 0;
$intTDSOnAgencyMarkUp = 0;
$TotalPublishedFare = 0;
$intChargeFromWallet = 0;
$intCommisionEarnedForAgency = 0;
$intPLBEarnedForAgency = 0;
$intIncentiveEarnedForAgency = 0;
$intTotalEarningsForAgency = 0;
$intTotalGSTAgencyEarnings = 0;
$intAgencyFixMarkUp = 0;
$CostToAgent = 0;
//echo "<pre>";print_r($arrFlightFare);
foreach ($arrFlightFare as $FareResult) {
foreach ($FareResult as $FareBreakdown) {
$intPublishedFare = $FareBreakdown['PublishedFare'];
$intOfferedFare = $FareBreakdown['OfferedFare'];
$intCommissionEarned = $FareBreakdown['CommissionEarned'];
$intPLBEarned = $FareBreakdown['PLBEarned'];
$intIncentiveEarned = $FareBreakdown['IncentiveEarned'];
$arrAllCommissions = array(
'intCommissionEarned' => $intCommissionEarned,
'intPLBEarned' => $intPLBEarned,
'intIncentiveEarned' => $intIncentiveEarned
);
//echo "<pre>";print_r($arrAllCommissions);echo "</pre>";
//}
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $intOfferedFare, $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps);echo "</pre>";
//$intFareWithGTXMarkUp = $arrPriceAndMarkUps['intFareWithGTXMarkUp'];
if (!empty($interNationalSearch)) {
$intFareWithGTXMarkUp = $intOfferedFare + (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intFareWithGTXMarkUp = $intOfferedFare + (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp));
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp));
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp));
}
// Agency Earning Part....
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency += $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency;
// Agency Earning Part....
// Agency Earning Tax Part....
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings += $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
// Agency Earning Tax Part....
$CostToAgent += $intFareWithGTXMarkUp;
//$intChargeFromWallet += $TotalPublishedFare - ($intAgencyFixMarkUp + $intSTaxOnAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency);
$intCostToCustomer = $CostToAgent + $intTotalEarningsForAgency + $intTotalGSTAgencyEarnings;
$intChargeFromWallet = $CostToAgent;
}
}
//echo $intCostToCustomer.'<br>';
//echo $intChargeFromWallet.'<br>';
//die;
$this->view->intTotalPublishedFare = $TotalPublishedFare;
$this->view->intTotalAmount = $TotalPublishedFare;
$this->view->intTax = $intTDSOnAgencyMarkUp;
$this->view->intAgentMarkUpAmount = $intAgencyMarkUp;
//$this->view->intGrandPayableAmount = $intGrandPayableAmount = $TotalPublishedFare;
$this->view->intGrandPayableAmount = $GetFlightCostingArr['TotalChargeFromWallet'];
$this->view->intChargeFromWallet = $GetFlightCostingArr['TotalChargeFromWallet'];
$arrPriceAndMarkups = array(
"intAgentMarkUpAmount" => 0,
"intAgencyMarkUpAmount" => $GetFlightCostingArr['FixedMarkUp'],
"intGTXMarkUpAmount" => $GetFlightCostingArr['intintGTXMarkUpAmount'],
"intTotalAmount" => $GetFlightCostingArr['TotalChargeFromWallet'],
"intTax" => 0,
"GTXServiceTaxAmount" => 0,
"AgentServiceTaxAmount" => $GetFlightCostingArr['GSTOnMarkUp'],
"AgentsCustomServiceTaxAmount" => "0",
"Pax" => $intTatalPaxCTForMarkUp,
"SupplierSourceStr" => "API",
"MarketPlaceId" => "1",
"TotalDiscount" => "0",
"CurrencyType" => "1"
);
//echo $intChargeFromWallet;
//echo $intChargeFromWallet;
//echo "<pre>";print_r($arrPriceAndMarkups);echo "</pre>";
$strPriceAndMarkups = json_encode($arrPriceAndMarkups);
$this->view->stringData = $strStringData = $this->getEnc($strPriceAndMarkups);
$this->view->intLoggedinUserId = $this->intLoggedinUserId;
$this->view->intLoggedinUserGroupSysId = $this->intLoggedinUserGroupId;
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinAgencyId;
$this->view->guid = $strGuid;
$this->view->walletCode = $this->walletCode($this->intLoggedinAgencyId, $this->view->guid, $GetFlightCostingArr['TotalChargeFromWallet'], $this->intLoggedinUserId, $intTpSysId, $intCustomerSysId, $strStringData);
//$this->view->securecode = $this->secureCode($this->intLoggedinAgencyId, $this->view->guid);
}
public function passengerDetailsAction() {
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$departureDates = $sessionFlightSearchParams->params['departure_dates'];
$arrDepartureDates = explode("/", $departureDates);
$this->view->departureDates = $arrDepartureDates[2] . "/" . $arrDepartureDates[1] . "/" . ($arrDepartureDates[0] - 1);
$this->view->departureMonthInfant = $arrDepartureDates[1];
$this->view->departureDayInfant = ($arrDepartureDates[0] + 1);
$this->view->departureMonthChild = $arrDepartureDates[1];
$this->view->departureDayChild = ($arrDepartureDates[0]);
$strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
//echo "<pre>";print_r($arrUrlData);exit;
$intGoingFlightId = $this->view->intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$intReturnFlightId = $this->view->intInBoundId = !empty($arrUrlData['intInBoundId']) ? $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = $this->view->intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$this->view->arrSelectedFlightDetails = $arrSelectedFlightDetails;
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
//echo "<pre>";print_r($arrSelectedFlightFareDetails);die;
$arrFlightFare = array();
if (!empty($arrSelectedFlightFareDetails)) {
$j = 0;
$temp = "";
foreach ($arrSelectedFlightFareDetails as $value) {
if (!empty($temp) && $temp != trim($value['TBQAirInvenAPISysId'])) {
$j = 0;
}
$temp = $intTBQAirInvenAPISysId = trim($value['TBQAirInvenAPISysId']);
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['OtherCharges'] = $value['OtherCharges'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['Discount'] = $value['Discount'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['ServiceFee'] = $value['ServiceFee'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['PublishedFare'] = $value['PublishedFare'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['CommissionEarned'] = $value['CommissionEarned'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['PLBEarned'] = $value['PLBEarned'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['IncentiveEarned'] = $value['IncentiveEarned'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['OfferedFare'] = $value['OfferedFare'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['TdsOnCommission'] = $value['TdsOnCommission'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['TdsOnPLB'] = $value['TdsOnPLB'];
$arrFlightFare[$intTBQAirInvenAPISysId][$j]['TdsOnIncentive'] = $value['TdsOnIncentive'];
$j++;
}
}
$this->view->arrFlightFare = $arrFlightFare;
$this->view->arrFlightFare = $arrFlightFare;
//$GetFlightCostingArr = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->GetFlightCostingArr($arrFlightFare,$sessionFlightSearchParams);
//echo "<pre>";print_r($arrFlightFare);echo "</pre>";//exit;
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
//echo "<pre>";print_r($sessionFlightSearchParams->params);exit;
$this->view->intFlightRoute = $intFlightRoute = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : 0;
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams->params['child']) ? $sessionFlightSearchParams->params['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams->params['infant']) ? $sessionFlightSearchParams->params['infant'] : 0;
$this->view->totalPaxCount = $adultCount + $childCount + $infantCount;
$arrPaxCount = array(
'intAdultsCount' => $adultCount,
'intChildCount' => $childCount,
'intInfantCount' => $infantCount
);
$this->view->arrPaxCount = $arrPaxCount;
if (!empty($intCustomerSysId)) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$this->view->arrTrevllerDetails = $arrTrevllerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
// $arrTrevllerDetails['FirstName']
// $arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking(827,$intTPSysId);
// $this->view->arrTrevllerDetails = $arrTrevllerDetails;
//echo "<pre>";print_r($arrTrevllerDetails);echo "</pre>";
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function fareQuoteDetailsAction() {
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$intOutBoundId = !empty($this->getRequest()->getParam('intOutBoundId')) ? $this->getRequest()->getParam('intOutBoundId') : 0;
$intInBoundId = !empty($this->getRequest()->getParam('intInBoundId')) ? $this->getRequest()->getParam('intInBoundId') : 0;
$intFlightRoute = !empty($this->getRequest()->getParam('intFlightRoute')) ? $this->getRequest()->getParam('intFlightRoute') : 1;
$IsInterNational = trim($this->getRequest()->getParam('IsInterNational'));
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intAdultsCT = $sessionFlightSearchParams->params['adults'];
$intChildsCT = $sessionFlightSearchParams->params['child'];
$intInfantsCT = $sessionFlightSearchParams->params['infant'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$interNationalSearch = $sessionFlightSearchParams->params['interNationalSearch'];
$route = $sessionFlightSearchParams->params['route'];
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intOutBoundId . "','" . $intInBoundId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
//echo '<pre>';print_r($sessionFlightSearchParams->params);die;
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
if (!empty($arrSelectedFlightDetails)) {
$arrData = array();
$arrOfferedFareToAgent = array();
$arrIsPriceChanged = array();
$arrResponseStatus = array();
$intTotalUpdatedFare = 0;
$objFlight = new Travel_Model_TblFlight();
foreach ($arrSelectedFlightDetails as $result) {
$intAirInvenSysId = trim($result['AirInvenSysId']);
$TraceId = trim($result['apiTraceId']);
$ResultIndex = trim($result['ApiResultIndex']);
if (!empty($TraceId) && !empty($ResultIndex)) {
$arrData = array(
"apiTraceId" => $TraceId,
"ApiResultIndex" => $ResultIndex
);
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->fareQuoteDetails($arrData);
//echo "<pre>";print_r($response);exit;
if ($response['Response']['ResponseStatus'] == '1') {
$arrIsPriceChanged[] = $response['Response']['IsPriceChanged'];
$result = $response['Response']['Results'];
$Currency = $result['Fare']['Currency'];
$IsGSTMandatory = isset($result['IsGSTMandatory']) ? $result['IsGSTMandatory'] : '0';
$currencySysId = !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$BaseFare = $result['Fare']['BaseFare'];
$Tax = $result['Fare']['Tax'];
$YQTax = $result['Fare']['YQTax'];
$AdditionalTxnFeeOfrd = $result['Fare']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $result['Fare']['AdditionalTxnFeePub'];
$OtherCharges = $result['Fare']['OtherCharges'];
$Discount = $result['Fare']['Discount'];
$PublishedFare = $result['Fare']['PublishedFare'];
$CommissionEarned = $result['Fare']['CommissionEarned'];
$PLBEarned = $result['Fare']['PLBEarned'];
$IncentiveEarned = $result['Fare']['IncentiveEarned'];
$OfferedFare = $result['Fare']['OfferedFare'];
$TdsOnCommission = $result['Fare']['TdsOnCommission'];
$TdsOnPLB = $result['Fare']['TdsOnPLB'];
$TdsOnIncentive = $result['Fare']['TdsOnIncentive'];
$ServiceFee = $result['Fare']['ServiceFee'];
$arrAllCommissions = array(
'intCommissionEarned' => $CommissionEarned,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned
);
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $OfferedFare, $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps); exit;
$intOfferedFare = $arrPriceAndMarkUps['intOfferedFare'];
if (!empty($interNationalSearch)) {
$intGTXMarkUp = (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUp = (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = ($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUp = ($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
}
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency = $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intAgencyFixMarkUp;
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
$intPublishFare = $intOfferedFare + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
//$intPublishFare = $intOfferedFare + $intGTXMarkUp + $intTotalEarningsForAgency + $intGSTOnTotalEarnings;
//echo $intOfferedFare.'=';
$intTotalUpdatedFare += $intPublishFare;
$arrFairRules = array(
"Currency" => $currencySysId,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"OfferedFare" => $OfferedFare,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"IsGSTMandatory" => $IsGSTMandatory
);
//echo $intAirInvenSysId;
$objFlight->updateFlightFareDetails($arrFairRules, $intAirInvenSysId);
//echo "<pre>";print_r($arrFairRules);//exit;
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$arrFareBreakdown = array(
//"TBQAirInvenAPISysId" => $intAirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub
);
$objFlight->updateFlightFareBreakdown($arrFareBreakdown, $intAirInvenSysId);
//echo "<pre>";print_r($arrFareBreakdown);exit;
}
}
$arrResponseStatus['arrIsPriceChanged'] = $arrIsPriceChanged;
$arrResponseStatus['ErrorCode'][] = $response['Response']['Error']['ErrorCode'];
$arrResponseStatus['ErrorMessage'][] = $response['Response']['Error']['ErrorMessage'];
} else {
$arrResponseStatus['arrIsPriceChanged'] = $arrIsPriceChanged;
$arrResponseStatus['ErrorCode'][] = $response['Response']['Error']['ErrorCode'];
$arrResponseStatus['ErrorMessage'][] = $response['Response']['Error']['ErrorMessage'];
}
}
}
//echo "<pre>";print_r($arrResponseStatus);exit;
if (!empty($intFlightRoute) && $intFlightRoute == 2) {
if ($IsInterNational) { // Round Trip International
if ($arrResponseStatus['ErrorCode'][0] == 0) {
$IsPriceChanged = false;
if ($arrResponseStatus['arrIsPriceChanged'][0] == 1) {
$IsPriceChanged = true;
}
$response = array(
'success' => true,
'IsPriceChanged' => $IsPriceChanged,
'intTotalUpdatedFare' => number_format($intTotalUpdatedFare, 2)
);
echo json_encode($response);
exit;
} else {
if ($arrResponseStatus['ErrorCode'][0] == 6) { // 6 For trace Id expired
$objFlight->updateTraceIdExpired($TraceId);
}
$response = array(
'success' => false,
'ErrorMessage' => $arrResponseStatus['ErrorMessage'][0]
);
echo json_encode($response);
exit;
}
} else { //roundTrip Domestic....
//echo "<pre>";print_r($arrResponseStatus);exit;
if ($arrResponseStatus['ErrorCode'][0] == 0 && $arrResponseStatus['ErrorCode'][1] == 0) {
$IsPriceChanged = false;
if ($arrResponseStatus['arrIsPriceChanged'][0] == 1 || $arrResponseStatus['arrIsPriceChanged'][0] == 1) {
$IsPriceChanged = true;
}
$response = array(
'success' => true,
'IsPriceChanged' => $IsPriceChanged,
'intTotalUpdatedFare' => number_format($intTotalUpdatedFare, 2)
);
//echo "<pre>";print_r($response);exit;
echo json_encode($response);
exit;
} else {
if ($arrResponseStatus['ErrorCode'][0] == 6 && $arrResponseStatus['ErrorCode'][1] == 6) { // 6 For trace Id expired
$objFlight->updateTraceIdExpired($TraceId);
}
$response = array(
'success' => false,
'ErrorMessage' => $arrResponseStatus['ErrorMessage'][0]
);
echo json_encode($response);
exit;
}
}
} else {
if (isset($arrResponseStatus['ErrorCode'][0]) && $arrResponseStatus['ErrorCode'][0] == 0) {
$IsPriceChanged = false;
if ($arrResponseStatus['arrIsPriceChanged'][0] == 1) {
$IsPriceChanged = true;
}
$response = array(
'success' => true,
'IsPriceChanged' => $IsPriceChanged,
'intTotalUpdatedFare' => number_format($intTotalUpdatedFare, 2)
);
echo json_encode($response);
exit;
} else {
if (isset($arrResponseStatus['ErrorCode'][0]) && $arrResponseStatus['ErrorCode'][0] == 6) { // 6 For trace Id expired
$objFlight->updateTraceIdExpired($TraceId);
}
$response = array(
'success' => false,
'ErrorMessage' => $arrResponseStatus['ErrorMessage'][0]
);
echo json_encode($response);
exit;
}
}
} else {
$arrResponseStatus['Response']['ErrorMessage'][] = "Oops! There might be some technical issue";
$response = array(
'success' => false
);
echo json_encode($response);
exit;
}
}
exit;
}
public function dataEncodeAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$intOutBoundId = !empty($this->getRequest()->getParam('intOutBoundId')) ? $this->getRequest()->getParam('intOutBoundId') : 0;
$intInBoundId = !empty($this->getRequest()->getParam('intInBoundId')) ? $this->getRequest()->getParam('intInBoundId') : 0;
$intCustomerSysId = !empty($this->getRequest()->getParam('intCustomerSysId')) ? $this->getRequest()->getParam('intCustomerSysId') : 0;
if (!empty($intOutBoundId) && !empty($intInBoundId)) {
$arrIds = array(
"intOutBoundId" => $intOutBoundId,
"intInBoundId" => $intInBoundId,
"intCustomerSysId" => $intCustomerSysId
);
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrIds);
echo $strUrlData;
} else {
echo '';
}
}
exit;
}
public function insertInterNationalFlightNewAction($data, $arrCommonInsVariables, $AgentSysId, $ICSourceSysId) {
if (isset($data) && count($data) > 0) {
$objFlight = new Travel_Model_TblFlight();
// For getting All Airlines Array
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
// For getting All currency Array
$objCurrency = new Travel_Model_TblCurrency();
$arrCurrencyList = $objCurrency->getCurrencyIdsAndSymbolList();
$interNationalSearch = isset($arrCommonInsVariables['interNationalSearch']) ? $arrCommonInsVariables['interNationalSearch'] : '';
$JourneyType = isset($arrCommonInsVariables['JourneyType']) ? $arrCommonInsVariables['JourneyType'] : '';
// For getting All Source & Destination CitySysId Array
$objAirport = new Travel_Model_TblAirport();
$arrCityIds = $objAirport->getCityIdsAndAirPortCodeList();
try {
foreach ($data as $result) {
//echo $ICSourceSysId;
// Master Entry... ToUTCTime
$AirInvenSysIdArr = [];
if (isset($result['Segments']) && count($result['Segments']) > 1) {
$AirlineCode = isset($result['AirlineCode']) ? $result['AirlineCode'] : '';
if ($ICSourceSysId == 7) {
$OriginDepTime = isset($result['Segments'][0][0]['originDepTime']) ? $result['Segments'][0][0]['originDepTime'] . ':00' : '';
if (count($result['Segments'][1]) == 1) {
$DestinationArrTime = isset($result['Segments'][1][0]['destinationArrTime']) ? $result['Segments'][1][0]['destinationArrTime'] . ':00' : $result['Segments'][1][0]['destinationArrTime'] . ':00';
} elseif (count($result['Segments'][1]) == 2) {
$DestinationArrTime = isset($result['Segments'][1][1]['destinationArrTime']) ? $result['Segments'][1][1]['destinationArrTime'] . ':00' : $result['Segments'][1][1]['destinationArrTime'] . ':00';
} elseif (count($result['Segments'][1]) == 3) {
$DestinationArrTime = isset($result['Segments'][1][2]['destinationArrTime']) ? $result['Segments'][1][2]['destinationArrTime'] . ':00' : $result['Segments'][1][2]['destinationArrTime'] . ':00';
} elseif (count($result['Segments'][1]) == 4) {
$DestinationArrTime = isset($result['Segments'][1][3]['destinationArrTime']) ? $result['Segments'][1][3]['destinationArrTime'] . ':00' : $result['Segments'][1][3]['destinationArrTime'] . ':00';
}
} else {
$SegmentsEnd = end($result['Segments']);
$originDepTime_ = isset($result['Segments'][0]['originDepTime']) ? $result['Segments'][0]['originDepTime'] : '';
$destinationArrTime_ = isset($SegmentsEnd['destinationArrTime']) ? $SegmentsEnd['destinationArrTime'] : '';
$OriginDepTime = isset($result['Segments'][0][0]['Origin']['DepTime']) ? $result['Segments'][0][0]['Origin']['DepTime'] : $originDepTime_;
$DestinationArrTime = isset($result['Segments'][1][1]['Destination']['ArrTime']) ? $result['Segments'][1][1]['Destination']['ArrTime'] : $destinationArrTime_;
// $DestinationArrTime = isset($result['Segments'][1][1]['Destination']['ArrTime']) ? $result['Segments'][1][1]['Destination']['ArrTime'] : $result['Segments'][1][0]['Destination']['ArrTime'];
}
$Currency = $result['Fare']['Currency'];
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = '';
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = true; //isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($result['strTraceId']) ? $result['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId; //3 For TBO
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = $OriginDepTime;
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = $DestinationArrTime;
$arrInsertFlightData['IsDirect'] = 0;
$arrInsertFlightData['FareClass'] = '';
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = '0';
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['SourceAirportCode'] = $arrCommonInsVariables['strSourceAirportCode'];
$arrInsertFlightData['DestAirportCode'] = $arrCommonInsVariables['strDestinationAirportCode'];
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = '0';
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = 0;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$arrInsertFlightData['PublishedFare'] = isset($result['Fare']['OfferedFare']) ? (int) round($result['Fare']['OfferedFare']) : 0;
$arrInsertFlightData['CommissionEarned'] = isset($result['Fare']['CommissionEarned']) ? (int) round($result['Fare']['CommissionEarned']) : 0;
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = '2';
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $AgentSysId;
$arrInsertFlightData['CreatedByISSysId'] = $AgentSysId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $AgentSysId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$arrInsertFlightData['IsNewMigration'] = isset($result['IsNewMigration']) ? $result['IsNewMigration'] : 0;
$intFlightParentRecordId = $AirInvenSysIdArr[] = $objFlight->addFlightDetails($arrInsertFlightData);
// Master Entry Ends...
// Master Fare Details...
$arrFairRules = array(
"TBOAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"BaseFare" => isset($result['Fare']['BaseFare']) ? $result['Fare']['BaseFare'] : 0,
"Tax" => isset($result['Fare']['Tax']) ? $result['Fare']['Tax'] : 0,
"YQTax" => isset($result['Fare']['YQTax']) ? $result['Fare']['YQTax'] : 0,
"AdditionalTxnFeeOfrd" => isset($result['Fare']['AdditionalTxnFeeOfrd']) ? $result['Fare']['AdditionalTxnFeeOfrd'] : 0,
"AdditionalTxnFeePub" => isset($result['Fare']['AdditionalTxnFeePub']) ? $result['Fare']['AdditionalTxnFeePub'] : 0,
"OtherCharges" => isset($result['Fare']['OtherCharges']) ? $result['Fare']['OtherCharges'] : 0,
"Discount" => isset($result['Fare']['Discount']) ? $result['Fare']['Discount'] : 0,
"ServiceFee" => isset($result['Fare']['ServiceFee']) ? $result['Fare']['ServiceFee'] : 0,
"PublishedFare" => isset($result['Fare']['PublishedFare']) ? $result['Fare']['PublishedFare'] : 0,
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : 0,
"PLBEarned" => isset($result['Fare']['PLBEarned']) ? $result['Fare']['PLBEarned'] : 0,
"IncentiveEarned" => isset($result['Fare']['IncentiveEarned']) ? $result['Fare']['IncentiveEarned'] : 0,
"OfferedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : 0,
"TdsOnCommission" => isset($result['Fare']['TdsOnCommission']) ? $result['Fare']['TdsOnCommission'] : 0,
"TdsOnPLB" => isset($result['Fare']['TdsOnPLB']) ? $result['Fare']['TdsOnPLB'] : 0,
"TdsOnIncentive" => isset($result['Fare']['TdsOnIncentive']) ? $result['Fare']['TdsOnIncentive'] : 0,
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDel" => 0
);
$objFlight->addFlightFairRuleDetails($arrFairRules);
// Master Fare Details Ends...
// FareBreakdown Details...
if ($ICSourceSysId == 7) {
if (!empty($result['Fare']['FareBreakdown'])) {
foreach ($result['Fare']['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['TaxIN'];
$YQTax = $fareBreakdown['YQ'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$intCommisionEarnedForAgency = isset($fareBreakdown['IntCommission']) ? $fareBreakdown['IntCommission'] : 0; // New fields
$OtherCharges = isset($fareBreakdown['OtherCharges']) ? $fareBreakdown['OtherCharges'] : 0; // New fields
$FixedMarkUp = isset($fareBreakdown['FixedMarkUp']) ? $fareBreakdown['FixedMarkUp'] : 0; // New fields
$GSTOnMarkUp = isset($fareBreakdown['GSTOnMarkUp']) ? $fareBreakdown['GSTOnMarkUp'] : 0; // New fields
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"CommissionEarned" => ($intCommisionEarnedForAgency),
"OtherCharges" => $OtherCharges,
"FixedMarkUp" => $FixedMarkUp,
"GSTOnMarkUp" => $GSTOnMarkUp,
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
} else {
foreach ($result['FairRules']['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['TaxIN'];
$YQTax = $fareBreakdown['YQ'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$intCommisionEarnedForAgency = isset($fareBreakdown['IntCommission']) ? $fareBreakdown['IntCommission'] : 0; // New fields
$OtherCharges = isset($fareBreakdown['OtherCharges']) ? $fareBreakdown['OtherCharges'] : 0; // New fields
$FixedMarkUp = isset($fareBreakdown['FixedMarkUp']) ? $fareBreakdown['FixedMarkUp'] : 0; // New fields
$GSTOnMarkUp = isset($fareBreakdown['GSTOnMarkUp']) ? $fareBreakdown['GSTOnMarkUp'] : 0; // New fields
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"CommissionEarned" => ($intCommisionEarnedForAgency),
"OtherCharges" => $OtherCharges,
"FixedMarkUp" => $FixedMarkUp,
"GSTOnMarkUp" => $GSTOnMarkUp,
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
} else {
if (!empty($result['FareBreakdown'])) {
foreach ($result['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['Tax'];
$YQTax = $fareBreakdown['YQTax'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$intCommisionEarnedForAgency = isset($fareBreakdown['IntCommission']) ? $fareBreakdown['IntCommission'] : 0; // New fields
$OtherCharges = isset($fareBreakdown['OtherCharges']) ? $fareBreakdown['OtherCharges'] : 0; // New fields
$FixedMarkUp = isset($fareBreakdown['FixedMarkUp']) ? $fareBreakdown['FixedMarkUp'] : 0; // New fields
$GSTOnMarkUp = isset($fareBreakdown['GSTOnMarkUp']) ? $fareBreakdown['GSTOnMarkUp'] : 0; // New fields
$ServiceFee = isset($fareBreakdown['ServiceFee']) ? $fareBreakdown['ServiceFee'] : 0; // New fields
$Discount = isset($fareBreakdown['CommisionPass']) ? $fareBreakdown['CommisionPass'] : 0; // New fields
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"CommissionEarned" => ($intCommisionEarnedForAgency),
"OtherCharges" => $OtherCharges,
"FixedMarkUp" => $FixedMarkUp,
"GSTOnMarkUp" => $GSTOnMarkUp,
"ServiceFee" => $ServiceFee,
"Discount" => $Discount,
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
} else {
if (!empty($result['FairRules']['FareBreakdown'])) {
foreach ($result['FairRules']['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = $fareBreakdown['TaxIN'];
$YQTax = $fareBreakdown['YQ'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$intCommisionEarnedForAgency = isset($fareBreakdown['IntCommission']) ? $fareBreakdown['IntCommission'] : 0; // New fields
$OtherCharges = isset($fareBreakdown['OtherCharges']) ? $fareBreakdown['OtherCharges'] : 0; // New fields
$FixedMarkUp = isset($fareBreakdown['FixedMarkUp']) ? $fareBreakdown['FixedMarkUp'] : 0; // New fields
$GSTOnMarkUp = isset($fareBreakdown['GSTOnMarkUp']) ? $fareBreakdown['GSTOnMarkUp'] : 0; // New fields
$ServiceFee = isset($fareBreakdown['ServiceFee']) ? $fareBreakdown['ServiceFee'] : 0; // New fields
$Discount = isset($fareBreakdown['CommisionPass']) ? $fareBreakdown['CommisionPass'] : 0; // New fields
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => !empty($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"CommissionEarned" => ($intCommisionEarnedForAgency),
"OtherCharges" => $OtherCharges,
"FixedMarkUp" => $FixedMarkUp,
"GSTOnMarkUp" => $GSTOnMarkUp,
"ServiceFee" => $ServiceFee,
"Discount" => $Discount,
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
}
}
// FareBreakdown Details Ends...
// InOutBound/InBound Flights Data...
if ($ICSourceSysId == 3 && $interNationalSearch == 1 && $JourneyType == 2) {
$SegmentsTBO = $result['SegmentsInt'];
} else {
$SegmentsTBO = $result['Segments'];
}
$arrInsertFlightData = array();
$intSegments = 1;
foreach ($SegmentsTBO as $segmentsResult) {
$arrFirstSegments = current($segmentsResult);
$arrLastSegments = end($segmentsResult);
$FlyingMinutesOutBound = 0;
$FlyingMinutesInBound = 0;
foreach ($segmentsResult as $arrSegmentsRes) {
$TripIndicator = isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0';
$Duration = isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0';
$GroundTime = isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0';
if ($TripIndicator == 1) {
$FlyingMinutesOutBound += ($Duration + $GroundTime);
} else {
$FlyingMinutesInBound += ($Duration + $GroundTime);
}
}
if ($ICSourceSysId == 7) {
$OriginDepTime = isset($arrFirstSegments['originDepTime']) ? $arrFirstSegments['originDepTime'] . ':00' : '';
$DestinationArrTime = isset($arrLastSegments['destinationArrTime']) ? $arrLastSegments['destinationArrTime'] . ':00' : '';
$AirlineCode = isset($arrFirstSegments['AirlineCode']) ? $arrFirstSegments['AirlineCode'] : '';
$AirlineName = isset($arrFirstSegments['AirlineName']) ? $arrFirstSegments['AirlineName'] : '';
$FlightNumber = isset($arrFirstSegments['SegFlightNumber']) ? $arrFirstSegments['SegFlightNumber'] : '';
$SourceAirportCode = isset($arrFirstSegments['originAirportCode']) ? $arrFirstSegments['originAirportCode'] : '';
$DestAirportCode = isset($arrLastSegments['destinationAirportCode']) ? $arrLastSegments['destinationAirportCode'] : '';
$FareClass = isset($arrFirstSegments['FareClass']) ? $arrFirstSegments['FareClass'] : '';
} else {
$OriginDepTime = isset($arrFirstSegments['Origin']['DepTime']) ? $arrFirstSegments['Origin']['DepTime'] : '';
$DestinationArrTime = isset($arrLastSegments['Destination']['ArrTime']) ? $arrLastSegments['Destination']['ArrTime'] : '';
$AirlineCode = isset($arrFirstSegments['Airline']['AirlineCode']) ? $arrFirstSegments['Airline']['AirlineCode'] : '';
$AirlineName = isset($arrFirstSegments['Airline']['AirlineName']) ? $arrFirstSegments['Airline']['AirlineName'] : '';
$FlightNumber = isset($arrFirstSegments['Airline']['FlightNumber']) ? $AirlineCode . '-' . $arrFirstSegments['Airline']['FlightNumber'] : '';
$SourceAirportCode = isset($arrFirstSegments['Origin']['Airport']['AirportCode']) ? $arrFirstSegments['Origin']['Airport']['AirportCode'] : '';
$DestAirportCode = isset($arrLastSegments['Destination']['Airport']['AirportCode']) ? $arrLastSegments['Destination']['Airport']['AirportCode'] : '';
$FareClass = isset($arrFirstSegments['Airline']['FareClass']) ? $arrFirstSegments['Airline']['FareClass'] : '';
}
// echo "<pre>";
// print_r($segmentsResult);
// die('ddd');
$NoOfSeatAvailableOutBound = isset($arrFirstSegments['NoOfSeatAvailable']) ? $arrFirstSegments['NoOfSeatAvailable'] : '0';
$NoOfSeatAvailableInBound = isset($arrLastSegments['NoOfSeatAvailable']) ? $arrLastSegments['NoOfSeatAvailable'] : '0';
$strFlightNumber = $FlightNumber;
if (count($segmentsResult) > 1) {
$IsDirect = 0;
$StopCount = count($segmentsResult) - 1;
} else {
$IsDirect = 1;
$StopCount = 0;
}
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = $intFlightParentRecordId;
$arrInsertFlightData['IsLCC'] = isset($result['IsLCC']) ? $result['IsLCC'] : '';
$arrInsertFlightData['IsRefundable'] = isset($result['IsRefundable']) ? $result['IsRefundable'] : '';
$arrInsertFlightData['apiTraceId'] = isset($result['strTraceId']) ? $result['strTraceId'] : '';
$arrInsertFlightData['AirlineSysId'] = isset($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId; //3 For TBO
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = isset($arrCommonInsVariables['localFromDateTime']) ? $arrCommonInsVariables['localFromDateTime'] : '';
$arrInsertFlightData['FromUTCTime'] = $OriginDepTime;
$arrInsertFlightData['LocalToTime'] = isset($arrCommonInsVariables['localToDateTime']) ? $arrCommonInsVariables['localToDateTime'] : '';
;
$arrInsertFlightData['ToUTCTime'] = $DestinationArrTime;
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $FareClass;
$arrInsertFlightData['DayLightSavingDiff'] = '0';
$arrInsertFlightData['FlyingMinutes'] = ($intSegments > 1) ? $FlyingMinutesInBound : $FlyingMinutesOutBound;
if ($intSegments > 1) {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
} else {
$arrInsertFlightData['SourcePlaceSysId'] = $arrCommonInsVariables['intSourceCityId'];
$arrInsertFlightData['DestPlaceSysId'] = $arrCommonInsVariables['intDestinationCityId'];
}
$arrInsertFlightData['SourceAirportCode'] = $SourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $DestAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = '0';
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = ($intSegments > 1) ? $NoOfSeatAvailableInBound : $NoOfSeatAvailableOutBound;
$arrInsertFlightData['TotalFlightMembers'] = isset($arrCommonInsVariables['intMemberCount']) ? $arrCommonInsVariables['intMemberCount'] : '';
$arrInsertFlightData['CurrencyType'] = isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1';
$arrInsertFlightData['PublishedFare'] = isset($result['Fare']['OfferedFare']) ? (int) round($result['Fare']['OfferedFare']) : 0;
$arrInsertFlightData['CommissionEarned'] = isset($result['Fare']['CommissionEarned']) ? (int) round($result['Fare']['CommissionEarned']) : 0;
$arrInsertFlightData['ApiResultIndex'] = isset($result['ResultIndex']) ? $result['ResultIndex'] : '';
$arrInsertFlightData['JourneyType'] = '2';
$arrInsertFlightData['TripType'] = 2;
$arrInsertFlightData['IsInternational'] = '1';
$arrInsertFlightData['Rating'] = '0';
$arrInsertFlightData['FllightFeatureMask'] = '0';
$arrInsertFlightData['UpdatedByISSysId'] = $AgentSysId;
$arrInsertFlightData['CreatedByISSysId'] = $AgentSysId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['ApproveBy'] = $AgentSysId;
$arrInsertFlightData['ApprovalDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$arrInsertFlightData['IsNewMigration'] = isset($result['IsNewMigration']) ? $result['IsNewMigration'] : 0;
// echo "<pre>";
// print_r($arrInsertFlightData);
// echo '==========';die;
$intFlightChildRecordId = $objFlight->addFlightDetails($arrInsertFlightData);
$intSegments++;
if ($ICSourceSysId == 3 && count($segmentsResult) > 0) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
// FOR FLIGHT SEGMENTS.....
$arrSegments = array(
"AirInvenAPISysId" => $intFlightChildRecordId,
"TripIndicator" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Baggage" => isset($arrSegmentsRes['Baggage']) ? $arrSegmentsRes['Baggage'] : '',
"CabinBaggage" => isset($arrSegmentsRes['CabinBaggage']) ? $arrSegmentsRes['CabinBaggage'] : '',
"SegmentIndicator" => isset($arrSegmentsRes['SegmentIndicator']) ? $arrSegmentsRes['SegmentIndicator'] : '0',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"Duration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0',
"GroundTime" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Mile" => isset($arrSegmentsRes['Mile']) ? $arrSegmentsRes['Mile'] : '0',
"StopOver" => isset($arrSegmentsRes['StopOver']) ? $arrSegmentsRes['StopOver'] : '0',
"StopPoint" => isset($arrSegmentsRes['StopPoint']) ? $arrSegmentsRes['StopPoint'] : '0',
"StopPointArrivalTime" => isset($arrSegmentsRes['StopPointArrivalTime']) ? $arrSegmentsRes['StopPointArrivalTime'] : '0',
"Craft" => isset($arrSegmentsRes['Craft']) ? $arrSegmentsRes['Craft'] : '',
"Remark" => isset($arrSegmentsRes['Remark']) ? $arrSegmentsRes['Remark'] : '',
"IsETicketEligible" => isset($arrSegmentsRes['IsETicketEligible']) ? $arrSegmentsRes['IsETicketEligible'] : '0',
"FlightStatus" => isset($arrSegmentsRes['FlightStatus']) ? $arrSegmentsRes['FlightStatus'] : '',
"Status" => isset($arrSegmentsRes['Status']) ? $arrSegmentsRes['Status'] : ''
);
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
}
}
if ($ICSourceSysId == 7 && count($segmentsResult) > 0) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
// FOR FLIGHT SEGMENTS.....
$arrSegments = array(
"AirInvenAPISysId" => $intFlightChildRecordId,
"TripIndicator" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Baggage" => isset($arrSegmentsRes['Baggage']) ? $arrSegmentsRes['Baggage'] : '',
"CabinBaggage" => isset($arrSegmentsRes['CabinBaggage']) ? $arrSegmentsRes['CabinBaggage'] : '',
"SegmentIndicator" => isset($arrSegmentsRes['SegmentIndicator']) ? $arrSegmentsRes['SegmentIndicator'] : '0',
"OriginAirportCode" => isset($arrSegmentsRes['originAirportCode']) ? $arrSegmentsRes['originAirportCode'] : '',
"DestAirportCode" => isset($arrSegmentsRes['destinationAirportCode']) ? $arrSegmentsRes['destinationAirportCode'] : '',
"Duration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0',
"GroundTime" => isset($arrSegmentsRes['TripIndicator']) ? $arrSegmentsRes['TripIndicator'] : '0',
"Mile" => isset($arrSegmentsRes['Mile']) ? $arrSegmentsRes['Mile'] : '0',
"StopOver" => isset($arrSegmentsRes['StopOver']) ? $arrSegmentsRes['StopOver'] : '0',
"StopPoint" => isset($arrSegmentsRes['StopPoint']) ? $arrSegmentsRes['StopPoint'] : '0',
"StopPointArrivalTime" => isset($arrSegmentsRes['StopPointArrivalTime']) ? $arrSegmentsRes['StopPointArrivalTime'] : '0',
"Craft" => isset($arrSegmentsRes['Craft']) ? $arrSegmentsRes['Craft'] : '',
"Remark" => isset($arrSegmentsRes['Remark']) ? $arrSegmentsRes['Remark'] : '',
"IsETicketEligible" => isset($arrSegmentsRes['IsETicketEligible']) ? $arrSegmentsRes['IsETicketEligible'] : '0',
"FlightStatus" => isset($arrSegmentsRes['FlightStatus']) ? $arrSegmentsRes['FlightStatus'] : '',
"Status" => isset($arrSegmentsRes['Status']) ? $arrSegmentsRes['Status'] : ''
);
//die;
$objFlight->addFlightSegmentsDetails($arrSegments);
// FOR FLIGHT SEGMENTS.....
}
}
if ($ICSourceSysId == 7 && count($segmentsResult) > 0) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
$FlightNumber = isset($arrSegmentsRes['FlightNumber']) ? $arrSegmentsRes['FlightNumber'] : 0;
$originAirportCode = $arrSegmentsRes['originAirportCode'];
$destinationAirportCode = $arrSegmentsRes['destinationAirportCode'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0';
$GroundTime = isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0';
$FlightDuration = $Duration + $GroundTime;
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $intFlightChildRecordId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"DestPlaceSysId" => $DestPlaceSysId,
"Sequance" => $Sequance,
"StayDuration" => isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '',
"FlightDuration" => $FlightDuration,
"AirlineCode" => isset($arrSegmentsRes['AirlineCode']) ? $arrSegmentsRes['AirlineCode'] : '',
"AirlineName" => isset($arrSegmentsRes['AirlineName']) ? $arrSegmentsRes['AirlineName'] : '',
"FlightNumber" => isset($arrSegmentsRes['SegFlightNumber']) ? $arrSegmentsRes['SegFlightNumber'] : '',
"FareClass" => isset($arrSegmentsRes['FareClass']) ? $arrSegmentsRes['FareClass'] : '',
"OriginAirportCode" => isset($arrSegmentsRes['originAirportCode']) ? $arrSegmentsRes['originAirportCode'] : '',
"DestinationAirportCode" => isset($arrSegmentsRes['destinationAirportCode']) ? $arrSegmentsRes['destinationAirportCode'] : '',
"IsFlightChange" => 0,
"NewFInvenSysId" => 0, //!empty($NewFInvenSysId)?$NewFInvenSysId:0,
"DepartureTime" => isset($arrSegmentsRes['originDepTime']) ? $arrSegmentsRes['originDepTime'] . ':00' : '',
"ArrivalTime" => isset($arrSegmentsRes['destinationArrTime']) ? $arrSegmentsRes['destinationArrTime'] . ':00' : '',
"HaultInclusions" => '',
"NoOfSeatAvailable" => isset($arrSegmentsRes['NoOfSeatAvailable']) ? $arrSegmentsRes['NoOfSeatAvailable'] : '',
"CurrencyType" => isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PublishedFare" => isset($result['Fare']['OfferedFare']) ? (int) round($result['Fare']['OfferedFare']) : 0,
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? (int) round($result['Fare']['CommissionEarned']) : 0,
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDelete" => 0
);
$AirStopInvenSysId = $objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$AirInvenSysId = $AirStopInvenSysId;
$Sequance++;
}
}
if ($ICSourceSysId == 3 && count($segmentsResult) > 1) {
$Sequance = 1;
foreach ($segmentsResult as $arrSegmentsRes) {
$FlightNumber = isset($arrSegmentsRes['Airline']['FlightNumber']) ? $arrSegmentsRes['Airline']['FlightNumber'] : 0;
$originAirportCode = $arrSegmentsRes['Origin']['Airport']['AirportCode'];
$destinationAirportCode = $arrSegmentsRes['Destination']['Airport']['AirportCode'];
$SourcePlaceSysId = !empty($arrCityIds[$originAirportCode]) ? $arrCityIds[$originAirportCode] : '0';
$DestPlaceSysId = !empty($arrCityIds[$destinationAirportCode]) ? $arrCityIds[$destinationAirportCode] : '0';
$Duration = isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0';
$GroundTime = isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0';
$FlightDuration = $Duration + $GroundTime;
$arrFlightStopsInsert = array(
"TBQAirInvenSysId" => $intFlightChildRecordId,
"SourcePlaceSysId" => $SourcePlaceSysId,
"DestPlaceSysId" => $DestPlaceSysId,
"Sequance" => $Sequance,
"StayDuration" => isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '',
"FlightDuration" => $FlightDuration,
"AirlineCode" => isset($arrSegmentsRes['Airline']['AirlineCode']) ? $arrSegmentsRes['Airline']['AirlineCode'] : '',
"AirlineName" => isset($arrSegmentsRes['Airline']['AirlineName']) ? $arrSegmentsRes['Airline']['AirlineName'] : '',
"FlightNumber" => isset($arrSegmentsRes['Airline']['FlightNumber']) ? $arrSegmentsRes['Airline']['FlightNumber'] : '',
"FareClass" => isset($arrSegmentsRes['Airline']['FareClass']) ? $arrSegmentsRes['Airline']['FareClass'] : '',
"OriginAirportCode" => isset($arrSegmentsRes['Origin']['Airport']['AirportCode']) ? $arrSegmentsRes['Origin']['Airport']['AirportCode'] : '',
"DestinationAirportCode" => isset($arrSegmentsRes['Destination']['Airport']['AirportCode']) ? $arrSegmentsRes['Destination']['Airport']['AirportCode'] : '',
"IsFlightChange" => 0,
"NewFInvenSysId" => 0, //!empty($NewFInvenSysId)?$NewFInvenSysId:0,
"DepartureTime" => isset($arrSegmentsRes['Destination']['ArrTime']) ? $arrSegmentsRes['Destination']['ArrTime'] : '',
"ArrivalTime" => isset($arrSegmentsRes['Origin']['DepTime']) ? $arrSegmentsRes['Origin']['DepTime'] : '',
"HaultInclusions" => '',
"NoOfSeatAvailable" => isset($arrSegmentsRes['NoOfSeatAvailable']) ? $arrSegmentsRes['NoOfSeatAvailable'] : 0,
"CurrencyType" => isset($arrCurrencyList[$Currency]) ? $arrCurrencyList[$Currency] : '1',
"PublishedFare" => isset($result['Fare']['OfferedFare']) ? $result['Fare']['OfferedFare'] : $result['FairRules']['PublishedFare'],
"CommissionEarned" => isset($result['Fare']['CommissionEarned']) ? $result['Fare']['CommissionEarned'] : $result['FairRules']['CommissionEarned'],
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"UpdateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
"IsActive" => 1,
"IsMarkForDelete" => 0
);
// echo "<pre>";
// print_r($arrFlightStopsInsert);die;
$AirStopInvenSysId = $objFlight->addFlightStopsDetails($arrFlightStopsInsert);
$AirInvenSysId = $AirStopInvenSysId;
$Sequance++;
}
}
}
// InOutBound/InBound Flights Data Ends...
return $AirInvenSysIdArr;
}
} // Foreach ends
// exit;
} catch (Zend_Exception $e) {
print_r($e->getMessage());
die;
return $AirInvenSysIdArr;
}
}
}
public function savePassengerDetailsTripjackAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
try {
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgentDetailById = $crmcustomerObj->getAgentDetailById($this->intLoggedinUserId);
$IsAllowFlightBooking = isset($getAgentDetailById[0]['IsAllowFlightBooking']) ? $getAgentDetailById[0]['IsAllowFlightBooking'] : 0;
$IsCheckWallet = isset($this->agencyDetails['IsCheckWallet']) ? $this->agencyDetails['IsCheckWallet'] : 0;
$sessionFlightSearchParams = !empty($this->getRequest()->getParam('sessionFlightSearchParams')) ? json_decode($this->getRequest()->getParam('sessionFlightSearchParams'), true) : 0;
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$AgencySysId = isset($sessionFlightSearchParams['AgencySysId']) ? $sessionFlightSearchParams['AgencySysId'] : '';
$B2BType = isset($sessionFlightSearchParams['B2BType']) ? $sessionFlightSearchParams['B2BType'] : '';
$editLeadId = isset($sessionFlightSearchParams['editLeadId']) ? $sessionFlightSearchParams['editLeadId'] : '';
$route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : '';
// echo "<pre>";
// print_r($sessionFlightSearchParams);die; TB_Agency_Customer_TravelPlan
$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : '';
$isgstapply = (trim($this->getRequest()->getParam('isgstapply'))) ? trim($this->getRequest()->getParam('isgstapply')) : 0;
$gstnnumber = trim($this->getRequest()->getParam('gstnnumber'));
$companyname = trim($this->getRequest()->getParam('companyname'));
$gstemail = trim($this->getRequest()->getParam('gstemail'));
$gstphone = trim($this->getRequest()->getParam('gstphone'));
$gstaddress = trim($this->getRequest()->getParam('gstaddress'));
$gststate = trim($this->getRequest()->getParam('gststate'));
$intCustomerSysId = trim($this->getRequest()->getParam('customerId'));
$intOutBoundId = !empty($this->getRequest()->getParam('intOutBoundId')) ? json_decode($this->getRequest()->getParam('intOutBoundId'), true) : 0;
$ICSourceSysId_ = isset($intOutBoundId[0]['ICSourceSysId']) ? $intOutBoundId[0]['ICSourceSysId'] : 0;
//echo "<pre>";print_r($intOutBoundId);echo "</pre>";die;
$intInBoundId = !empty($this->getRequest()->getParam('intInBoundId')) ? $this->getRequest()->getParam('intInBoundId') : 0;
if ($interNationalSearch == "1" && $route == "2") {
if ($ICSourceSysId_ == 3) {
$BookingData[] = isset($intOutBoundId[0]) ? $intOutBoundId[0] : '';
$InternationalData[] = isset($intOutBoundId[0]) ? $intOutBoundId[0] : '';
} else {
$BookingData[] = isset($intOutBoundId[0]['InternationalData']) ? $intOutBoundId[0]['InternationalData'] : '';
$InternationalData[] = isset($intOutBoundId[0]['InternationalData']) ? $intOutBoundId[0]['InternationalData'] : '';
}
$arrCommonInsVariables = isset($intOutBoundId[0]['arrCommonInsVariables']) ? $intOutBoundId[0]['arrCommonInsVariables'] : '';
$AirInvenSysIdArrNew = $this->insertInterNationalFlightNewAction($InternationalData, $arrCommonInsVariables, $this->intLoggedinUserId, $ICSourceSysId_);
} else {
$BookingData = $intOutBoundId;
}
// echo "<pre>";print_r($AirInvenSysIdArrNew);echo "</pre>"; ARR_SALUTION_TJ
// echo "<pre>";print_r($BookingData);echo "</pre>";
// die;
$SearchTraceId = $BookingData[0]['SearchTraceId'];
$isAdobrMandatory = $BookingData[0]['isAdobrMandatory'];
$isCdobrMandatory = $BookingData[0]['isCdobrMandatory'];
$isIdobrMandatory = $BookingData[0]['isIdobrMandatory'];
$IsPassMandatory = $BookingData[0]['IsPassMandatory'];
$IsPassExpiry = $BookingData[0]['IsPassExpiry'];
$IsPassIssue = $BookingData[0]['IsPassIssue'];
$IsPassExpiry = $BookingData[0]['IsPassExpiry'];
$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
$this->CurrencyRate = isset($BookingData[0]['FairRules']['CurrencyRate']) ? $BookingData[0]['FairRules']['CurrencyRate'] : 1;
$objFlight = new Travel_Model_TblFlight();
$arrSelectedFlightDetails = $BookingData;
$post = $this->getRequest()->getPost();
$SelectedBaggSessionNew = json_decode($post['SelectedBaggSessionNew'], true);
$SelectedMealSessionNew = json_decode($post['SelectedMealSessionNew'], true);
$selectedSeatSession = json_decode($post['selectedSeatSession'], true);
$mytrip_city_from = explode(',', $sessionFlightSearchParams['sourceCityText']);
$mytrip_city_to = explode(',', $sessionFlightSearchParams['destinationCityText']);
if ($route == 1) {
$sectorTitle = $mytrip_city_from[0] . '-' . $mytrip_city_to[0];
} else {
$sectorTitle = $mytrip_city_from[0] . '-' . $mytrip_city_to[0] . '-' . $mytrip_city_from[0];
}
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$PublishedFare = 0;
$BaseAmount = 0;
$AgentCommisionEarned = 0;
$AgentCommisionEarnedGST = 0;
$AgencyMarkUp = 0;
$AgencyMarkUpGST = 0;
$GTXMarkUp = 0;
$GTXMarkUpGST = 0;
$TotalExtraCharge = 0;
$AgentServiceTaxAmount = 0;
$TotalAgencyMarkUp = 0;
$TotalExtraMarkup = 0;
$TotalExtraMarkupOnGST = 0;
$TotalDiscountValue = 0;
$FareSummary = [];
if ($BookingData) {
foreach ($BookingData as $k => $booking) {
$DiscountValue = isset($booking['FairRules']['DiscountValue']) ? $booking['FairRules']['DiscountValue'] : 0;
$ExtraMarkup = isset($booking['FairRules']['ExtraMarkup']) ? $booking['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = isset($booking['FairRules']['ExtraMarkupOnGST']) ? $booking['FairRules']['ExtraMarkupOnGST'] : 0;
if ($booking['FairRules']['FareBreakdown']) {
foreach ($booking['FairRules']['FareBreakdown'] as $key => $value) {
$IntCommission = $value['IntCommission'];
$CommissionEarned = $value['CommissionEarned'];
$PBaseFare = $value['BaseFare'];
$MF = $value['MF']; //Management Fee
$YQ = $value['YQ']; //Fuel Surcharge
$AGST = $value['AGST']; //Airline GST Component
$MFT = $value['MFT']; //Management Fee Tax
$OT = $value['OT']; //Other Charges
$MU = $value['MU']; //Markup
$YR = $value['YR']; //Carrier Misc Fee
$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$intGTXMarkUp = $value['intGTXMarkUp'];
$GTXMarkUpGST = $value['GTXMarkUpGST'];
$intTotalGST = $value['intTotalGST'];
$apiMarkup = $value['apiMarkup'];
$CommEarned = $value['CommEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$GrandTotalBaseFare = (($PBaseFare - $CommEarned + $otherCharge + $FixedMarkUp + $apiMarkup + $intGTXMarkUp + $GTXMarkUpGST) - $customerDiscount);
$BaseAmount += (($PBaseFare - $CommEarned + $otherCharge + $intGTXMarkUp + $GTXMarkUpGST) - $customerDiscount); //$GrandTotalBaseFare;
$AgentServiceTaxAmount += $intTotalGST;
$TotalAgencyMarkUp += ($FixedMarkUp + $apiMarkup);
}
}
$PublishedFare += $booking['FairRules']['PublishedFare'];
$TotalExtraCharge += ($ExtraMarkup + $ExtraMarkupOnGST);
$TotalExtraMarkup += ($ExtraMarkup);
$TotalExtraMarkupOnGST += ($ExtraMarkupOnGST);
$TotalDiscountValue += ($DiscountValue);
//$BaseAmount += $booking['FairRules']['OfferedFare'];
$AgentCommisionEarned += $booking['FairRules']['CommEarned'];
}
}
$intOfferedFare = ($BaseAmount + $MealFare + $BaggFare + $SeatPrice); //isset($post['intPayableFromWallet']) ? $post['intPayableFromWallet'] : '0';AirInvenSysIdArr
$totalCost = ($PublishedFare + $MealFare + $BaggFare + $SeatPrice + $TotalExtraCharge - $TotalDiscountValue); //isset($post['intCostToCustomer']) ? $post['intCostToCustomer'] : '0';
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strSourceAirportCode = $sessionFlightSearchParams['from'];
$strDestinationAirportCode = $sessionFlightSearchParams['to'];
$adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
$childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
$infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
$totalPassengers = $adultCount + $childCount + $infantCount;
//encode travellers information in json to save created by Er Amit Kumar Dubey on 6 march 2017 at 11:21 AM
$departure_dates_string = $sessionFlightSearchParams['departure_dates'];
$strDepatureDate = $sessionFlightSearchParams['strDepatureDate'];
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$return_dates_string = $sessionFlightSearchParams['return_dates'];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($sessionFlightSearchParams['return_dates']) && !empty($sessionFlightSearchParams['return_dates'])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
$departureDates = $sessionFlightSearchParams['departure_dates'];
if ($route == "2") {
$departureDatesValid = $return_dates;
} else {
$departureDatesValid = $departure_dates;
}
$Cities__ = [];
if ($route == "3") {
$departure_dates = $departureDatesValid = isset($strDepatureDate[0]) ? $strDepatureDate[0] : '';
$departureDates = $sessionFlightSearchParams['departure_dates'][0];
$sourceCityText = $sessionFlightSearchParams['sourceCityText'];
$destinationCityText = $sessionFlightSearchParams['destinationCityText'];
if ($strSourceAirportCode && $route == '3') {
foreach ($strSourceAirportCode as $key => $value) {
$string = isset($sourceCityText[$key]) ? $sourceCityText[$key] : '';
$sourceCityText__ = substr($string, 0, strpos($string, ','));
$string2 = isset($destinationCityText[$key]) ? $destinationCityText[$key] : '';
$destinationCityText__ = substr($string2, 0, strpos($string2, ','));
$Cities__[] = $sourceCityText__ . '-' . $destinationCityText__;
}
}
}
$oneway_origin_text = isset($sessionFlightSearchParams['oneway_origin_text']) ? $sessionFlightSearchParams['oneway_origin_text'] : $sessionFlightSearchParams['sourceCityText'];
$oneway_destination_text = isset($sessionFlightSearchParams['oneway_destination_text']) ? $sessionFlightSearchParams['oneway_destination_text'] : $sessionFlightSearchParams['destinationCityText'];
$flight_class = $sessionFlightSearchParams['flight_class'];
$roomjson = array();
$roomjson[1]['route'] = $route;
$roomjson[1]['Adult'] = $adultCount;
$roomjson[1]['Child'] = $childCount;
$roomjson[1]['bedtype'] = '';
$roomjson[1]['departuredate'] = $departure_dates_string;
$roomjson[1]['returndate'] = $return_dates_string;
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
//$roomjson[1]['fromaircode'] = $strSourceAirportCode;
//$roomjson[1]['toaircode'] = $strDestinationAirportCode;
$roomjson[1]['airclass'] = $flight_class;
for ($c = 1; $c <= $childCount; $c++) {
$childsage = $infantCount;
$roomjson[$c]['route'] = $route;
$roomjson[$c]['Adult'] = $adultCount;
$roomjson[$c]['Child'] = $childCount;
$roomjson[$c]['ChildAge_' . $c] = $childsage;
$roomjson[$c]['bedtype'] = '';
$roomjson[$c]['departuredate'] = $departure_dates_string;
$roomjson[$c]['returndate'] = $return_dates_string;
$roomjson[$c]['fromaircode'] = $oneway_origin_text;
$roomjson[$c]['toaircode'] = $oneway_destination_text;
$roomjson[$c]['airclass'] = $flight_class;
}
$RoomInfoJson = json_encode($roomjson);
//encode travellers information in json to save created by Er Amit Kumar Dubey on 6 march 2017 at 11:21 AM
if (empty($adultCount)) {
throw new Exception("Adult count not found.");
}
$arrCustomer = array();
$arrCustomerMembers = array();
$ForCustomerSession = array();
$key = 0;
// echo "<pre>";print_r($post);die;
for ($i = 1; $i <= $totalPassengers; $i++) {
$paxType = $post['paxType-' . $i];
$firstName = $fname = $post['passenger-firstname-' . $i];
$lastName = $post['passenger-lastname-' . $i];
$relation = $post['relation-' . $i];
$salutation = $post['passenger-salutation-' . $i];
$mobileNumber = $post['mobile_number'];
$email_id = $post['email_id'];
$airline_number = $post['airline_number'];
$airline_email = $post['airline_email'];
$passengerDob = $post['passenger-dob-' . $i];
$AdultpassengerpassengerDob = isset($post['Adultpassenger-dob-' . $i]) ? $post['Adultpassenger-dob-' . $i] : '';
$nationality = isset($post['passenger-nationality-' . $i]) ? $post['passenger-nationality-' . $i] : '';
$passengerPassportNo = isset($post['passenger-PassportNo-' . $i]) ? $post['passenger-PassportNo-' . $i] : '';
$passengerPassportExpiry = isset($post['passenger-PassportExpiry-' . $i]) ? $post['passenger-PassportExpiry-' . $i] : '';
$passporIssue = isset($post['passenger-passporIssue-' . $i]) ? $post['passenger-passporIssue-' . $i] : '';
// passenger-address-1
if (!empty($passengerDob)) {
$passengerDob = explode("/", $passengerDob);
$passengerDob = $passengerDob[2] . "-" . $passengerDob[1] . "-" . $passengerDob[0];
}
if (!empty($AdultpassengerpassengerDob)) {
$AdultpassengerpassengerDob = explode("/", $AdultpassengerpassengerDob);
$AdultpassengerpassengerDob = $AdultpassengerpassengerDob[2] . "-" . $AdultpassengerpassengerDob[1] . "-" . $AdultpassengerpassengerDob[0];
}
if (!empty($passengerPassportExpiry)) {
$passengerPassportExpiry = explode("/", $passengerPassportExpiry);
$passengerPassportExpiry = $passengerPassportExpiry[2] . "-" . $passengerPassportExpiry[1] . "-" . $passengerPassportExpiry[0];
}
if (!empty($passporIssue)) {
$passporIssue = explode("/", $passporIssue);
$passporIssue = $passporIssue[2] . "-" . $passporIssue[1] . "-" . $passporIssue[0];
}
$passengerCity = ($post['passenger-city-1']) ? $post['passenger-city-1'] : 0;
$passengerCountry = ($post['passenger-country-1']) ? $post['passenger-country-1'] : '';
$passengerAddress = ($post['passenger-address-1']) ? $post['passenger-address-1'] : '';
$AdultageCalculator = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->ageCalculator($departure_dates, $AdultpassengerpassengerDob);
if (empty($airline_number)) {
$response = array('succes' => false, 'msg' => 'Please enter airline number.', 'index' => 'airline_number');
echo json_encode($response);
exit;
}
if (strlen($airline_number) != 10 && strlen($airline_number) != 11) {
$response = array('succes' => false, 'msg' => 'Please enter a valid airline number.', 'index' => 'airline_number');
echo json_encode($response);
exit;
}
if (empty($mobileNumber)) {
$response = array('succes' => false, 'msg' => 'Please enter mobile number.', 'index' => 'airline_number');
echo json_encode($response);
exit;
}
if (empty($airline_email)) {
$response = array('succes' => false, 'msg' => 'Please enter airline Email ID.', 'index' => 'airline_email');
echo json_encode($response);
exit;
}
if (!filter_var($airline_email, FILTER_VALIDATE_EMAIL)) {
$msg = "Airline Email address is not valid.";
$response = array('success' => false, 'msg' => $msg, 'index' => 'airline_email');
echo json_encode($response);
exit;
}
if (strlen($mobileNumber) != 10 && strlen($mobileNumber) != 11) {
$response = array('succes' => false, 'msg' => 'Please enter a valid mobile number.', 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
if (empty($email_id)) {
$response = array('succes' => false, 'msg' => 'Please enter Email ID.', 'index' => 'email_id');
echo json_encode($response);
exit;
}
if (!filter_var($email_id, FILTER_VALIDATE_EMAIL)) {
$msg = "Email address is not valid.";
$response = array('success' => false, 'msg' => $msg, 'index' => 'email_id');
echo json_encode($response);
exit;
}
if (empty($firstName)) {
$response = array('succes' => false, 'msg' => 'Please enter first name.', 'index' => 'passenger-firstname-' . $i);
echo json_encode($response);
exit;
}
if (empty($lastName)) {
$response = array('succes' => false, 'msg' => 'Please enter last name.', 'index' => 'passenger-lastname-' . $i);
echo json_encode($response);
exit;
}
if ($paxType == 1 && $isAdobrMandatory) {
if (empty($passengerDob)) {
$response = array('succes' => false, 'msg' => 'Please enter date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 2 && $isCdobrMandatory) {
if (empty($passengerDob)) {
$response = array('succes' => false, 'msg' => 'Please enter date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 3 && $isIdobrMandatory) {
if (empty($passengerDob)) {
$response = array('succes' => false, 'msg' => 'Please enter date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
}
// if($AdultageCalculator < 12) {
// $response = array('succes' => false, 'msg' => 'Please enter valid adult date of birth.','index' => 'passenger-dob-' . $i);
// echo json_encode($response);
// exit;
// }
//echo $ageCalculator;die;
if (isset($post['passenger-nationality-' . $i]) && empty($nationality) && $IsPassMandatory) {
$response = array('succes' => false, 'msg' => 'Please select Nationality.', 'index' => 'passenger-nationality-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-PassportNo-' . $i]) && empty($passengerPassportNo) && $IsPassMandatory) {
$response = array('succes' => false, 'msg' => 'Please enter passenger passport no.', 'index' => 'passenger-PassportNo-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-passporIssue-' . $i]) && empty($passporIssue) && $IsPassIssue == 1) {
$response = array('succes' => false, 'msg' => 'Please enter passport issue date.', 'index' => 'passenger-passporIssue-' . $i);
echo json_encode($response);
exit;
}
if ($passporIssue == '1900-01-01' && $IsPassIssue == 1) {
$response = array('succes' => false, 'msg' => 'Please enter valid passport issue date.', 'index' => 'passenger-passporIssue-' . $i);
echo json_encode($response);
exit;
}
$CurrentDatesValid = date('Y-m-d');
if (isset($post['passenger-PassportExpiry-' . $i]) && strtotime($CurrentDatesValid) < strtotime($passporIssue) && $IsPassIssue) {
$response = array('succes' => false, 'msg' => 'Please enter valid passport issue date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-PassportExpiry-' . $i]) && empty($passengerPassportExpiry) && $IsPassExpiry) {
$response = array('succes' => false, 'msg' => 'Please enter passport expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-PassportExpiry-' . $i]) && strtotime($departure_dates) > strtotime($passengerPassportExpiry) && $IsPassExpiry) {
$response = array('succes' => false, 'msg' => 'Please enter valid passport expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
$expiry_dateY = date_diff(date_create($passengerPassportExpiry), date_create($departureDatesValid))->y;
$expiry_dateM = date_diff(date_create($passengerPassportExpiry), date_create($departureDatesValid))->m;
if ($expiry_dateY == 0 && $expiry_dateM <= 6 && $interNationalSearch == '1' && $IsPassExpiry) {
$response = array('succes' => false, 'msg' => "Passenger " . $i . " Passport should have at least six months of validity from the date of travel.", 'index' => 'passportnoexpiry-' . $i);
echo json_encode($response);
exit;
}
if ($paxType == 1 && $isAdobrMandatory) {
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
if ($AdultAge < 12) {
$response = array('succes' => false, 'msg' => "Adult age should be greater than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 2 && $isCdobrMandatory) {
//$departureDates = $sessionFlightSearchParams['departure_dates'];
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDates = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$childAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($childAge < 2 || $childAge >= 12) {
$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 3 && $isIdobrMandatory) {
//$departureDates = $sessionFlightSearchParams['departure_dates'];
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDates = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$infantAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($infantAge >= 2) {
$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (empty($passengerCity) && $ICSourceSysId == 3) {
$response = array('succes' => false, 'msg' => 'Please enter City.', 'index' => 'passenger-city-1');
echo json_encode($response);
exit;
}
if (empty($passengerAddress) && $ICSourceSysId == 3) {
$response = array('succes' => false, 'msg' => 'Please enter Address.', 'index' => 'passenger-address-1');
echo json_encode($response);
exit;
}
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($this->intLoggedinAgencyId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
if ($i == 1 && $relation == 0) {
$arrCustomer = $ForCustomerSession[$key] = array(
'AgencySysId' => $AgencySysId, 'CRMCustSysId' => 0, 'EmailId' => $email_id, 'Salutation' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'PassportIssue' => $passporIssue, 'PassportNationality' => $nationality, 'PassportNo' => $passengerPassportNo, 'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0',
'LeadSourceSysId' => $leadsource, 'LeadStageSysId' => $leadstage, 'GstNumber' => $gstnnumber, 'GstCompany' => $companyname,
'GstEmail' => $gstemail, 'GstPhone' => $gstphone, 'GstAddress' => $gstaddress, 'GstState' => $gststate
);
if (empty($intCustomerSysId)) {
$objGest = new Travel_Model_Tbltbbcuser();
$arrCustomer['ContactNumber'] = $mobileNumber;
$intCustomerSysId = $objGest->createAgencyCustomer($arrCustomer, $AgencySysId);
} else {
$objGest = new Travel_Model_Tbltbbcuser();
$arrCustomer['ContactNumber'] = $mobileNumber;
$intCustomerSysId = $objGest->createAgencyCustomer($arrCustomer, $AgencySysId);
}
//echo "<pre>";print_r($arrCustomer);echo "</pre>";die;
//echo '<pre>';print_r($arrCustomer);die;
} else {
// $arrCustomerMembers[] = array('AgencySysId' => $this->intLoggedinAgencyId, 'EmailId' => $email_id, 'Title' => $salutation,'Relation' => $relation,
// 'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
// 'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
// 'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
// 'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
// 'RandomCode' => '', 'Gender' =>'', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
// 'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '','DOB' => $passengerDob,'PassportNo' => $passengerPassportNo,'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity,'paxType' => $paxType,
// 'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
// 'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
// 'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0');
if (!empty($passengerPassportNo)) {
$arrCustomerMembers[] = $ForCustomerSession[$key] = array(
'AgencySysId' => $AgencySysId, 'EmailId' => $email_id, 'Title' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'PassportIssue' => $passporIssue, 'PassportNationality' => $nationality, 'PassportNo' => $passengerPassportNo, 'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0'
);
} else {
$arrCustomerMembers[] = $ForCustomerSession[$key] = array(
'AgencySysId' => $AgencySysId, 'EmailId' => $email_id, 'Title' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0'
);
}
}
$ForCustomerSession[$key]['airline_number'] = $airline_number;
$ForCustomerSession[$key]['airline_email'] = $airline_email;
$key++;
}
// echo "<pre>";print_r($intCustomerSysId);
// echo "<pre>";print_r($arrCustomerMembers);
// die('dd');
if ($BookingData && $isgstapply == 0) {
foreach ($BookingData as $values) {
if (trim($values['isGSTMandatory']) == 1) {
$response = array('succes' => false, 'msg' => 'GST mandatory for this flight.', 'index' => 'gstnnumber');
echo json_encode($response);
exit;
}
}
}
if ($isgstapply == 1) {
if (empty(trim($gstnnumber))) {
$response = array('succes' => false, 'msg' => 'Please enter GSTIN number.', 'index' => 'gstnnumber');
echo json_encode($response);
exit;
}
$is_valid_gstin = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->is_valid_gstin($gstnnumber);
if ($is_valid_gstin == 0) {
$response = array('succes' => false, 'msg' => 'Enter Valid GST Number', 'index' => 'gstnnumber');
echo json_encode($response);
exit;
}
if (empty(trim($companyname))) {
$response = array('succes' => false, 'msg' => 'Please enter company name.', 'index' => 'companyname');
echo json_encode($response);
exit;
}
if (empty(trim($gstemail))) {
$response = array('succes' => false, 'msg' => 'Please enter registered email id.', 'index' => 'gstemail');
echo json_encode($response);
exit;
}
if (!filter_var($gstemail, FILTER_VALIDATE_EMAIL)) {
$msg = "GST Email address is not valid.";
$response = array('success' => false, 'msg' => $msg, 'index' => 'gstemail');
echo json_encode($response);
exit;
}
if (empty(trim($gstphone))) {
$response = array('succes' => false, 'msg' => 'Please enter registered phone.', 'index' => 'gstphone');
echo json_encode($response);
exit;
}
if (strlen($gstphone) != 10 && strlen($gstphone) != 11) {
$response = array('succes' => false, 'msg' => 'Please enter a valid GST phone number.', 'index' => 'gstphone');
echo json_encode($response);
exit;
}
if (empty(trim($gstaddress))) {
$response = array('succes' => false, 'msg' => 'Please enter GST address.', 'index' => 'gstaddress');
echo json_encode($response);
exit;
}
}
//
if (empty($ForCustomerSession)) {
throw new Exception('Customer Information not found.');
}
//$objFlight = new Travel_Model_TblFlight();
// echo "<pre>";print_r($ForCustomerSession);
// echo "<pre>";print_r($BookingData);
// die;
if (empty($intCustomerSysId)) {
throw new Exception('Customer Id not found.');
}
$arrCustomerMembersIds = array();
if (!empty($arrCustomerMembers)) {
$arrCustomerMembersIds = $objFlight->createAgencyCustomerMembers($arrCustomerMembers, $AgencySysId, $intCustomerSysId);
//$arrCustomerMembersIds = $objFlight->createAgencyCustomerMembers($arrCustomerMembers, $this->intLoggedinAgencyId, $intCustomerSysId);
}
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$SecurityKey = $arrAgentDetail['SecurityKey'];
$sessionFlightSearchParams['SecurityKey'] = $SecurityKey;
$checkInventory = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CheckInventorycheckRetriveUpdateNew($BookingData, $sessionFlightSearchParams);
// $RetriveUpdateNew = new Zend_Session_Namespace('RetriveUpdateNew');
// $checkInventory = $RetriveUpdateNew->params;
if ($checkInventory[0]['Status'] == 1) {
$BookingData[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
$intOutBoundId[0]['bookingId'] = isset($checkInventory[0]['data']['RefNo']) ? $checkInventory[0]['data']['RefNo'] : 0;
} else {
$checkInventoryResponse = array('success' => $checkInventory[0]['Status'], 'status' => $checkInventory[0]['Status'], 'msg' => ($checkInventory[0]['message'] != '') ? $checkInventory[0]['message'] : 'Seats are no available.');
echo json_encode($checkInventoryResponse);
exit;
}
if (isset($checkInventory[1]['Status']) && !empty($checkInventory[1]) && $route == 2) {
if ($checkInventory[1]['Status'] == 1) {
$BookingData[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
$intOutBoundId[1]['bookingId'] = isset($checkInventory[1]['data']['RefNo']) ? $checkInventory[1]['data']['RefNo'] : 0;
} else {
$checkInventoryResponse = array('success' => $checkInventory[1]['Status'], 'status' => $checkInventory[1]['Status'], 'msg' => ($checkInventory[1]['message'] != '') ? $checkInventory[1]['message'] : 'Seats are no available.');
echo json_encode($checkInventoryResponse);
exit;
}
}
}
// echo "<pre>";print_r($Cities__);echo "</pre>";
// die;
// echo "<pre>";print_r($TotalExtraMarkup);
// echo "<pre>";print_r($TotalExtraMarkupOnGST);
// echo "<pre>";print_r($TotalDiscountValue);
// echo "<pre>";print_r($BookingData);
// die;
if (!empty($intCustomerSysId)) {
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$AgencyMarkUp___ = ($TotalAgencyMarkUp + $AgentCommisionEarned + $TotalExtraMarkup);
$AgentServiceTaxAmount___ = ($AgentServiceTaxAmount + $TotalExtraMarkupOnGST);
// Travel Plan Data....
if (empty($editLeadId)) {
$PlanBookingId = "Q/" . date('y');
$arrTravelPlan['PlanBookingId'] = $PlanBookingId;
$arrTravelPlan['Price'] = (($totalCost - $AgencyMarkUp___) - $AgentServiceTaxAmount___);
$arrTravelPlan['TotalCost'] = $totalCost;
$arrTravelPlan['NetPrice'] = $totalCost;
$arrTravelPlan['DiscountVal'] = ($TotalDiscountValue);
$arrTravelPlan['AgencyMarkUp'] = $AgencyMarkUp___; //($TotalAgencyMarkUp + $AgentCommisionEarned + $TotalExtraMarkup);
$arrTravelPlan['AgentServiceTaxAmount'] = $AgentServiceTaxAmount___; //($AgentServiceTaxAmount + $TotalExtraMarkupOnGST);
$arrTravelPlan['AgencySysId'] = $this->intLoggedinAgencyId;
$arrTravelPlan['AgentSysId'] = $this->intLoggedinUserId;
// $arrTravelPlan['AgentSysId'] = ($B2BType == 1)?$AgencySysId:$this->intLoggedinUserId;
$arrTravelPlan['CreatorSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['PlanType'] = '1'; // For Flight AgencyMarkUp
$arrTravelPlan['SupplierSysId'] = 3;
$arrTravelPlan['StatusType'] = 2;
$arrTravelPlan['InventoryType'] = 1;
$arrTravelPlan['CurrencyType'] = $BookingData[0]['CurrencyType'];
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['SourcePlaceSysId'] = $BookingData[0]['SourcePlaceSysId'];
$arrTravelPlan['DestinationPlacesSysId'] = $BookingData[0]['DestPlaceSysId'];
$arrTravelPlan['SourcePlaces'] = $BookingData[0]['SourcePlaceName'];
$arrTravelPlan['DestinationPlaces'] = $BookingData[0]['DestPlaceName'];
$arrTravelPlan['Cities'] = ($route == "3") ? implode(',', $Cities__) : $BookingData[0]['SourcePlaceName'] . "-" . $BookingData[0]['DestPlaceName'];
$arrTravelPlan['IsHotelFromApi'] = 1;
$arrTravelPlan['CustomerSysId'] = $intCustomerSysId;
$arrTravelPlan['StartDate'] = $departure_dates;
$arrTravelPlan['ValidTill'] = $return_dates;
$arrTravelPlan['CreateDate'] = $currentDate;
$arrTravelPlan['UpdateDate'] = $currentDate;
$arrTravelPlan['ApproveDate'] = $currentDate;
$arrTravelPlan['IsMarkForDel'] = 0;
$arrTravelPlan['IsActive'] = 1;
$arrTravelPlan['IsAprooved'] = 1;
$arrTravelPlan['LeadSourceSysId'] = $leadsource;
$arrTravelPlan['B2BAgencySysId'] = $AgencySysId;
$arrTravelPlan['IsB2BProposal'] = $IsB2BCustomer;
// if ($B2BType == 1 || $B2BType == 2) {
// $arrTravelPlan['IsB2BProposal'] = true; AgencyCommission
// }
$arrTravelPlan['Title'] = !empty($sectorTitle) ? $sectorTitle : 'NA';
// echo "<pre>";print_r($arrTravelPlan);die('1');
$TPSysId = $objFlight->insertTravelPlan($arrTravelPlan);
} else {
$TPSysId = $editLeadId;
}
$PlanBookingId = "Q/" . date('y');
$arrTravelPlan['PlanBookingId'] = $PlanBookingId;
$arrTravelPlan['MasterTPSysId'] = $TPSysId;
$arrTravelPlan['Price'] = (($totalCost - $AgencyMarkUp___) - $AgentServiceTaxAmount___);
$arrTravelPlan['TotalCost'] = $totalCost;
$arrTravelPlan['NetPrice'] = $totalCost;
$arrTravelPlan['DiscountVal'] = ($TotalDiscountValue);
$arrTravelPlan['AgencyMarkUp'] = $AgencyMarkUp___; //($TotalAgencyMarkUp + $AgentCommisionEarned + $TotalExtraMarkup);
$arrTravelPlan['AgentServiceTaxAmount'] = $AgentServiceTaxAmount___; //($AgentServiceTaxAmount + $TotalExtraMarkupOnGST);
$arrTravelPlan['VersionId'] = 1;
$arrTravelPlan['AgencySysId'] = $this->intLoggedinAgencyId;
$arrTravelPlan['AgentSysId'] = $this->intLoggedinUserId;
// $arrTravelPlan['AgentSysId'] = ($B2BType == 1)?$AgencySysId:$this->intLoggedinUserId;
$arrTravelPlan['CreatorSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['PlanType'] = '1'; // For Flight
$arrTravelPlan['SupplierSysId'] = 3;
$arrTravelPlan['StatusType'] = 4;
$arrTravelPlan['InventoryType'] = 1;
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['CustomerSysId'] = $intCustomerSysId;
$arrTravelPlan['CurrencyType'] = $BookingData[0]['CurrencyType'];
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['SourcePlaceSysId'] = $BookingData[0]['SourcePlaceSysId'];
$arrTravelPlan['DestinationPlacesSysId'] = $BookingData[0]['DestPlaceSysId'];
$arrTravelPlan['SourcePlaces'] = $BookingData[0]['SourceAirportCode'];
$arrTravelPlan['DestinationPlaces'] = $BookingData[0]['DestAirportCode'];
$arrTravelPlan['Cities'] = ($route == "3") ? implode(',', $Cities__) : $BookingData[0]['SourceAirportCode'] . "-" . $BookingData[0]['DestAirportCode'];
$arrTravelPlan['IsHotelFromApi'] = 1;
//$arrTravelPlan['TemplatePckSysId'] = '';
$arrTravelPlan['ProposalEmailTo'] = !empty($email_id) ? trim($email_id) : 0;
$arrTravelPlan['StartDate'] = $departure_dates;
$arrTravelPlan['ValidTill'] = $return_dates;
$arrTravelPlan['CreateDate'] = $currentDate;
$arrTravelPlan['UpdateDate'] = $currentDate;
$arrTravelPlan['ApproveDate'] = $currentDate;
$arrTravelPlan['IsMarkForDel'] = 0;
$arrTravelPlan['IsActive'] = 1;
$arrTravelPlan['IsAprooved'] = 1;
$arrTravelPlan['LeadSourceSysId'] = $leadsource;
$arrTravelPlan['B2BAgencySysId'] = $AgencySysId;
$arrTravelPlan['IsB2BProposal'] = $IsB2BCustomer;
// if ($B2BType == 1 || $B2BType == 2) {
// $arrTravelPlan['IsB2BProposal'] = true; TBOAirInvenAPISysId
// }
$arrTravelPlan['Title'] = !empty($sectorTitle) ? $sectorTitle : 'NA';
$expectedClosureData = [
'ExpectedClosureDate' => $departure_dates,
'ExpectedValue' => $totalCost ? round($totalCost, 2) : 0,
];
$this->_crmcusttravelplan->expectedClosureData($TPSysId, $expectedClosureData);
$TPSysId = $objFlight->insertTravelPlan($arrTravelPlan);
$arrPaxData = array();
$arrPaxData = array();
foreach ($arrSelectedFlightDetails as $ks => $flightRounds) {
if (!empty($TPSysId)) {
if (!empty($arrCustomer)) {
$arrPaxData['TPSysId'] = $TPSysId;
$arrPaxData['VersionId'] = '1';
$arrPaxData['CustomerSysId'] = $intCustomerSysId;
$arrPaxData['MemberSysId'] = 0;
$arrPaxData['IsLeadPax'] = 1;
$arrPaxData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPaxData['IsApproved'] = '1';
$arrPaxData['IsActive'] = '1';
$arrPaxData['IsMarkForDelete'] = '0';
$arrPaxData['IsReturn'] = $ks;
$arrPaxData['paxType'] = 1;
$arrPaxData['FirstName'] = ($arrCustomer) ? $arrCustomer['FirstName'] : '';
$arrPaxData['LastName'] = ($arrCustomer) ? $arrCustomer['LastName'] : '';
$arrPaxData['Salutation'] = ($arrCustomer['Salutation']) ? $arrCustomer['Salutation'] : '';
$arrPaxData['Title'] = ($arrCustomer['Salutation']) ? $arrCustomer['Salutation'] : '';
$arrPaxData['GstNumber'] = $gstnnumber;
$arrPaxData['GstCompany'] = $companyname;
$arrPaxData['GstEmail'] = $gstemail;
$arrPaxData['GstPhone'] = $gstphone;
$arrPaxData['GstAddress'] = $gstaddress;
$arrPaxData['GstState'] = $gststate;
$arrPaxData['isgstapply'] = $isgstapply;
$objFlight->insertTravelPlanPax($arrPaxData);
}
if (!empty($arrCustomerMembersIds)) {
$VersionId = 2;
foreach ($arrCustomerMembersIds as $kkk => $memberSysId) {
$Members = ($arrCustomerMembers[$kkk]) ? $arrCustomerMembers[$kkk] : '';
if (!empty($arrCustomer)) {
$IsLeadPax = 0;
} else {
if ($kkk == 0) {
$IsLeadPax = 1;
} else {
$IsLeadPax = 0;
}
}
$arrPaxData['TPSysId'] = $TPSysId;
$arrPaxData['VersionId'] = $VersionId;
$arrPaxData['CustomerSysId'] = $intCustomerSysId;
$arrPaxData['MemberSysId'] = $memberSysId;
$arrPaxData['IsLeadPax'] = $IsLeadPax;
$arrPaxData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPaxData['IsApproved'] = '1';
$arrPaxData['IsActive'] = '1';
$arrPaxData['IsMarkForDelete'] = '0';
$arrPaxData['IsReturn'] = $ks;
$arrPaxData['paxType'] = ($Members) ? $Members['paxType'] : 0;
$arrPaxData['FirstName'] = ($Members) ? $Members['FirstName'] : '';
$arrPaxData['LastName'] = ($Members) ? $Members['LastName'] : '';
$arrPaxData['Salutation'] = ($Members['Title']) ? $Members['Title'] : '';
$arrPaxData['Title'] = ($Members['Title']) ? $Members['Title'] : '';
$arrPaxData['GstNumber'] = $gstnnumber;
$arrPaxData['GstCompany'] = $companyname;
$arrPaxData['GstEmail'] = $gstemail;
$arrPaxData['GstPhone'] = $gstphone;
$arrPaxData['GstAddress'] = $gstaddress;
$arrPaxData['GstState'] = $gststate;
$arrPaxData['isgstapply'] = $isgstapply;
$objFlight->insertTravelPlanPax($arrPaxData);
$VersionId++;
}
}
}
}
// Travel Itenary Data....
$arrPlanItenary['TPSysId'] = $TPSysId;
$arrPlanItenary['Sequence'] = 1;
$arrPlanItenary['AgencySysId'] = $this->intLoggedinAgencyId;
$arrPlanItenary['StartDate'] = $currentDate;
$arrPlanItenary['EndDate'] = $currentDate;
$arrPlanItenary['CreateDate'] = $currentDate;
$arrPlanItenary['UpdateDate'] = $currentDate;
$arrPlanItenary['IsActive'] = 1;
$TPIntSysId = $objFlight->insertTravelPlanItenary($arrPlanItenary);
//echo "<pre>";
//print_r($BookingData);
// Travel Plan Air Data....
$AirInvenSysIdArr = [];
$AgencyMarkUp = 0;
$GTXMarkUp = 0;
$AgentCommisionEarned = 0;
$BaseAmount = 0;
$PublishedFare = 0;
$TotalDiscountValue = 0;
if (!empty($BookingData)) {
$intRounds = 0;
$arrIntTpAirId = array();
foreach ($BookingData as $keys => $flightRounds) {
$IsNewMigration = isset($flightRounds['IsNewMigration']) ? $flightRounds['IsNewMigration'] : 0;
$IsTJFlightAPI = isset($flightRounds['IsTJFlightAPI']) ? $flightRounds['IsTJFlightAPI'] : 0;
$Currency = $flightRounds['FairRules']['Currency'];
$currencySysId = $flightRounds['FairRules']['currencySysId'];
$BaseFairRules = $flightRounds['FairRules']['BaseFare'];
$Tax = !empty($flightRounds['FairRules']['Tax']) ? $flightRounds['FairRules']['Tax'] : 0;
$YQTax = !empty($flightRounds['FairRules']['YQTax']) ? $flightRounds['FairRules']['YQTax'] : 0;
$AdditionalTxnFeeOfrd = $flightRounds['FairRules']['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $flightRounds['FairRules']['AdditionalTxnFeePub'];
$OtherCharges = $flightRounds['FairRules']['OtherCharges'];
$Discount = $flightRounds['FairRules']['Discount'];
$PublishedFare = $flightRounds['FairRules']['PublishedFare'];
$CommissionEarned = isset($flightRounds['FairRules']['CommissionEarned']) ? $flightRounds['FairRules']['CommissionEarned'] : 0;
//$CommissionEarned = isset($flightRounds['FairRules']['CommEarned']) ? $flightRounds['FairRules']['CommEarned'] : 0;
$PLBEarned = $flightRounds['FairRules']['PLBEarned'];
$IncentiveEarned = $flightRounds['FairRules']['IncentiveEarned'];
$OfferedFare = $flightRounds['FairRules']['OfferedFare'];
$TdsOnCommission = isset($flightRounds['FairRules']['TdsOnCommission']) ? $flightRounds['FairRules']['TdsOnCommission'] : 0;
$TdsOnPLB = $flightRounds['FairRules']['TdsOnPLB'];
$TdsOnIncentive = $flightRounds['FairRules']['TdsOnIncentive'];
$ServiceFee = $flightRounds['FairRules']['ServiceFee'];
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinAgencyId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => $currencySysId,
"BaseFare" => $BaseFairRules,
"Tax" => $Tax,
"YQTax" => $YQTax,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"OtherCharges" => $OtherCharges,
"Discount" => $Discount,
"ServiceFee" => $ServiceFee,
"PublishedFare" => $PublishedFare,
"CommissionEarned" => $CommissionEarned,
"PLBEarned" => $PLBEarned,
"IncentiveEarned" => $IncentiveEarned,
"OfferedFare" => $OfferedFare,
"TdsOnCommission" => $TdsOnCommission,
"TdsOnPLB" => $TdsOnPLB,
"TdsOnIncentive" => $TdsOnIncentive,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => 1,
"IsMarkForDel" => 1
);
//$AirInvenSysId = isset($AirInvenSysIdArr[$keys]) ? $AirInvenSysIdArr[$keys] : 0; TdsOnCommission
if ($interNationalSearch == "1" && $route == "2") {
$Segments = $flightRounds['Segments'];
} else {
$Segments = $flightRounds['Segments'];
}
$SeatPriceSeg = 0;
$MealPriceSeg = 0;
$BagPriceSeg = 0;
$FlyingMinutes = 0;
foreach ($Segments as $seg) {
$segmentid = $seg['segmentid'];
$SelectedBagg = isset($SelectedBaggSessionNew[$segmentid]) ? $SelectedBaggSessionNew[$segmentid] : [];
$SelectedMeal = isset($SelectedMealSessionNew[$segmentid]) ? $SelectedMealSessionNew[$segmentid] : [];
$SelectedSeat = isset($selectedSeatSession[$segmentid]) ? $selectedSeatSession[$segmentid] : [];
if (!empty($SelectedSeat)) {
foreach ($SelectedSeat as $val) {
$SeatPriceSeg += $val['amount'];
}
}
if (!empty($SelectedMeal)) {
foreach ($SelectedMeal as $val) {
$MealPriceSeg += $val['Price'];
}
}
if (!empty($SelectedBagg)) {
foreach ($SelectedBagg as $val) {
$BagPriceSeg += $val['Price'];
}
}
$strBaggage = $seg['Baggage'];
$strCabinBaggage = $seg['CabinBaggage'];
$TripIndicator = $seg['TripIndicator'];
$SegmentIndicator = $seg['TripIndicator'];
$AirlineName = $seg['AirlineName'];
$FlightNumber = $seg['SegFlightNumber'];
$FareClass = $seg['FareClass'];
$originAirportCode = $seg['originAirportCode'];
$originDepTime = $seg['originDepTime'];
$destinationAirportCode = $seg['destinationAirportCode'];
$destinationArrTime = $seg['destinationArrTime'];
$Duration = $seg['Duration'];
$GroundTime = $seg['GroundTime'];
$Mile = $seg['Mile'];
$StopOver = $seg['StopOver'];
$StopPoint = $seg['StopPoint'];
$StopPointArrivalTime = $seg['StopPointArrivalTime'];
$Craft = $seg['Craft'];
$Remark = $seg['Remark'];
$IsETicketEligible = $seg['IsETicketEligible'];
$NoOfSeatAvailable = !empty($seg['NoOfSeatAvailable']) ? $seg['NoOfSeatAvailable'] : 0;
$FlightStatus = $seg['FlightStatus'];
$Status = $seg['Status'];
// $arrSegments = array(
// "AirInvenAPISysId" => '',
// "TripIndicator" => $TripIndicator,
// "Baggage" => $strBaggage,
// "CabinBaggage" => $strCabinBaggage,
// "SegmentIndicator" => ($SegmentIndicator) ? $SegmentIndicator : 1,
// "Duration" => $Duration,
// "GroundTime" => $GroundTime,
// "Mile" => $Mile,
// "StopOver" => $StopOver,
// "StopPoint" => $StopPoint,
// "StopPointArrivalTime" => $StopPointArrivalTime,
// "Craft" => $Craft,
// "Remark" => $Remark,
// "IsETicketEligible" => $IsETicketEligible,
// "FlightStatus" => $FlightStatus,
// "Status" => $Status
// );
$FlyingMinutes = $FlyingMinutes + ((isset($seg['Duration']) ? $seg['Duration'] : 0) + (!empty($seg['GroundTime']) ? $seg['GroundTime'] : (isset($seg['AccumulatedDuration']) ? $seg['AccumulatedDuration'] : 0)));
}
$airlineSysId = $flightRounds['AirlineSysId'];
$FlyingMinutes = $FlyingMinutes;
if (count($result['Segments']) > 1) {
$SegmentsCount = count($result['Segments']);
$StopCount = $SegmentsCount - 1;
$IsDirect = '0';
} else {
$StopCount = '0';
$IsDirect = '1';
}
$strTraceId = $flightRounds['apiTraceId'];
$localFromDateTime = $flightRounds['LocalFromTime'];
$initialOriginDepTime = $flightRounds['FromUTCTime'];
$localToDateTime = $flightRounds['LocalToTime'];
$ToUTCTime = $flightRounds['ToUTCTime'];
$DayLightSavingDiff = isset($flightRounds['DayLightSavingDiff']) ? $flightRounds['DayLightSavingDiff'] : 0;
$intSourceCityId = $flightRounds['SourcePlaceSysId'];
$intDestinationCityId = $flightRounds['DestPlaceSysId'];
$strSourceAirportCode = $flightRounds['SourceAirportCode'];
$strDestinationAirportCode = $flightRounds['DestAirportCode'];
$AirportHaultMinutes = isset($flightRounds['AirportHaultMinutes']) ? $flightRounds['AirportHaultMinutes'] : 0;
$intMemberCount = $flightRounds['TotalFlightMembers'];
$JourneyType = $flightRounds['JourneyType'];
$TripType = $flightRounds['TripType'];
$IsInternational = $flightRounds['IsInternational'];
$IsFromAgency = 1;
$strFlightNumber = $flightRounds['FlightNumber'];
$ResultIndex = $flightRounds['ApiResultIndex'];
$IsLCC = $flightRounds['IsLCC'];
$IsRefundable = isset($flightRounds['IsRefundable']) ? $flightRounds['IsRefundable'] : 0;
$strFareClass = isset($flightRounds['FareClass']) ? $flightRounds['FareClass'] : 0;
$NoOfSeatAvailable = isset($flightRounds['NoOfSeatAvailable']) ? $flightRounds['NoOfSeatAvailable'] : 0;
if ($interNationalSearch == "1" && $route == "2") {
$AirInvenSysId = isset($AirInvenSysIdArrNew[$keys]) ? $AirInvenSysIdArrNew[$keys] : 0;
} else {
if ($IsTJFlightAPI == 1 && $IsSeriesFareData == 0) {
$ICSourceSysId = 7;
} elseif ($IsTJFlightAPI == 0 && $IsSeriesFareData == 0) {
$ICSourceSysId = 3;
} elseif ($IsTJFlightAPI == 0 && $IsSeriesFareData == 1) {
$ICSourceSysId = 8;
}
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $strFlightNumber;
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = $IsLCC;
$arrInsertFlightData['IsRefundable'] = !empty($IsRefundable) ? $IsRefundable : 0;
$arrInsertFlightData['apiTraceId'] = $strTraceId;
$arrInsertFlightData['AirlineSysId'] = $airlineSysId;
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId; //($IsSeriesFareData == 1)?8:7;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = str_replace('T', ' ', $initialOriginDepTime);
$arrInsertFlightData['LocalToTime'] = str_replace('T', ' ', $localToDateTime);
$arrInsertFlightData['ToUTCTime'] = str_replace('T', ' ', $ToUTCTime);
$arrInsertFlightData['IsDirect'] = $IsDirect;
$arrInsertFlightData['FareClass'] = $strFareClass;
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId;
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId;
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode;
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode;
$arrInsertFlightData['AirportHaultMinutes'] = $AirportHaultMinutes;
$arrInsertFlightData['StopCount'] = $StopCount;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = $NoOfSeatAvailable;
$arrInsertFlightData['TotalFlightMembers'] = $intMemberCount;
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG Discount
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = 'NA';//$ResultIndex;
$arrInsertFlightData['JourneyType'] = $JourneyType;
$arrInsertFlightData['TripType'] = $TripType;
$arrInsertFlightData['Rating'] = 0;
$arrInsertFlightData['FllightFeatureMask'] = 0;
$arrInsertFlightData['UpdatedByISSysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData['CreatedByISSysId'] = $this->intLoggedinAgencyId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = 1;
$arrInsertFlightData['IsActive'] = 1;
$arrInsertFlightData['IsMarkForDel'] = 0;
$arrInsertFlightData['IsInternational'] = ($IsInternational) ? $IsInternational : '0';
$arrInsertFlightData['IsNewMigration'] = ($IsNewMigration) ? $IsNewMigration : 0;
$intFlightLastInsertId = $this->_objFlight->addFlightDetails($arrInsertFlightData); //TB_IC_Trans_API_Air addFlightDetails
$AirInvenSysId = $AirInvenSysIdArr[] = $intFlightLastInsertId;
$arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
$this->_objFlight->addFlightFairRuleDetails($arrFairRules); //TB_IC_Trans_API_Air_Fare
$Sectors = [];
$segment_ssr = [];
try {
$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
if (!empty($Segments)) {
foreach ($Segments as $arrSegmentsRes) {
$originAirportCode = isset($arrSegmentsRes['originAirportCode']) ? $arrSegmentsRes['originAirportCode'] : '';
$destinationAirportCode = isset($arrSegmentsRes['destinationAirportCode']) ? $arrSegmentsRes['destinationAirportCode'] : '';
$Sectors[] = $originAirportCode . '-' . $destinationAirportCode;
$segment_ssr[] = $arrSegments = array(
"AirInvenAPISysId" => $intFlightLastInsertId,
"TripIndicator" => isset($arrSegmentsRes['isReturnSegment']) ? $arrSegmentsRes['isReturnSegment'] : '0',
"Baggage" => isset($arrSegmentsRes['CheckinBaggage']) ? $arrSegmentsRes['CheckinBaggage'] : '',
"CabinBaggage" => isset($arrSegmentsRes['CabinBaggage']) ? $arrSegmentsRes['CabinBaggage'] : '',
"SegmentIndicator" => isset($arrSegmentsRes['isReturnSegment']) ? $arrSegmentsRes['isReturnSegment'] : '0',
"OriginAirportCode" => isset($arrSegmentsRes['originAirportCode']) ? $arrSegmentsRes['originAirportCode'] : '',
"DestAirportCode" => isset($arrSegmentsRes['destinationAirportCode']) ? $arrSegmentsRes['destinationAirportCode'] : '',
"Duration" => isset($arrSegmentsRes['Duration']) ? $arrSegmentsRes['Duration'] : '0',
"GroundTime" => isset($arrSegmentsRes['GroundTime']) ? $arrSegmentsRes['GroundTime'] : '0',
"Mile" => '0',
"StopOver" => '0',
"StopPoint" => isset($arrSegmentsRes['LAYOVERCity']) ? $arrSegmentsRes['LAYOVERCity'] : '0',
"StopPointArrivalTime" => '0',
"Craft" => isset($arrSegmentsRes['Craft']) ? $arrSegmentsRes['Craft'] : '',
"Remark" => isset($arrSegmentsRes['Remark']) ? $arrSegmentsRes['Remark'] : '',
"IsETicketEligible" => isset($arrSegmentsRes['IsETicketEligible']) ? $arrSegmentsRes['IsETicketEligible'] : '0',
"FlightStatus" => isset($arrSegmentsRes['FlightStatus']) ? $arrSegmentsRes['FlightStatus'] : '',
"Status" => isset($arrSegmentsRes['Status']) ? $arrSegmentsRes['Status'] : '',
"segmentid" => isset($arrSegmentsRes['segmentid']) ? $arrSegmentsRes['segmentid'] : '',
"arrivingnextday" => isset($arrSegmentsRes['arrivingnextday']) ? $arrSegmentsRes['arrivingnextday'] : '',
"originDepTime" => isset($arrSegmentsRes['originDepTime']) ? $arrSegmentsRes['originDepTime'] : '',
"destinationArrTime" => isset($arrSegmentsRes['destinationArrTime']) ? $arrSegmentsRes['destinationArrTime'] : '',
"FlightNumber" => isset($arrSegmentsRes['SegFlightNumber']) ? $arrSegmentsRes['SegFlightNumber'] : '',
"AirlineCode" => isset($arrSegmentsRes['AirlineCode']) ? $arrSegmentsRes['AirlineCode'] : '',
"AirlineName" => isset($arrSegmentsRes['AirlineName']) ? $arrSegmentsRes['AirlineName'] : '',
"FareClass " => isset($arrSegmentsRes['FareClass']) ? $arrSegmentsRes['FareClass'] : '',
"cabinClass" => isset($arrSegmentsRes['cabinClass']) ? $arrSegmentsRes['cabinClass'] : '',
"IsMealIncludes" => isset($arrSegmentsRes['IsMealIncludes']) ? $arrSegmentsRes['IsMealIncludes'] : '',
"LAYOVERDuration" => isset($arrSegmentsRes['LAYOVERDuration']) ? $arrSegmentsRes['LAYOVERDuration'] : '',
"logo" => isset($arrSegmentsRes['filePath']) ? $arrSegmentsRes['filePath'] : '',
"DepTerminal" => isset($arrSegmentsRes['DepTerminal']) ? $arrSegmentsRes['DepTerminal'] : '',
"ArrTerminal" => isset($arrSegmentsRes['ArrTerminal']) ? $arrSegmentsRes['ArrTerminal'] : '',
);
// echo "<pre>";
// print_r($arrSegments);
// die;
$objFlight->addFlightSegmentsDetails($arrSegments);
}
}
//$objFlight->addFlightSegmentsDetails($arrSegments);
} catch (Exception $e) {
echo $e->getMessage();
die('addflightfairrules');
}
if (!empty($flightRounds['FairRules']['FareBreakdown'])) {
foreach ($flightRounds['FairRules']['FareBreakdown'] as $fareBreakdown) {
$Currency = $fareBreakdown['Currency'];
$PassengerType = $fareBreakdown['PassengerType'];
$PassengerCount = $fareBreakdown['PassengerCount'];
$BaseFare = $fareBreakdown['BaseFare'];
$Tax = isset($fareBreakdown['Tax']) ? $fareBreakdown['Tax'] : $fareBreakdown['TaxIN'];
$YQTax = isset($fareBreakdown['YQTax']) ? $fareBreakdown['YQTax'] : $fareBreakdown['YQ'];
$AdditionalTxnFeeOfrd = $fareBreakdown['AdditionalTxnFeeOfrd'];
$AdditionalTxnFeePub = $fareBreakdown['AdditionalTxnFeePub'];
$intCommisionEarnedForAgency = isset($fareBreakdown['IntCommission']) ? $fareBreakdown['IntCommission'] : 0; // New fields
$ExtraMarkup = isset($fareBreakdown['ExtraMarkup']) ? $fareBreakdown['ExtraMarkup'] : 0; // New fields
$ExtraMarkupOnGST = isset($fareBreakdown['ExtraMarkupOnGST']) ? $fareBreakdown['ExtraMarkupOnGST'] : 0; // New fields
$OtherCharges = isset($fareBreakdown['OtherCharges']) ? $fareBreakdown['OtherCharges'] : 0; // New fields
$FixedMarkUp = isset($fareBreakdown['FixedMarkUp']) ? ($fareBreakdown['FixedMarkUp'] + $ExtraMarkup) : 0; // New fields
$GSTOnMarkUp = isset($fareBreakdown['GSTOnMarkUp']) ? ($fareBreakdown['GSTOnMarkUp'] + $ExtraMarkupOnGST) : 0; // New fields
$ServiceFee = isset($fareBreakdown['ServiceFee']) ? $fareBreakdown['ServiceFee'] : 0; // New fields
$Discount = isset($fareBreakdown['CommisionPass']) ? $fareBreakdown['CommisionPass'] : 0; // New fields
$TDSEarn = isset($fareBreakdown['TDSEarn']) ? $fareBreakdown['TDSEarn'] : 0; // New fields
$YR = isset($fareBreakdown['YR']) ? $fareBreakdown['YR'] : 0; //Carrier Misc Fee
$MF = isset($fareBreakdown['MF']) ? $fareBreakdown['MF'] : 0; // Manahement fee
$MFT = isset($fareBreakdown['MFT']) ? $fareBreakdown['MFT'] : 0; // Manahement fee Tax
$AGST = isset($fareBreakdown['AGST']) ? $fareBreakdown['AGST'] : 0; // Airlines GST Component
$Tax = isset($fareBreakdown['Tax']) ? $fareBreakdown['Tax'] : 0; // Total Tax
$YQTax = isset($fareBreakdown['YQ']) ? $fareBreakdown['YQ'] : 0; //Fuel Surcharge
$OfferedFare = isset($fareBreakdown['OfferedFare']) ? $fareBreakdown['OfferedFare'] : 0; // New fields
$TotalFare = isset($fareBreakdown['TotalFare']) ? $fareBreakdown['TotalFare'] : 0; // New fields
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $AirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => $PassengerType,
"PassengerCount" => $PassengerCount,
"BaseFare" => $BaseFare,
"Tax" => !empty($Tax) ? $Tax : 0,
"YQTax" => !empty($YQTax) ? $YQTax : 0,
"AdditionalTxnFeeOfrd" => $AdditionalTxnFeeOfrd,
"AdditionalTxnFeePub" => $AdditionalTxnFeePub,
"CommissionEarned" => ($intCommisionEarnedForAgency),
"OtherCharges" => $OtherCharges,
"FixedMarkUp" => $FixedMarkUp,
"GSTOnMarkUp" => $GSTOnMarkUp,
"ServiceFee" => $ServiceFee,
"Discount" => $Discount,
"OfferedFare" => $OfferedFare,
"TotalFare" => $TotalFare,
"TDSEarn" => $TDSEarn,
"MF" => $MF,
"AGST" => $AGST,
"MFT" => $MFT,
"YR" => $YR,
);
$FareBreakdownid = $objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
}
$strGoingFlightFrom = $flightRounds['SourceAirportCode'];
$strGoingFlightTo = $flightRounds['DestAirportCode'];
$AirlineSysId = $flightRounds['AirlineSysId'];
$StopCount = $flightRounds['Stops'];
$AirlineName = $flightRounds['AirlineName'];
$FlightNumber = $flightRounds['FlightNumber'];
$PublishedFare = $flightRounds['PublishedFare'];
//$OfferedFare = $flightRounds['OfferedFare'];
//$intCommissionEarned = $flightRounds['CommissionEarned'];
$strArrivalTime = $flightRounds['LocalToTime'];
$strDepartureTime = $flightRounds['LocalFromTime'];
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intAdultsCT = $sessionFlightSearchParams['adults'];
$intChildsCT = $sessionFlightSearchParams['child'];
$intInfantsCT = $sessionFlightSearchParams['infant'];
//$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
if ($interNationalSearch) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$DiscountValue = ($flightRounds['FairRules']['DiscountValue']) ? $flightRounds['FairRules']['DiscountValue'] : 0;
$ExtraMarkup = ($flightRounds['FairRules']['ExtraMarkup']) ? $flightRounds['FairRules']['ExtraMarkup'] : 0;
$ExtraMarkupOnGST = ($flightRounds['FairRules']['ExtraMarkupOnGST']) ? $flightRounds['FairRules']['ExtraMarkupOnGST'] : 0;
$intPublishedFare = ($flightRounds['FairRules']['PublishedFare'] + $BagPriceSeg + $MealPriceSeg + $SeatPriceSeg);
//$intOfferedFare = ($flightRounds['FairRules']['OfferedFare'] + $BagPriceSeg + $MealPriceSeg + $SeatPriceSeg);
$intCommissionEarned = $flightRounds['FairRules']['CommEarned'];
$intPLBEarned = $flightRounds['FairRules']['PLBEarned'];
$intIncentiveEarned = $flightRounds['FairRules']['IncentiveEarned'];
$intGTXMarkUp = $flightRounds['FairRules']['intGTXMarkUp'];
$GTXMarkUpGST = $flightRounds['FairRules']['GTXMarkUpGST'];
$intAgencyFixMarkUp = $flightRounds['FairRules']['FixedMarkUp'];
$apiMarkup = ($flightRounds['FairRules']['apiMarkup']) ? $flightRounds['FairRules']['apiMarkup'] : 0;
$intTotalGST = ($flightRounds['FairRules']['intTotalGST']) ? $flightRounds['FairRules']['intTotalGST'] : 0;
$BaseAmount = 0;
$baggageByPax = [];
if ($flightRounds['FairRules']['FareBreakdown']) {
foreach ($flightRounds['FairRules']['FareBreakdown'] as $key => $value) {
$baggageByPax[$value['PassengerType']]['Baggage'] = $value['Baggage'];
$baggageByPax[$value['PassengerType']]['CabinBaggage'] = $value['CabinBaggage'];
//////////////////////////////////
$IntCommission_ = $value['IntCommission'];
$CommissionEarned_ = $value['CommissionEarned'];
$PBaseFare_ = $value['BaseFare'];
$MF = $value['MF']; //Management Fee
$YQ = $value['YQ']; //Fuel Surcharge
$AGST = $value['AGST']; //Airline GST Component
$MFT = $value['MFT']; //Management Fee Tax
$OT = $value['OT']; //Other Charges
$MU = $value['MU']; //Markup
$YR = $value['YR']; //Carrier Misc Fee
$otherCharge_ = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
$FixedMarkUp_ = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$intGTXMarkUp_ = $value['intGTXMarkUp'];
$GTXMarkUpGST_ = $value['GTXMarkUpGST'];
$intTotalGST_ = $value['intTotalGST'];
$apiMarkup_ = $value['apiMarkup'];
$CommEarned_ = $value['CommEarned'];
$customerDiscount_ = ($CommissionEarned_ - $IntCommission_);
$GrandTotalBaseFare = (($PBaseFare_ - $CommEarned_ + $otherCharge_ + $FixedMarkUp_ + $apiMarkup_ + $intGTXMarkUp_ + $GTXMarkUpGST_) - $customerDiscount_);
$BaseAmount += $GrandTotalBaseFare;
$AgentServiceTaxAmount += $intTotalGST_;
}
}
$TotalExtraCharge = ($ExtraMarkup + $ExtraMarkupOnGST);
$intOfferedFare = ($BaseAmount + $BagPriceSeg + $MealPriceSeg + $SeatPriceSeg);
$totalCost = ($intPublishedFare + $TotalExtraCharge - $DiscountValue);
$AgentServiceTaxAmount_ = ($intTotalGST + $ExtraMarkupOnGST);
$AgencyMarkUp_ = ($intAgencyFixMarkUp + $apiMarkup + $ExtraMarkup);
$AgencyMarkUp += ($intAgencyFixMarkUp + $apiMarkup + $ExtraMarkup);
$GTXMarkUp += ($GTXMarkUpGST);
$AgentCommisionEarned += ($intCommissionEarned);
$BaseAmount_trx += ($intOfferedFare);
$PublishedFare_trx += ($intPublishedFare);
$TotalDiscountValue += ($DiscountValue);
$arrPlanAir['SeqId'] = $intRounds;
$arrPlanAir['TPIntSysId'] = $TPIntSysId;
$arrPlanAir['SourceAirportCode'] = $strGoingFlightFrom;
$arrPlanAir['DestAirportCode'] = $strGoingFlightTo;
$arrPlanAir['LocalFromTime'] = $strArrivalTime;
$arrPlanAir['LocalToTime'] = $strDepartureTime;
$arrPlanAir['FromUTCTime'] = $strArrivalTime;
$arrPlanAir['ToUTCTime'] = $strDepartureTime;
$arrPlanAir['SupplierSysId'] = 3;
$arrPlanAir['IsActive'] = 1;
$arrPlanAir['IsMarkForDel'] = 0;
$arrPlanAir['FlightNumber'] = $FlightNumber;
$arrPlanAir['Cost'] = ($intOfferedFare);
$arrPlanAir['TotalCost'] = $totalCost; //($intPublishedFare + $ExtraMarkup + $ExtraMarkupOnGST); Discount
$arrPlanAir['XServiceTaxAmount'] = 0; //$intSTaxOnBasePrice;
$arrPlanAir['GTXServiceTaxAmount'] = $GTXMarkUpGST; //$intSTaxOnGTXMarkUp;
$arrPlanAir['AgentServiceTaxAmount'] = ($AgentServiceTaxAmount_ * $this->CurrencyRate); //$intTotalGST; //$intTotalGSTAgencyEarnings; ICSourceSysId
$arrPlanAir['AgentsCustomServiceTaxAmount'] = 0;
$arrPlanAir['MarkUp'] = 0;
$arrPlanAir['AgencyMarkUp'] = ($AgencyMarkUp_ * $this->CurrencyRate); //($intAgencyFixMarkUp + $apiMarkup); $this->CurrencyRate
$arrPlanAir['GTXMarkup'] = $intGTXMarkUp;
$arrPlanAir['GTXCommission'] = 0;
$arrPlanAir['AgencyCommission'] = ($intCommissionEarned * $this->CurrencyRate);
$arrPlanAir['ExtraMarkup'] = $ExtraMarkup;
$arrPlanAir['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$arrPlanAir['Discount'] = ($DiscountValue * $this->CurrencyRate);
$arrPlanAir['Taxes'] = 0;
$arrPlanAir['TDS'] = 0;
$arrPlanAir['AirlineSysId'] = $AirlineSysId;
$arrPlanAir['ICSourceSysId'] = $ICSourceSysId; //($IsSeriesFareData == 1)?8:7;
$arrPlanAir['InvnItemSysId'] = $AirInvenSysId;
$arrPlanAir['IsFromAPI'] = 1;
$arrPlanAir['StopCount'] = $StopCount;
$arrPlanAir['AdultPax'] = $adultCount;
$arrPlanAir['ChildPax'] = $childCount;
$arrPlanAir['InfentPax'] = $infantCount;
$arrPlanAir['TotalPax'] = $totalPassengers;
$arrPlanAir['TripType'] = $route;
$arrPlanAir['XRefBookingId'] = isset($flightRounds['bookingId']) ? $flightRounds['bookingId'] : '';
$arrPlanAir['IsSelectedOnPkg'] = 1;
$arrPlanAir['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPlanAir['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPlanAir['AgencySysId'] = $this->intLoggedinAgencyId;
$intTpAirId = $objFlight->insertTravelPlanIAir($arrPlanAir);
$intRounds++;
$arrIntTpAirId[] = $intTpAirId;
$TripCount = count($BookingData);
// if (!empty($TPSysId)) {
// $Memb = 0;
// if (!empty($ForCustomerSession)) {
// foreach ($ForCustomerSession as $key => $resultPax) {
// $BagPrice_c = 0;
// $MealPrice_c = 0;
// $SeatPrice_c = 0;
// $SelectedBag = [];
// $SelectedMeal = [];
// $SelectedSeat = [];
// if($SelectedBaggSessionNew && ($resultPax['paxType'] == 1 || $resultPax['paxType'] == 2)){
// foreach ($SelectedBaggSessionNew as $value) {
// if($value){
// foreach($value as $v){
// $Orgin = $v['Origin'];
// $Destination = $v['Destination'];
// //$sorcdes = isset($segment_ssr[$v['Segment_Id']])?$segment_ssr[$v['Segment_Id']]:'';
// $sorcdes = isset($segment_ssr[($v['segmentid']-1)])?$segment_ssr[($v['segmentid']-1)]:'';
// if ($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14) {
// $Orgin = $sorcdes['originAirportCode'];
// $Destination = $sorcdes['destinationAirportCode'];
// }
// if ($ICSourceSysId == 17) {
// $Orgin = $v['origin'];
// $Destination = $v['destination'];
// }
// if ($ICSourceSysId == 12) {
// $sorcdes = isset($segment_ssr[($v['segmentid'])])?$segment_ssr[($v['segmentid'])]:'';
// $Orgin = $sorcdes['originAirportCode'];
// $Destination = $sorcdes['destinationAirportCode'];
// $SelectedBag[$Orgin.'-'.$Destination][] = $v;
// }else{
// $SelectedBag[$Orgin.'-'.$Destination][] = $v;
// }
// }
// }
// if(isset($value[$key+1])){
// $BagPrice_c += $value[$key+1]['Price'];
// }
// }
// }
// if($SelectedMealSessionNew && ($resultPax['paxType'] == 1 || $resultPax['paxType'] == 2)){
// foreach ($SelectedMealSessionNew as $value) {
// if($value){
// foreach($value as $v){
// $Orgin = $v['Origin'];
// $Destination = $v['Destination'];
// $sorcdes = isset($segment_ssr[($v['segmentid']-1)])?$segment_ssr[($v['segmentid']-1)]:'';
// if ($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14) {
// $Orgin = $sorcdes['originAirportCode'];
// $Destination = $sorcdes['destinationAirportCode'];
// }
// if ($ICSourceSysId == 3) {
// $v['Description'] = $v['AirlineDescription'];
// }
// if ($ICSourceSysId == 17) {
// $Orgin = $v['origin'];
// $Destination = $v['destination'];
// }
// if ($ICSourceSysId == 12) {
// $sorcdes = isset($segment_ssr[($v['segmentid'])])?$segment_ssr[($v['segmentid'])]:'';
// $Orgin = $sorcdes['originAirportCode'];
// $Destination = $sorcdes['destinationAirportCode'];
// $SelectedMeal[$Orgin.'-'.$Destination][] = $v;
// }else{
// $SelectedMeal[$Orgin.'-'.$Destination][] = $v;
// }
// }
// }
// if(isset($value[$key+1])){
// $MealPrice_c += $value[$key+1]['Price'];
// }
// }
// }
// if($selectedSeatSession && ($resultPax['paxType'] == 1 || $resultPax['paxType'] == 2)){
// foreach ($selectedSeatSession as $segmentid=>$value) {
// if($value){
// foreach($value as $v){
// $Orgin = $v['Origin'];
// $Destination = $v['Destination'];
// //$sorcdes = isset($segment_ssr[$v['segmentid']])?$segment_ssr[$v['segmentid']]:'';
// $sorcdes = isset($segment_ssr[($segmentid-1)])?$segment_ssr[($segmentid-1)]:'';
// if ($ICSourceSysId == 11 || $ICSourceSysId == 13 || $ICSourceSysId == 14) {
// $Orgin = $sorcdes['originAirportCode'];
// $Destination = $sorcdes['destinationAirportCode'];
// }
// if ($ICSourceSysId == 17) {
// $Orgin = $v['origin'];
// $Destination = $v['destination'];
// }
// if ($ICSourceSysId == 12) {
// $SelectedSeat[] = $v;
// }else{
// $SelectedSeat[$Orgin.'-'.$Destination][] = $v;
// }
// }
// }
// if(isset($value[$key+1])){
// $SeatPrice_c += $value[$key+1]['amount'];
// }
// }
// }
// $CheckinBaggage = isset($baggageByPax[$resultPax['paxType']]['Baggage']) ? $baggageByPax[$resultPax['paxType']]['Baggage'] : '';
// $CabinBaggage = isset($baggageByPax[$resultPax['paxType']]['CabinBaggage']) ? $baggageByPax[$resultPax['paxType']]['CabinBaggage'] : '';
// $arrPaxData['TPSysId'] = $TPSysId;
// $arrPaxData['VersionId'] = $VersionId;
// $arrPaxData['CustomerSysId'] = $intCustomerSysId;
// $arrPaxData['MemberSysId'] = 0;
// $arrPaxData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
// $arrPaxData['IsApproved'] = '1';
// $arrPaxData['IsLeadPax'] = 0;
// $arrPaxData['IsActive'] = '1';
// $arrPaxData['IsMarkForDelete'] = '0';
// $arrPaxData['IsReturn'] = $ks;
// $arrPaxData['paxType'] = $resultPax['paxType'];
// $arrPaxData['FirstName'] = ($arrCustomer) ? $resultPax['FirstName'] : '';
// $arrPaxData['LastName'] = ($arrCustomer) ? $resultPax['LastName'] : '';
// $arrPaxData['Salutation'] = (($resultPax['Salutation']) && $key == 0) ? $resultPax['Salutation'] : $resultPax['Title'];
// $arrPaxData['Title'] = (($resultPax['Salutation']) && $key == 0) ? $resultPax['Salutation'] : $resultPax['Title'];
// $arrPaxData['GstNumber'] = $gstnnumber;
// $arrPaxData['GstCompany'] = $companyname;
// $arrPaxData['GstEmail'] = $gstemail;
// $arrPaxData['GstPhone'] = $gstphone;
// $arrPaxData['GstAddress'] = $gstaddress;
// $arrPaxData['GstState'] = $gststate;
// $arrPaxData['isgstapply'] = $isgstapply;
// $arrPaxData['Sectors'] = implode('@@', $Sectors);
// $arrPaxData['BagPrice'] = (!empty($BagPrice_c)) ? ($BagPrice_c / $TripCount) :0;
// $arrPaxData['MealPrice'] = (!empty($MealPrice_c)) ? ($MealPrice_c / $TripCount) :0;
// $arrPaxData['SeatPrice'] = (!empty($SeatPrice_c)) ? ($SeatPrice_c / $TripCount) :0;
// $arrPaxData['SelectedBag'] = (!empty($SelectedBag)) ? json_encode($SelectedBag) :'';
// $arrPaxData['SelectedMeal'] = (!empty($SelectedMeal)) ? json_encode($SelectedMeal) :'';
// $arrPaxData['SelectedSeat'] = (!empty($SelectedSeat))? json_encode($SelectedSeat) :'';
// $arrPaxData['CheckinBaggage'] = !empty($CheckinBaggage) ? $CheckinBaggage : '';
// $arrPaxData['CabinBaggage'] = !empty($CabinBaggage) ? $CabinBaggage : '';
// // echo "<pre>";print_r($arrPaxData);
// // echo "<pre>";print_r($SelectedBaggSessionNew);
// // die;
// if ($key == 0) {
// $arrPaxData['IsLeadPax'] = 1;
// $dfdfdfdf = $objFlight->insertTravelPlanPax($arrPaxData);
// } else {
// $Members = ($arrCustomerMembers[$kkk]) ? $arrCustomerMembers[$kkk] : '';
// $memberSysId = isset($arrCustomerMembersIds[$Memb]) ? $arrCustomerMembersIds[$Memb] : 0;
// if ($IsB2BCustomer == 1 || $IsB2BCustomer == '1') {
// $arrPaxData['IsLeadPax'] = 0;
// }
// $arrPaxData['paxType'] = ($Members) ? $Members['paxType'] : 0;
// $arrPaxData['MemberSysId'] = $memberSysId;
// $arrPaxData['VersionId'] = $VersionId;
// $dfdfdfdf = $objFlight->insertTravelPlanPax($arrPaxData);
// $Memb++;
// //$VersionId++;
// }
// //$objFlight->insertTravelPlanPax($arrPaxData);
// }
// }
// }
}
}
// die('ddddd');
if ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1) {
$walletPay = '0';
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 1) {
$walletPay = '1';
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 0) {
$walletPay = '1';
} elseif ($IsCheckWallet == 1 && $IsAllowFlightBooking == 0) {
$walletPay = '0';
}
$offlinePaymentModeData = $this->paymentMdl->getDetailsByUniqueId("TB_Master_PaymentMediaType", "Title", "CC");
$TrxPayMediaType = $offlinePaymentModeData['PaymentMediaType'];
$addData_Trx = array(
'MPSysId' => 1,
'InvoiceId' => '',
'TrxOrdDocId' => 1,
'TrxType' => "A",
'TrxOrdDocId' => $TrxPayMediaType,
'TrxDate' => date('Y-m-d H:i:s'),
'TrxPayMediaType' => $TrxPayMediaType,
'CrPartyAccSysId' => 1,
'DrPartyAccSysId' => "",
'CrPartyName' => '', //Agency Name
'DrPartyName' => $fname,
'CurrencyType' => 1,
'Markup' => 0,
"AgencyMarkUp" => $AgencyMarkUp,
"GTXMarkup" => $GTXMarkUp,
"TrxFee" => 0,
"Commission" => $AgentCommisionEarned,
"GTXCommission" => 0,
'TotalDiscount' => $TotalDiscountValue,
'Amount' => $BaseAmount_trx,
'PaidAmount' => $PublishedFare_trx,
'NetAmount' => $PublishedFare_trx,
'TrxStatus' => false,
'TBPoints' => 0,
'IsActive' => true
);
if ($walletPay == '0') {
$TrxSysId = $this->paymentMdl->insertTable("TB_Trx", $addData_Trx);
}
$addDataAgency_Customer_Trx = array(
"CustomerSysId" => $intCustomerSysId,
"AgencySysId" => $this->intLoggedinAgencyId,
"UserSysId" => $this->intLoggedinUserId,
"TrxSysId" => $TrxSysId,
'XRefTrxNo' => '',
'TPSysId' => $TPSysId,
'MPSysId' => 1,
'TrxDate' => date('Y-m-d H:i:s'),
'TrxUpdatedOn' => "",
'PaymentModeType' => 1,
'InvoiceId' => '',
'TrxOrdDocId' => 1,
'TrxType' => "A",
'TrxPayMediaRefNo' => "",
'CrPartyAccSysId' => 1,
"DrPartyAccSysId" => 0,
"CrPartyName" => "", //Agency Name
"DrPartyName" => $fname,
'TrxPayMediaType' => 1,
'CurrencyType' => 1,
'Amount' => $BaseAmount_trx,
'Markup' => 0,
"AgencyMarkUp" => $AgencyMarkUp,
"GTXMarkup" => $GTXMarkUp,
"TrxFee" => 0,
"Commission" => $AgentCommisionEarned,
'TotalDiscount' => $TotalDiscountValue,
'PaidAmount' => $PublishedFare_trx,
'NetAmount' => $PublishedFare_trx,
'TBPoints' => 0,
'TrxStatus' => 0,
'IsActive' => true
);
if ($walletPay == '0') {
$this->paymentMdl = new Payment_Model_Payment();
$dddd = $this->paymentMdl->insertTable("TB_Agency_Customer_Trx", $addDataAgency_Customer_Trx); /// by sabir
}
///echo "<pre>";print_r($dddd);echo "</pre>";
}
//Will Remove ...
$Customer = new Zend_Session_Namespace('Customer');
$Customer->Customer = $arrCustomer;
$Customer->CustomerMembers = $arrCustomerMembers;
$Customer->intCustomerSysId = $intCustomerSysId;
$Customer->intTPSysId = $TPSysId;
//Will Remove...
$arrData = array(
"intOutBoundId" => $intOutBoundId,
"intInBoundId" => $intInBoundId,
"intCustomerSysId" => $intCustomerSysId,
"intTPSysId" => $TPSysId,
"TrxSysId" => $TrxSysId,
"arrIntTpAirId" => $arrIntTpAirId,
"SelectedBaggSessionNew" => $SelectedBaggSessionNew,
"SelectedMealSessionNew" => $SelectedMealSessionNew,
"selectedSeatSession" => $selectedSeatSession,
"sessionFlightSearchParams" => $sessionFlightSearchParams,
"AirInvenSysIdArr" => $AirInvenSysIdArr,
"ForCustomerSession" => $ForCustomerSession,
"sessionLogin_user" => $_SESSION['sessionLogin_user'],
"IsTripjack" => true,
);
//echo "<pre>";print_r($arrData);exit;
$tempData = array(
'TPSysId' => $TPSysId,
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrData),
);
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
//$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'intCustomerSysId' => $intCustomerSysId, 'strUrlData' => $SearchTraceId);
echo json_encode($response);
exit;
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
public function savePassengerDetailsAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
// echo "HI";exit;
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$editLeadId = isset($sessionFlightSearchParams->params['editLeadId']) ? $sessionFlightSearchParams->params['editLeadId'] : '';
$route = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : '';
$interNationalSearch = isset($sessionFlightSearchParams->params['interNationalSearch']) ? $sessionFlightSearchParams->params['interNationalSearch'] : '';
$intCustomerSysId = trim($this->getRequest()->getParam('customerId'));
$intOutBoundId = !empty($this->getRequest()->getParam('intOutBoundId')) ? $this->getRequest()->getParam('intOutBoundId') : 0;
$intInBoundId = !empty($this->getRequest()->getParam('intInBoundId')) ? $this->getRequest()->getParam('intInBoundId') : 0;
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intOutBoundId . "','" . $intInBoundId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$getflightData = $objFlight->getFlightSearchListForProposal("'" . $intOutBoundId . "','" . $intInBoundId . "'");
$post = $this->getRequest()->getPost();
$intOfferedFare = isset($post['intPayableFromWallet']) ? $post['intPayableFromWallet'] : '0';
$totalCost = isset($post['intCostToCustomer']) ? $post['intCostToCustomer'] : '0';
//echo "<pre>";print_r($sessionFlightSearchParams->params);
// echo "<pre>";
// print_r($getflightData);
// print_r($arrSelectedFlightDetails);
// die;
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strSourceAirportCode = $sessionFlightSearchParams->params['from'];
$strDestinationAirportCode = $sessionFlightSearchParams->params['to'];
$adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
$childCount = isset($sessionFlightSearchParams->params['child']) ? $sessionFlightSearchParams->params['child'] : 0;
$infantCount = isset($sessionFlightSearchParams->params['infant']) ? $sessionFlightSearchParams->params['infant'] : 0;
$totalPassengers = $adultCount + $childCount + $infantCount;
// echo "<pre>";
// print_r($arrSelectedFlightDetails);
// print_r($getflightData);
// exit;
//encode travellers information in json to save created by Er Amit Kumar Dubey on 6 march 2017 at 11:21 AM
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'];
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$return_dates_string = $sessionFlightSearchParams->params['return_dates'];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($sessionFlightSearchParams->params['return_dates']) && !empty($sessionFlightSearchParams->params['return_dates'])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
$oneway_origin_text = isset($sessionFlightSearchParams->params['oneway_origin_text']) ? $sessionFlightSearchParams->params['oneway_origin_text'] : $sessionFlightSearchParams->params['sourceCityAirportCode'];
$oneway_destination_text = isset($sessionFlightSearchParams->params['oneway_destination_text']) ? $sessionFlightSearchParams->params['oneway_destination_text'] : $sessionFlightSearchParams->params['destinationCityAirportCode'];
$flight_class = $sessionFlightSearchParams->params['flight_class'];
$roomjson = array();
$roomjson[1]['Adult'] = $adultCount;
$roomjson[1]['Child'] = $childCount;
$roomjson[1]['bedtype'] = '';
$roomjson[1]['departuredate'] = $departure_dates_string;
$roomjson[1]['returndate'] = $return_dates_string;
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
$roomjson[1]['airclass'] = $flight_class;
for ($c = 1; $c <= $childCount; $c++) {
$childsage = $infantCount;
$roomjson[$c]['Adult'] = $adultCount;
$roomjson[$c]['Child'] = $childCount;
$roomjson[$c]['ChildAge_' . $c] = $childsage;
$roomjson[$c]['bedtype'] = '';
$roomjson[$c]['departuredate'] = $departure_dates_string;
$roomjson[$c]['returndate'] = $return_dates_string;
$roomjson[$c]['fromaircode'] = $oneway_origin_text;
$roomjson[$c]['toaircode'] = $oneway_destination_text;
$roomjson[$c]['airclass'] = $flight_class;
}
$RoomInfoJson = json_encode($roomjson);
//encode travellers information in json to save created by Er Amit Kumar Dubey on 6 march 2017 at 11:21 AM
if (empty($adultCount)) {
throw new Exception("Adult count not found.");
}
$arrCustomer = array();
$arrCustomerMembers = array();
for ($i = 1; $i <= $totalPassengers; $i++) {
$paxType = $post['paxType-' . $i];
$firstName = $post['passenger-firstname-' . $i];
$lastName = $post['passenger-lastname-' . $i];
$relation = $post['relation-' . $i];
$salutation = $post['passenger-salutation-' . $i];
$mobileNumber = $post['mobile_number'];
$email_id = $post['email_id'];
$passengerDob = $post['passenger-dob-' . $i];
$AdultpassengerpassengerDob = isset($post['Adultpassenger-dob-' . $i]) ? $post['Adultpassenger-dob-' . $i] : '';
$passengerPassportNo = isset($post['passenger-PassportNo-' . $i]) ? $post['passenger-PassportNo-' . $i] : '';
$passengerPassportExpiry = isset($post['passenger-PassportExpiry-' . $i]) ? $post['passenger-PassportExpiry-' . $i] : '';
if (!empty($passengerDob)) {
$passengerDob = explode("/", $passengerDob);
$passengerDob = $passengerDob[2] . "-" . $passengerDob[1] . "-" . $passengerDob[0];
}
if (!empty($AdultpassengerpassengerDob)) {
$AdultpassengerpassengerDob = explode("/", $AdultpassengerpassengerDob);
$AdultpassengerpassengerDob = $AdultpassengerpassengerDob[2] . "-" . $AdultpassengerpassengerDob[1] . "-" . $AdultpassengerpassengerDob[0];
}
if (!empty($passengerPassportExpiry)) {
$passengerPassportExpiry = explode("/", $passengerPassportExpiry);
$passengerPassportExpiry = $passengerPassportExpiry[2] . "-" . $passengerPassportExpiry[1] . "-" . $passengerPassportExpiry[0];
}
$passengerCity = $post['passenger-city-1'];
$passengerCountry = $post['passenger-country-1'];
$passengerAddress = $post['passenger-address-1'];
$AdultageCalculator = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->ageCalculator($departure_dates, $AdultpassengerpassengerDob);
if (empty($mobileNumber)) {
$response = array('succes' => false, 'msg' => 'Please enter mobile number.', 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
if (strlen($mobileNumber) != 10 && strlen($mobileNumber) != 11) {
$response = array('succes' => false, 'msg' => 'Please enter a valid mobile number.', 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
if (empty($email_id)) {
$response = array('succes' => false, 'msg' => 'Please enter Email ID.', 'index' => 'email_id');
echo json_encode($response);
exit;
}
if (!filter_var($email_id, FILTER_VALIDATE_EMAIL)) {
$msg = "Email address is not valid.";
$response = array('success' => false, 'msg' => $msg, 'index' => 'email_id');
echo json_encode($response);
exit;
}
if (empty($firstName)) {
$response = array('succes' => false, 'msg' => 'Please enter first name.', 'index' => 'passenger-firstname-' . $i);
echo json_encode($response);
exit;
}
if (empty($lastName)) {
$response = array('succes' => false, 'msg' => 'Please enter last name.', 'index' => 'passenger-lastname-' . $i);
echo json_encode($response);
exit;
}
if (empty($passengerDob)) {
$response = array('succes' => false, 'msg' => 'Please enter date of birth.', 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
// if($AdultageCalculator < 12) {
// $response = array('succes' => false, 'msg' => 'Please enter valid adult date of birth.','index' => 'passenger-dob-' . $i);
// echo json_encode($response);
// exit;
// }
//echo $ageCalculator;die;
if (isset($post['passenger-PassportNo-' . $i]) && empty($passengerPassportNo)) {
$response = array('succes' => false, 'msg' => 'Please enter passenger passport no.', 'index' => 'passenger-PassportNo-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-PassportExpiry-' . $i]) && empty($passengerPassportExpiry)) {
$response = array('succes' => false, 'msg' => 'Please enter passport expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
if (isset($post['passenger-PassportExpiry-' . $i]) && strtotime($departure_dates) > strtotime($passengerPassportExpiry)) {
$response = array('succes' => false, 'msg' => 'Please enter passport valid expiry date.', 'index' => 'passenger-PassportExpiry-' . $i);
echo json_encode($response);
exit;
}
if ($paxType == 1) {
$departureDates = $sessionFlightSearchParams->params['departure_dates'];
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDatesAD = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$AdultAge = date_diff(date_create($passengerDob), date_create($departureDatesAD))->y;
if ($AdultAge < 12) {
$response = array('succes' => false, 'msg' => "Adult age should be greater than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 2) {
$departureDates = $sessionFlightSearchParams->params['departure_dates'];
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDates = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$childAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($childAge < 2 || $childAge >= 12) {
$response = array('succes' => false, 'msg' => "Child age should be 2 years or less than 12 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (!empty($paxType) && $paxType == 3) {
$departureDates = $sessionFlightSearchParams->params['departure_dates'];
if (!empty($departureDates)) {
$arrDepartureDates = explode("/", $departureDates);
$departureDates = $arrDepartureDates[2] . "-" . $arrDepartureDates[1] . "-" . $arrDepartureDates[0];
$infantAge = date_diff(date_create($passengerDob), date_create($departureDates))->y;
if ($infantAge >= 2) {
$response = array('succes' => false, 'msg' => "Infant age should be less than 2 years. ", 'index' => 'passenger-dob-' . $i);
echo json_encode($response);
exit;
}
} else {
$response = array('succes' => false, 'msg' => "Departure date can not be empty.", 'index' => 'mobile_number');
echo json_encode($response);
exit;
}
}
if (empty($passengerCity)) {
$response = array('succes' => false, 'msg' => 'Please enter City.', 'index' => 'passenger-city-1');
echo json_encode($response);
exit;
}
if (empty($passengerAddress)) {
$response = array('succes' => false, 'msg' => 'Please enter Address.', 'index' => 'passenger-address-1');
echo json_encode($response);
exit;
}
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($this->intLoggedinAgencyId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
if ($i == 1 && $relation == 0) {
$arrCustomer = array(
'AgencySysId' => $this->intLoggedinAgencyId, 'CRMCustSysId' => 0, 'EmailId' => $email_id, 'Salutation' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'PassportNo' => $passengerPassportNo, 'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0',
'LeadSourceSysId' => $leadsource, 'LeadStageSysId' => $leadstage
);
if (empty($intCustomerSysId)) {
$objGest = new Travel_Model_Tbltbbcuser();
$arrCustomer['ContactNumber'] = $mobileNumber;
$intCustomerSysId = $objGest->createAgencyCustomer($arrCustomer);
} else {
$objGest = new Travel_Model_Tbltbbcuser();
$arrCustomer['ContactNumber'] = $mobileNumber;
$intCustomerSysId = $objGest->createAgencyCustomer($arrCustomer);
}
} else {
// $arrCustomerMembers[] = array('AgencySysId' => $this->intLoggedinAgencyId, 'EmailId' => $email_id, 'Title' => $salutation,'Relation' => $relation,
// 'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
// 'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
// 'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
// 'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
// 'RandomCode' => '', 'Gender' =>'', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
// 'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '','DOB' => $passengerDob,'PassportNo' => $passengerPassportNo,'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity,'paxType' => $paxType,
// 'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
// 'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
// 'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0');
if (!empty($passengerPassportNo)) {
$arrCustomerMembers[] = array(
'AgencySysId' => $this->intLoggedinAgencyId, 'EmailId' => $email_id, 'Title' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'PassportNo' => $passengerPassportNo, 'PassportExpiry' => $passengerPassportExpiry, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0'
);
} else {
$arrCustomerMembers[] = array(
'AgencySysId' => $this->intLoggedinAgencyId, 'EmailId' => $email_id, 'Title' => $salutation, 'Relation' => $relation,
'Logo' => '', 'IsfromSM' => '0', 'SMTypeId' => '0', 'SMId' => '', 'UserId' => '0', 'IsEmployee' => '0',
'Contacts' => $mobileNumber, 'ExitDate' => EMPTY_DATE, 'UserName' => '', 'FirstName' => $firstName, 'LastName' => $lastName,
'Designation' => '', 'Password' => '', 'RandStr' => '', 'PasswordExpiryDate' => EMPTY_DATE, 'IsPswExpire' => 0,
'OtherEmail' => '', 'SecondaryEmail' => '', 'LastLoginTime' => EMPTY_DATE, 'IsLogInNow' => 0, 'CreatedByUserSysId' => $this->intLoggedinUserId,
'RandomCode' => '', 'Gender' => '', 'UserNickName' => '', 'UserPicPath' => '', 'ContactNo1' => '', 'ContactNo2' => '',
'HomePhone' => '', 'SecondaryPhone' => '', 'UserDetails' => '', 'DOB' => $passengerDob, 'Address' => $passengerAddress, 'CitySysId' => $passengerCity, 'paxType' => $paxType,
'StateOrZoneSysId' => 0, 'CountrySysId' => $passengerCountry, 'PinCode' => '', 'SecondaryAddress' => '', 'Fax' => '',
'MacIp' => '', 'SpeakingLangSysId' => 0, 'Signature' => '', 'UpdateDate' => EMPTY_DATE,
'RegisterDate' => EMPTY_DATE, 'IsApproved' => 0, 'IsActive' => 1, 'IsMarkForDelete' => '0'
);
}
}
}
//echo "<pre>";print_r($arrCustomerMembers);exit;
if (empty($arrCustomer)) {
//throw new Exception('Customer Information not found.');
}
//$objFlight = new Travel_Model_TblFlight();
if (empty($intCustomerSysId)) {
throw new Exception('Customer Id not found.');
}
$arrCustomerMembersIds = array();
if (!empty($arrCustomerMembers)) {
$arrCustomerMembersIds = $objFlight->createAgencyCustomerMembers($arrCustomerMembers, $this->intLoggedinAgencyId, $intCustomerSysId);
// echo "<pre>";print_r($arrCustomerMembersIds);exit;
}
//$intCRMCustSysId = $objFlight->getCRMCustSysId($arrCustomer);
if (!empty($intCustomerSysId)) {
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
// Travel Plan Data....
if (empty($editLeadId)) {
$PlanBookingId = "Q/" . date('y');
$arrTravelPlan['PlanBookingId'] = $PlanBookingId;
$arrTravelPlan['Price'] = $intOfferedFare;
$arrTravelPlan['TotalCost'] = $totalCost;
$arrTravelPlan['NetPrice'] = $totalCost;
$arrTravelPlan['AgencySysId'] = $this->intLoggedinAgencyId;
$arrTravelPlan['AgentSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['CreatorSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['PlanType'] = '1'; // For Flight
$arrTravelPlan['SupplierSysId'] = 3;
$arrTravelPlan['StatusType'] = 2;
$arrTravelPlan['InventoryType'] = 1;
$arrTravelPlan['CurrencyType'] = $arrSelectedFlightDetails[0]['CurrencyType'];
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['SourcePlaceSysId'] = $getflightData[0]['SourcePlaceSysId'];
$arrTravelPlan['DestinationPlacesSysId'] = $getflightData[0]['DestPlaceSysId'];
$arrTravelPlan['SourcePlaces'] = $getflightData[0]['SourcePlaceName'];
$arrTravelPlan['DestinationPlaces'] = $getflightData[0]['DestPlaceName'];
$arrTravelPlan['Cities'] = $getflightData[0]['SourcePlaceName'] . "-" . $getflightData[0]['DestPlaceName'];
$arrTravelPlan['IsHotelFromApi'] = 1;
$arrTravelPlan['CustomerSysId'] = $intCustomerSysId;
$arrTravelPlan['StartDate'] = $departure_dates;
$arrTravelPlan['ValidTill'] = $return_dates;
$arrTravelPlan['CreateDate'] = $currentDate;
$arrTravelPlan['UpdateDate'] = $currentDate;
$arrTravelPlan['ApproveDate'] = $currentDate;
$arrTravelPlan['IsMarkForDel'] = 0;
$arrTravelPlan['IsActive'] = 1;
$arrTravelPlan['IsAprooved'] = 1;
$TPSysId = $objFlight->insertTravelPlan($arrTravelPlan);
} else {
$TPSysId = $editLeadId;
}
$PlanBookingId = "Q/" . date('y');
$arrTravelPlan['PlanBookingId'] = $PlanBookingId;
$arrTravelPlan['MasterTPSysId'] = $TPSysId;
$arrTravelPlan['Price'] = $intOfferedFare;
$arrTravelPlan['TotalCost'] = $totalCost;
$arrTravelPlan['NetPrice'] = $totalCost;
$arrTravelPlan['VersionId'] = 1;
$arrTravelPlan['AgencySysId'] = $this->intLoggedinAgencyId;
$arrTravelPlan['AgentSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['CreatorSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['PlanType'] = '1'; // For Flight
$arrTravelPlan['SupplierSysId'] = 3;
$arrTravelPlan['StatusType'] = 4;
$arrTravelPlan['InventoryType'] = 1;
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['CustomerSysId'] = $intCustomerSysId;
$arrTravelPlan['CurrencyType'] = $arrSelectedFlightDetails[0]['CurrencyType'];
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['SourcePlaceSysId'] = $getflightData[0]['SourcePlaceSysId'];
$arrTravelPlan['DestinationPlacesSysId'] = $getflightData[0]['DestPlaceSysId'];
$arrTravelPlan['SourcePlaces'] = $getflightData[0]['SourcePlaceName'];
$arrTravelPlan['DestinationPlaces'] = $getflightData[0]['DestPlaceName'];
$arrTravelPlan['Cities'] = $getflightData[0]['SourcePlaceName'] . "-" . $getflightData[0]['DestPlaceName'];
$arrTravelPlan['IsHotelFromApi'] = 1;
//$arrTravelPlan['TemplatePckSysId'] = '';
$arrTravelPlan['ProposalEmailTo'] = !empty($email_id) ? trim($email_id) : 0;
$arrTravelPlan['StartDate'] = $departure_dates;
$arrTravelPlan['ValidTill'] = $return_dates;
$arrTravelPlan['CreateDate'] = $currentDate;
$arrTravelPlan['UpdateDate'] = $currentDate;
$arrTravelPlan['ApproveDate'] = $currentDate;
$arrTravelPlan['IsMarkForDel'] = 0;
$arrTravelPlan['IsActive'] = 1;
$arrTravelPlan['IsAprooved'] = 1;
//echo "<pre>";print_r($arrTravelPlan);
$TPSysId = $objFlight->insertTravelPlan($arrTravelPlan);
$arrPaxData = array();
foreach ($arrSelectedFlightDetails as $ks => $flightRounds) {
if (!empty($TPSysId)) {
if (!empty($arrCustomer)) {
$arrPaxData['TPSysId'] = $TPSysId;
$arrPaxData['VersionId'] = '1';
$arrPaxData['CustomerSysId'] = $intCustomerSysId;
$arrPaxData['MemberSysId'] = 0;
$arrPaxData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPaxData['IsApproved'] = '1';
$arrPaxData['IsActive'] = '1';
$arrPaxData['IsMarkForDelete'] = '0';
$arrPaxData['IsReturn'] = $ks;
$objFlight->insertTravelPlanPax($arrPaxData);
}
if (!empty($arrCustomerMembersIds)) {
$VersionId = 2;
foreach ($arrCustomerMembersIds as $memberSysId) {
$arrPaxData['TPSysId'] = $TPSysId;
$arrPaxData['VersionId'] = $VersionId;
$arrPaxData['CustomerSysId'] = $intCustomerSysId;
$arrPaxData['MemberSysId'] = $memberSysId;
$arrPaxData['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPaxData['IsApproved'] = '1';
$arrPaxData['IsActive'] = '1';
$arrPaxData['IsMarkForDelete'] = '0';
$arrPaxData['IsReturn'] = $ks;
$objFlight->insertTravelPlanPax($arrPaxData);
$VersionId++;
}
}
}
}
// Travel Itenary Data....
$arrPlanItenary['TPSysId'] = $TPSysId;
$arrPlanItenary['Sequence'] = 1;
$arrPlanItenary['AgencySysId'] = $this->intLoggedinAgencyId;
$arrPlanItenary['StartDate'] = $currentDate;
$arrPlanItenary['EndDate'] = $currentDate;
$arrPlanItenary['CreateDate'] = $currentDate;
$arrPlanItenary['UpdateDate'] = $currentDate;
$arrPlanItenary['IsActive'] = 1;
$TPIntSysId = $objFlight->insertTravelPlanItenary($arrPlanItenary);
// Travel Plan Air Data....
if (!empty($arrSelectedFlightDetails)) {
$intRounds = 0;
$arrIntTpAirId = array();
foreach ($arrSelectedFlightDetails as $flightRounds) {
//if($intRounds >0){
// $strGoingFlightFrom = $flightRounds['DestAirportCode'];
// $strGoingFlightTo = $flightRounds['SourceAirportCode'];
//}else{
$strGoingFlightFrom = $flightRounds['SourceAirportCode'];
$strGoingFlightTo = $flightRounds['DestAirportCode'];
//}
$AirInvenSysId = $flightRounds['AirInvenSysId'];
$AirlineSysId = $flightRounds['AirlineSysId'];
$StopCount = $flightRounds['StopCount'];
$AirlineName = $flightRounds['AirlineName'];
$FlightNumber = $flightRounds['FlightNumber'];
$PublishedFare = $flightRounds['PublishedFare'];
//$OfferedFare = $flightRounds['OfferedFare'];
//$intCommissionEarned = $flightRounds['CommissionEarned'];
$strArrivalTime = $flightRounds['ArrivalTime'];
$strDepartureTime = $flightRounds['DepartureTime'];
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$intAdultsCT = $sessionFlightSearchParams->params['adults'];
$intChildsCT = $sessionFlightSearchParams->params['child'];
$intInfantsCT = $sessionFlightSearchParams->params['infant'];
//$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
if ($interNationalSearch) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$intPublishedFare = $flightRounds['PublishedFare'];
$intOfferedFare = $flightRounds['OfferedFare'];
$intCommissionEarned = $flightRounds['CommissionEarned'];
$intPLBEarned = $flightRounds['PLBEarned'];
$intIncentiveEarned = $flightRounds['IncentiveEarned'];
$arrAllCommissions = array(
'intCommissionEarned' => $intCommissionEarned,
'intPLBEarned' => $intPLBEarned,
'intIncentiveEarned' => $intIncentiveEarned
);
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $intOfferedFare, $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps);echo "</pre>";
$intOfferedFare = $arrPriceAndMarkUps['intOfferedFare'];
if ($interNationalSearch) {
$intGTXMarkUp = (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUp = ($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnGTXMarkUp = ($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intAgencyFixMarkUp = ($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUp = ($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
}
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency = $arrPriceAndMarkUps['intTotalEarningsForAgency'];
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
$arrSTaxOnBaseAmount = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($intOfferedFare, "F", "");
$intSTaxOnBasePrice = !empty($arrSTaxOnBaseAmount['serviceTaxAmount']) ? $arrSTaxOnBaseAmount['serviceTaxAmount'] : 0;
$arrSTaxOnGTXMarkUp = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($intGTXMarkUp, "F", "");
$intSTaxOnGTXMarkUp = !empty($arrSTaxOnGTXMarkUp['serviceTaxAmount']) ? $arrSTaxOnGTXMarkUp['serviceTaxAmount'] : 0;
$arrSTaxOnAgencyMarkUp = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($intAgencyFixMarkUp, "F", "");
$intSTaxOnAgencyMarkUp = !empty($arrSTaxOnAgencyMarkUp['serviceTaxAmount']) ? $arrSTaxOnAgencyMarkUp['serviceTaxAmount'] : 0;
// echo $intGTXMarkUp.'<br>';
// echo $intSTaxOnGTXMarkUp.'<br>';
// echo $intAgencyFixMarkUp.'<br>';
// echo $intSTaxOnAgencyFixMarkUp.'<br>';
$intTotalCost = $intOfferedFare + $intGTXMarkUp + $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency + $intTotalGSTAgencyEarnings;
//$intTotalCost = $TotalPublishedFare + $intGTXMarkUp +$intAgencyFixMarkUp+$intCommisionEarnedForAgency+$intSTaxOnBasePrice+$intSTaxOnGTXMarkUp+$intSTaxOnAgencyMarkUp;
//echo "<pre>";print_r($arrPriceAndMarkUps);exit;
$arrPlanAir['TPIntSysId'] = $TPIntSysId;
$arrPlanAir['SourceAirportCode'] = $strGoingFlightFrom;
$arrPlanAir['DestAirportCode'] = $strGoingFlightTo;
$arrPlanAir['LocalFromTime'] = $strArrivalTime;
$arrPlanAir['LocalToTime'] = $strDepartureTime;
$arrPlanAir['FromUTCTime'] = $strArrivalTime;
$arrPlanAir['ToUTCTime'] = $strDepartureTime;
$arrPlanAir['SupplierSysId'] = 3;
$arrPlanAir['IsActive'] = 1;
$arrPlanAir['IsMarkForDel'] = 0;
$arrPlanAir['FlightNumber'] = $FlightNumber;
$arrPlanAir['Cost'] = $intOfferedFare;
$arrPlanAir['TotalCost'] = $intTotalCost;
$arrPlanAir['XServiceTaxAmount'] = $intSTaxOnBasePrice;
$arrPlanAir['GTXServiceTaxAmount'] = $intSTaxOnGTXMarkUp;
$arrPlanAir['AgentServiceTaxAmount'] = $intTotalGSTAgencyEarnings;
$arrPlanAir['AgentsCustomServiceTaxAmount'] = 0;
$arrPlanAir['MarkUp'] = 0;
$arrPlanAir['AgencyMarkUp'] = $intAgencyFixMarkUp;
$arrPlanAir['GTXMarkup'] = $intGTXMarkUp;
$arrPlanAir['GTXCommission'] = 0;
$arrPlanAir['AgencyCommission'] = $intTotalEarningsForAgency;
$arrPlanAir['Taxes'] = 0;
$arrPlanAir['TDS'] = 0;
$arrPlanAir['AirlineSysId'] = $AirlineSysId;
$arrPlanAir['ICSourceSysId'] = 3;
$arrPlanAir['InvnItemSysId'] = $AirInvenSysId;
$arrPlanAir['IsFromAPI'] = 1;
$arrPlanAir['StopCount'] = $StopCount;
$arrPlanAir['AdultPax'] = $adultCount;
$arrPlanAir['ChildPax'] = $childCount;
$arrPlanAir['InfentPax'] = $infantCount;
$arrPlanAir['TotalPax'] = $totalPassengers;
$arrPlanAir['TripType'] = $route;
$arrPlanAir['IsSelectedOnPkg'] = 1;
$arrPlanAir['CreateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPlanAir['UpdateDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$arrPlanAir['AgencySysId'] = $this->intLoggedinAgencyId;
//echo "<pre>";print_r($arrPlanAir);exit;
$intTpAirId = $objFlight->insertTravelPlanIAir($arrPlanAir);
$intRounds++;
$arrIntTpAirId[] = $intTpAirId;
}
}
}
//Will Remove ...
$Customer = new Zend_Session_Namespace('Customer');
$Customer->Customer = $arrCustomer;
$Customer->CustomerMembers = $arrCustomerMembers;
$Customer->intCustomerSysId = $intCustomerSysId;
$Customer->intTPSysId = $TPSysId;
//Will Remove...
$arrData = array(
"intOutBoundId" => $intOutBoundId,
"intInBoundId" => $intInBoundId,
"intCustomerSysId" => $intCustomerSysId,
"intTPSysId" => $TPSysId,
"arrIntTpAirId" => $arrIntTpAirId
);
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
$response = array('success' => true, 'intCustomerSysId' => $intCustomerSysId, 'strUrlData' => $strUrlData);
echo json_encode($response);
exit;
}
}
public function reviewAction() {
$this->view->intLoggedinUserFirstName = $this->intLoggedinUserFirstName;
$this->view->intLoggedinUserEmailId = $this->intLoggedinUserEmailId;
$this->view->intLoggedinUserContactNo = $this->intLoggedinUserContactNo;
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$objFlight = new Travel_Model_TblFlight();
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$getAgentDetailById = $crmcustomerObj->getAgentDetailById($this->intLoggedinUserId);
$this->view->IsAllowFlightBooking = isset($getAgentDetailById[0]['IsAllowFlightBooking']) ? $getAgentDetailById[0]['IsAllowFlightBooking'] : 0;
$this->view->IsCheckWallet = isset($getAgencyDetail['IsCheckWallet']) ? $getAgencyDetail['IsCheckWallet'] : 0;
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
//$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$intGoingFlightId = !empty($this->view->intOutBoundId = $arrUrlData['intOutBoundId']) ? $this->view->intOutBoundId = $arrUrlData['intOutBoundId'] : 0;
$intReturnFlightId = !empty($this->view->intInBoundId = $arrUrlData['intInBoundId']) ? $this->view->intOutBoundId = $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = !empty($this->view->intInBoundId = $arrUrlData['intCustomerSysId']) ? $this->view->intOutBoundId = $arrUrlData['intCustomerSysId'] : 0;
$intTPSysId = !empty($this->view->intInBoundId = $arrUrlData['intTPSysId']) ? $this->view->intOutBoundId = $arrUrlData['intTPSysId'] : 0;
$TPSysId = !empty($this->view->TPSysId = $arrUrlData['intTPSysId']) ? $this->view->TPSysId = $arrUrlData['intTPSysId'] : 0;
$SelectedBaggSessionNew = !empty($this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew']) ? $this->view->SelectedBaggSessionNew = $arrUrlData['SelectedBaggSessionNew'] : 0;
$SelectedMealSessionNew = !empty($this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew']) ? $this->view->SelectedMealSessionNew = $arrUrlData['SelectedMealSessionNew'] : 0;
$selectedSeatSession = !empty($this->view->selectedSeatSession = $arrUrlData['selectedSeatSession']) ? $this->view->selectedSeatSession = $arrUrlData['selectedSeatSession'] : 0;
$this->view->FlightBookingData = $BookingData = $intGoingFlightId;
$this->view->CurrencyRate = $this->CurrencyRate;
$this->view->CurrencyTitle = $this->CurrencyTitle;
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$AgencySysId = isset($customerDetails['AgencySysId']) ? $customerDetails['AgencySysId'] : 0;
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$IsEnabledWallet = isset($customerDetails['IsEnabledWallet']) ? $customerDetails['IsEnabledWallet'] : 0;
$CustomerSysId = isset($customerDetails['CustomerSysId']) ? $customerDetails['CustomerSysId'] : 0;
$this->view->IsB2BCustomer = $IsB2BCustomer;
$this->view->IsEnabledWallet = $IsEnabledWallet;
$wallet = Zend_Controller_Action_HelperBroker::getStaticHelper('Dashboard')->getWalletPrice($this->intLoggedinAgencyId);
$this->view->walletBalanceAmount = '0.00'; //$wallet[0]['BalanceAmount'];
$model = new Gtxwebservices_Model_Webservices();
if ($IsB2BCustomer == 1) {
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$B2BAgencySysIdKey = $getAgencyDetail['SecurityKey'];
$B2CAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$apiDataIV = array(
"B2BAgencySysIdKey" => $B2BAgencySysIdKey,
"B2CAgencySysIdKey" => $B2CAgencySysIdKey,
);
$result = json_decode($model->GetB2Bbalance($apiDataIV), true);
$this->view->walletBalanceAmount = $result['creditBalance'];
} elseif ($IsEnabledWallet == 1) {
$apiDataIV = array(
"CustomerSysId" => $CustomerSysId,
);
$result = json_decode($model->GetB2Cbalance($apiDataIV, $this->agencyDetails['SecurityKey']), true);
$this->view->walletBalanceAmount = (isset($result['WalletBalance'][0]['BalanceAmount']) && !empty($result['WalletBalance'][0]['BalanceAmount'])) ? $result['WalletBalance'][0]['BalanceAmount'] : 0;
// echo "<pre>";print_r($result);
// echo "<pre>";print_r($apiDataIV);
// die;
}
$arrFlightFare = array();
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$this->view->intFlightRoute = $intFlightRoute = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
$this->view->route = $route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$this->view->interNationalSearch = $interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$intTatalPaxCTForMarkUp = $adultCount + $childCount + $infantCount;
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
//echo "<pre>";print_r($getAgencyDetail);echo "</pre>";
$arrPaxCount = array(
'intAdultsCount' => $adultCount,
'intChildCount' => $childCount,
'intInfantCount' => $infantCount
);
$this->view->arrPaxCount = $arrPaxCount;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if (isset($intCustomerSysId) && !empty($intCustomerSysId) && $intCustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetsils = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$this->view->customerDetsils = $customerDetsils;
}
}
//echo "<pre>";print_r($arrTrevllerDetails);echo "</pre>";die;
// For Flight Header , Sale Summary Tab Customers Details Ends...
$this->view->Error = $strError = trim($this->getRequest()->getParam('error_Message'));
$fullBaseUrl = $this->view->baseUrl();
$this->view->strPayWithWalletUrl = $fullBaseUrl . "/payment/wallet-pay";
$this->view->strRechargeNowUrl = $fullBaseUrl . "/payment/payment-options";
$this->view->strSearchPageUrl = $fullBaseUrl . "/flight/search-result";
$this->view->strReturnURL = $fullBaseUrl . "/flight/book-flight/data/" . $strUrlData;
$this->view->strErrorURL = $fullBaseUrl . "/flight/review/data/" . $strUrlData;
$this->view->strPayWithPaymentGatewayUrl = Catabatic_Helper::getSiteUrl() . "payment/payment-options/customer-pay";
$this->view->strReturnURLCustomerPayment = $fullBaseUrl . "/flight/check-flight-payment/data/" . $strUrlData;
$this->view->intPlanType = "1";
$this->view->strTrxType = "A";
$Customer = new Zend_Session_Namespace('Customer');
$this->view->intTpSysId = $intTpSysId = $Customer->intTPSysId;
$this->view->intCustomerSysId = $intCustomerSysId = $Customer->intCustomerSysId;
$sessionFareFinal = new Zend_Session_Namespace('sessionFareFinal');
if (!empty($sessionFlightInventoryBookingParams->intAirInvenSysId)) {
$TotalPublishedFare = $sessionFlightInventoryBookingParams->netAmt;
} else {
$TotalPublishedFare = $sessionFareFinal->TotalPublishedFare;
}
$sessionFlightPriceAndMarkupsDetails = new Zend_Session_Namespace('sessionFlightPriceAndMarkupsDetails');
//echo "<pre>";print_r($sessionFlightPriceAndMarkupsDetails->params);
//echo "<pre>";print_r($arrFlightFare);echo "</pre>";
$TotalBaseFare = 0;
$intGTXMarkUp = 0;
$intAgencyMarkUp = 0;
$intTDSOnAgencyMarkUp = 0;
$TotalPublishedFare = 0;
$intChargeFromWallet = 0;
$intCommisionEarnedForAgency = 0;
$intPLBEarnedForAgency = 0;
$intIncentiveEarnedForAgency = 0;
$intTotalEarningsForAgency = 0;
$intTotalGSTAgencyEarnings = 0;
$intAgencyFixMarkUp = 0;
$CostToAgent = 0;
//echo '<pre>';print_r($CostToAgent);echo '</pre>';
//echo $intChargeFromWallet.'=='.$intCostToCustomer.'='.$intTotalGSTAgencyEarnings;
$this->view->intTotalPublishedFare = $TotalPublishedFare;
$this->view->intTotalAmount = $TotalPublishedFare;
$this->view->intTax = $intTDSOnAgencyMarkUp;
$this->view->intAgentMarkUpAmount = $intAgencyMarkUp;
//$this->view->intGrandPayableAmount = $intGrandPayableAmount = $TotalPublishedFare;
$this->view->intGrandPayableAmount = $intCostToCustomer;
$this->view->intChargeFromWallet = ($intChargeFromWallet);
//$this->view->intChargeFromWallet = ($intChargeFromWallet - $intTotalGSTAgencyEarnings);
$arrPriceAndMarkups = array(
"intAgentMarkUpAmount" => 0,
"intAgencyMarkUpAmount" => $intTotalEarningsForAgency,
"intGTXMarkUpAmount" => $intGTXMarkUp,
"intTotalAmount" => ($CostToAgent - $intGTXMarkUp),
"intTax" => 0,
"GTXServiceTaxAmount" => 0,
"AgentServiceTaxAmount" => $intTotalGSTAgencyEarnings,
"AgentsCustomServiceTaxAmount" => "0",
"Pax" => $intTatalPaxCTForMarkUp,
"SupplierSourceStr" => "API",
"MarketPlaceId" => "1",
"TotalDiscount" => "0",
"CurrencyType" => "1"
);
$PublishedFare = 0;
$GrandTotalBaseFare = 0;
$intCostToCustomer = 0;
$TotalTaxsandFees = 0;
$Total_AGST = 0;
$Total_MF = 0;
$Total_YQ = 0;
$Total_MFT = 0;
$Total_OT = 0;
$Total_MU = 0;
$Total_YR = 0;
$Total_Offered = 0;
$Total_CommiErn = 0;
$Total_Profit = 0;
$Total_TaxIN = 0;
$Total_FixedMarkUp = 0;
$Total_GSTOnMarkUp = 0;
$intNetPublishedFare = 0;
$AdditionalTxnFeePub = 0;
$TotalExtraMarkup = 0;
$TotalExtraMarkupOnGST = 0;
$showintax = isset($FlightBookingData[0]['FairRules']['showintax']) ? $FlightBookingData[0]['FairRules']['showintax'] : 0;
$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
if ($BookingData) {
foreach ($BookingData as $amount) {
$PublishedFare += $amount['FairRules']['OfferedFare'];
$agencyMarkUp += $amount['FairRules']['FixedMarkUp'];
$gtxMarkup += $amount['FairRules']['intGTXMarkUp'];
$offerFare += $amount['FairRules']['OfferedFare'];
$gtxMarkupGST += $amount['FairRules']['GTXMarkUpGST'];
$agencyMarkUpGST += $amount['FairRules']['GSTOnMarkUp'];
if ($amount['FairRules']['FareBreakdown']) {
foreach ($amount['FairRules']['FareBreakdown'] as $key => $value) {
$PBaseFare = $value['BaseFare'];
$TaxIN = $value['TaxIN'];
$IntCommission = $value['IntCommission'];
$CommEarned = $value['CommEarned'];
$CommissionEarned = $value['CommissionEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$TotalExtraMarkup += isset($value['ExtraMarkup']) ? $value['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST += isset($value['ExtraMarkupOnGST']) ? $value['ExtraMarkupOnGST'] : 0;
$intGTXMarkUp = $value['intGTXMarkUp'];
$GTXMarkUpGST = $value['GTXMarkUpGST'];
$intTotalGST = $value['intTotalGST'];
$apiTaxOnMarkup = $value['apiTaxOnMarkup'];
$apiMarkup = $value['apiMarkup'];
$DiscountValue_ = isset($value['DiscountValue']) ? $value['DiscountValue'] : 0;
$CommisionPass = isset($value['CommisionPass']) ? $value['CommisionPass'] : 0;
$OtherCharges_ = isset($value['OtherCharges']) ? $value['OtherCharges'] : 0;
// echo '<pre>';
// print_r($value); ICSourceSysId
// echo '</pre>';
$TDS = $value['TDS']; //Management Fee
$MF = $value['MF']; //Management Fee
$YQ = $value['YQ']; //Fuel Surcharge
$AGST = $value['AGST']; //Airline GST Component
$MFT = $value['MFT']; //Management Fee Tax
$OT = $value['OT']; //Other Charges
$MU = $value['MU']; //Markup
$YR = $value['YR']; //Carrier Misc Fee
$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
if ($ICSourceSysId == 3) {
$otherCharge = ($AGST + $MFT + $MF + $OT + $YR + $OtherCharges_ );
}
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$paxPublishedFare = ($PBaseFare);
$PassengerType = $value['PassengerType'];
$PassengerCount = $value['PassengerCount'];
$BaseFare = ($value['BaseFare'] / $PassengerCount);
$TaxesFees = ($MF + $YQ + $AGST + $MFT + $OT + $MU + $YR + $FixedMarkUp + $GSTOnMarkUp);
$PublishedFare = ($value['BaseFareCal'] - $TaxIN - $FixedMarkUp - $GSTOnMarkUp);
$Total_CommiErn += ($CommEarned);
$Total_Profit += ($IntCommission);
$TotalBaseFare += $PublishedFare;
if ($ICSourceSysId == 3) {
$GrandTotalBaseFare += ((($PBaseFare + $otherCharge + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST - $CommisionPass)) - $DiscountValue_);
$intCostToCustomer += ((($PBaseFare + $otherCharge + $TDS + $FixedMarkUp + $apiMarkup + $apiTaxOnMarkup + $GSTOnMarkUp + $intGTXMarkUp + $GTXMarkUpGST - $CommisionPass)) - $DiscountValue_);
} else {
$GrandTotalBaseFare += ((($PBaseFare + $otherCharge + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST)) - $DiscountValue_);
$intCostToCustomer += ((($PBaseFare + $otherCharge + $FixedMarkUp + $apiMarkup + $apiTaxOnMarkup + $GSTOnMarkUp + $intGTXMarkUp + $GTXMarkUpGST + $IntCommission)) - $DiscountValue_);
}
//echo $PBaseFare.' +'. $otherCharge .' +'. $FixedMarkUp.' + '.$GSTOnMarkUp .' +'. $apiMarkup .' +'. $apiTaxOnMarkup .' +'. $intGTXMarkUp .' +'. $GTXMarkUpGST;
// $GrandTotalBaseFare += ((($PBaseFare + $otherCharge + $FixedMarkUp + $apiMarkup + $intTotalGST + $intGTXMarkUp + $GTXMarkUpGST) - $customerDiscount) - $DiscountValue_);
//$GrandTotalBaseFare += ($PBaseFare + $otherCharge + $FixedMarkUp + $apiMarkup + $intTotalGST + + $intGTXMarkUp + $GTXMarkUpGST);
}
}
}
}
//echo $intCostToCustomer.'=='.$GrandTotalBaseFare;
$OtherCharges = ($TotalExtraMarkup + $TotalExtraMarkupOnGST);
$TotalExtraCharge = ($TotalExtraMarkup + $TotalExtraMarkupOnGST);
if ($showintax == 1) {
$OtherCharges = $OtherCharges;
$ExtraMarkup = 0;
$ExtraMarkupOnGST = 0;
$TotalExtraProfit = $TotalExtraCharge;
} else {
$ExtraMarkup = $TotalExtraMarkup;
$ExtraMarkupOnGST = $TotalExtraMarkupOnGST;
$OtherCharges = 0;
$TotalExtraProfit = $ExtraMarkup;
}
//echo '<pre>';print_r($BookingData);echo '</pre>';die;
$BagPrice = 0;
$InbBagPrice = 0;
$MealPrice = 0;
$InbMealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice + $InbMealPrice);
$BaggFare = ($BagPrice + $InbBagPrice);
$PublishedFare = (($GrandTotalBaseFare + $BaggFare + $MealFare + $SeatPrice));
$intCostToCustomer = (($intCostToCustomer + $BaggFare + $MealFare + $SeatPrice));
//$PublishedFare = ($PublishedFare + $BaggFare + $MealFare + $SeatPrice);
$this->view->intChargeFromWallet = ($PublishedFare);
$this->view->intGrandPayableAmount = ceil($intCostToCustomer);
//
$strPriceAndMarkups = json_encode($arrPriceAndMarkups);
$this->view->stringData = $strStringData = $this->getEnc($strPriceAndMarkups);
$this->view->intLoggedinUserId = $this->intLoggedinUserId;
$this->view->intLoggedinUserGroupSysId = $this->intLoggedinUserGroupId;
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinAgencyId;
$this->view->guid = $this->GUID();
$this->view->walletCode = $this->walletCode($this->intLoggedinAgencyId, $this->view->guid, ($PublishedFare), $this->intLoggedinUserId, $intTPSysId, $intCustomerSysId, $strStringData);
$this->view->securecode = $this->secureCode($this->intLoggedinAgencyId, $this->view->guid);
}
public function verifyingBookingAction() {
if ($this->_request->isXmlHttpRequest()) {
$post = $this->getRequest()->getPost();
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgentDetailById = $crmcustomerObj->getAgentDetailById($this->intLoggedinUserId);
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$IsAllowFlightBooking = isset($getAgentDetailById[0]['IsAllowFlightBooking']) ? $getAgentDetailById[0]['IsAllowFlightBooking'] : 0;
$IsCheckWallet = isset($this->agencyDetails['IsCheckWallet']) ? $this->agencyDetails['IsCheckWallet'] : 0;
$PrimaryContactNo = isset($this->agencyDetails['PrimaryContactNo']) ? trim($this->agencyDetails['PrimaryContactNo']) : 0;
$countrycode = isset($this->agencyDetails['countrycode']) ? trim($this->agencyDetails['countrycode']) : '+91';
$MobileNumber = $countrycode . $PrimaryContactNo;
$LoggedinUserMobileNumber = $countrycode . $this->intLoggedinUserContactNo;
//
// $LoggedinUserMobileNumber = $countrycode.'8447455883'; // for testing
// $MobileNumber = $countrycode.'8447455883'; // for testing
$customHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$objFlight = new Travel_Model_TblFlight();
//
$FlightTempData = $objFlight->GetFlightTempData($post['strUrlData']);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$withprice = (isset($post['withprice']) && !empty($post['withprice'])) ? 1 : 0;
$paymentModebyUser = (isset($post['paymentModebyUser']) && !empty($post['paymentModebyUser'])) ? $post['paymentModebyUser'] : 1;
$travelPlanDetais = $this->_crmcusttravelplan->CheckCustomerWithLeadId($intTPSysId);
if (!empty($intOutBoundId)) {
$BookingData = $intOutBoundId;
$SelectedBaggSessionNew = !empty($arrUrlData['SelectedBaggSessionNew']) ? $arrUrlData['SelectedBaggSessionNew'] : 0;
$SelectedMealSessionNew = !empty($arrUrlData['SelectedMealSessionNew']) ? $arrUrlData['SelectedMealSessionNew'] : 0;
$selectedSeatSession = !empty($arrUrlData['selectedSeatSession']) ? $arrUrlData['selectedSeatSession'] : 0;
$sessionFlightSearchParams = !empty($arrUrlData['sessionFlightSearchParams']) ? $arrUrlData['sessionFlightSearchParams'] : 0;
$intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$IsSeriesFareData = !empty($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
$this->view->IsCheckWallet = $IsCheckWallet;
$this->view->IsAllowFlightBooking = $IsAllowFlightBooking;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$CashBalance = 1000000000;
$Total_CommiErn = 0;
$GrandTotalBaseFare = 0;
$GrandSellingPrice = 0;
$TotalPublishedFare = 0;
$TotalExtraMarkupAgency = 0;
if ($BookingData) {
foreach ($BookingData as $amount) {
$AirlineName = $amount['AirlineName'];
$FlightNumber = $amount['FlightNumber'];
$TotalPublishedFare += $amount['FairRules']['PublishedFare'];
$agencyMarkUp += $amount['FairRules']['FixedMarkUp'];
$gtxMarkup += $amount['FairRules']['intGTXMarkUp'];
$offerFare += $amount['FairRules']['OfferedFare'];
$gtxMarkupGST += $amount['FairRules']['GTXMarkUpGST'];
$agencyMarkUpGST += $amount['FairRules']['GSTOnMarkUp'];
if ($amount['FairRules']['FareBreakdown']) {
foreach ($amount['FairRules']['FareBreakdown'] as $key => $value) {
$PBaseFare = $value['BaseFare'];
$TaxIN = $value['TaxIN'];
$IntCommission = $value['IntCommission'];
$CommEarned = $value['CommEarned'];
$CommissionEarned = $value['CommissionEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$TotalExtraMarkup += isset($value['ExtraMarkup']) ? $value['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST += isset($value['ExtraMarkupOnGST']) ? $value['ExtraMarkupOnGST'] : 0;
$TotalExtraMarkup__ = isset($value['ExtraMarkup']) ? $value['ExtraMarkup'] : 0;
$TotalExtraMarkupOnGST__ = isset($value['ExtraMarkupOnGST']) ? $value['ExtraMarkupOnGST'] : 0;
$intGTXMarkUp = $value['intGTXMarkUp'];
$GTXMarkUpGST = $value['GTXMarkUpGST'];
$apiTaxOnMarkup = $value['apiTaxOnMarkup'];
$intTotalGST = $value['intTotalGST'];
$apiMarkup = $value['apiMarkup'];
$DiscountValue_ = isset($value['DiscountValue']) ? $value['DiscountValue'] : 0;
$CommisionPass = isset($value['CommisionPass']) ? $value['CommisionPass'] : 0;
$OtherCharges_ = isset($value['OtherCharges']) ? $value['OtherCharges'] : 0;
$TDS = $value['TDS'];
$MF = $value['MF']; //Management Fee
$YQ = $value['YQ']; //Fuel Surcharge
$AGST = $value['AGST']; //Airline GST Component
$MFT = $value['MFT']; //Management Fee Tax
$OT = $value['OT']; //Other Charges
$MU = $value['MU']; //Markup
$YR = $value['YR']; //Carrier Misc Fee
$otherCharge = ($YQ + $AGST + $MFT + $MF + $OT + $YR);
if ($ICSourceSysId == 3) {
$otherCharge = ($AGST + $MFT + $MF + $OT + $YR);
}
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$paxPublishedFare = ($PBaseFare);
$PassengerType = $value['PassengerType'];
$PassengerCount = $value['PassengerCount'];
$BaseFare = ($value['BaseFare'] / $PassengerCount);
$TaxesFees = ($MF + $YQ + $AGST + $MFT + $OT + $MU + $YR + $FixedMarkUp + $GSTOnMarkUp);
$PublishedFare = ($value['BaseFareCal'] - $TaxIN - $FixedMarkUp - $GSTOnMarkUp);
$TotalExtraMarkupAgency += ($TotalExtraMarkup__ + $TotalExtraMarkupOnGST__);
$Total_CommiErn += ($CommEarned);
$TotalBaseFare += $PublishedFare;
if ($ICSourceSysId == 3) {
$GrandTotalBaseFare += ((($PBaseFare + $otherCharge + $OtherCharges_ + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST - $CommisionPass)) - $DiscountValue_);
$GrandSellingPrice += ((($PBaseFare + $TotalExtraMarkup__ + $TotalExtraMarkupOnGST__ + $FixedMarkUp + $GSTOnMarkUp + $otherCharge + $OtherCharges_ + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST - $CommisionPass)) - $DiscountValue_);
} else {
$GrandTotalBaseFare += ((($PBaseFare + $otherCharge + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST)) - $DiscountValue_);
$GrandSellingPrice += ((($PBaseFare + $TotalExtraMarkup__ + $TotalExtraMarkupOnGST__ + $FixedMarkUp + $GSTOnMarkUp + $otherCharge + $apiMarkup + $apiTaxOnMarkup + $intGTXMarkUp + $GTXMarkUpGST)) - $DiscountValue_);
}
}
}
}
}
$TotalExtraCharge = ($TotalExtraMarkup + $TotalExtraMarkupOnGST);
$BagPrice = 0;
$MealPrice = 0;
$SeatPrice = 0;
if ($SelectedBaggSessionNew) {
foreach ($SelectedBaggSessionNew as $values) {
foreach ($values as $val) {
$BagPrice += $val['Price'];
}
}
}
if ($SelectedMealSessionNew) {
foreach ($SelectedMealSessionNew as $values) {
foreach ($values as $val) {
$MealPrice += $val['Price'];
}
}
}
if ($selectedSeatSession) {
foreach ($selectedSeatSession as $values) {
foreach ($values as $val) {
$SeatPrice += $val['amount'];
}
}
}
$MealFare = ($MealPrice);
$BaggFare = ($BagPrice);
$TotalPublishedFare = (($TotalPublishedFare + $BaggFare + $MealFare + $SeatPrice));
$intChargeFromWallet = (($GrandTotalBaseFare + $BaggFare + $MealFare + $SeatPrice));
$intChargeSelling = (($GrandSellingPrice + $BaggFare + $MealFare + $SeatPrice));
// echo "<pre>";print_r($TotalPublishedFare);
// echo "<pre>";print_r($TotalExtraMarkupAgency);
// exit;
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$AgencySysId__ = isset($customerDetails['AgencySysId']) ? $customerDetails['AgencySysId'] : 0;
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$IsEnabledWallet = isset($customerDetails['IsEnabledWallet']) ? $customerDetails['IsEnabledWallet'] : 0;
$CustomerSysId = isset($customerDetails['CustomerSysId']) ? $customerDetails['CustomerSysId'] : 0;
$model = new Gtxwebservices_Model_Webservices();
if ($IsB2BCustomer == 1 && $paymentModebyUser == 1) {
$intChargeSelling = ($TotalPublishedFare + $TotalExtraMarkupAgency);
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId__);
$B2BAgencySysIdKey = $getAgencyDetail['SecurityKey'];
$B2CAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$apiDataIV = array(
"B2BAgencySysIdKey" => $B2BAgencySysIdKey,
"B2CAgencySysIdKey" => $B2CAgencySysIdKey,
);
$result = json_decode($model->GetB2Bbalance($apiDataIV), true);
$B2BwalletBalanceAmount = isset($result['creditBalance']) ? $result['creditBalance'] : 0;
if ((float) $B2BwalletBalanceAmount < (float) $intChargeSelling) {
$response = array('success' => false, 'message' => 'Agent does not have sufficient Credit Balance. Use Pay Later or Ask agent to top up balance.');
echo json_encode($response);
exit;
}
} elseif ($IsEnabledWallet == 1 && $paymentModebyUser == 1) {
$apiDataIV = array(
"CustomerSysId" => $CustomerSysId,
);
$result = json_decode($model->GetB2Cbalance($apiDataIV, $this->agencyDetails['SecurityKey']), true);
$walletBalanceAmount = (isset($result['WalletBalance'][0]['BalanceAmount']) && !empty($result['WalletBalance'][0]['BalanceAmount'])) ? $result['WalletBalance'][0]['BalanceAmount'] : 0;
if ((float) $walletBalanceAmount < (float) $TotalPublishedFare) {
$response = array('success' => false, 'message' => 'Agent does not have sufficient Credit Balance. Use Pay Later or Ask customer to top up balance.');
echo json_encode($response);
exit;
}
}
// echo "<pre>";print_r($post);
// echo "<pre>";print_r($TotalPublishedFare);
// echo "<pre>";print_r($intChargeFromWallet);
// exit;
$arrUrlData['withprice'] = $withprice;
$arrUrlData['paymentModebyUser'] = $paymentModebyUser;
$arrUrlData['UpdateCredit'] = $UpdateCredit;
$tempData = array(
'TPSysId' => $intTPSysId,
'TraceId' => $post['strUrlData'],
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($post['strUrlData']);
$objFlight->insertFlightTempData($tempData);
if (isset($post['verifying']) && $post['verifying'] == 'true' && !empty($post['verifying'])) {
$getBooingOTP = $objFlight->getBooingOTP($intTPSysId);
$OTPNumber = trim($post['OTPNumber']);
$IsProposal = isset($post['IsProposal']) ? $post['IsProposal'] : 0;
if ($ICSourceSysId == 9) {
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => false, 'trxstatus' => 'success', 'checkpr' => 0, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
}
####### In case of quick proposal flight booking start #############
if ($IsProposal == 1) {
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => ''), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => false, 'trxstatus' => 'success', 'checkpr' => 0, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Invalid otp');
echo json_encode($response);
exit;
}
}
####### In case of quick proposal flight booking end #############
if ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1 && $IsSeriesFareData == 1) {
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => ''), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => false, 'checkpr' => 0, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Invalid otp');
echo json_encode($response);
exit;
}
} elseif ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1) {
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => ''), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => false, 'checkpr' => 0, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Invalid otp');
echo json_encode($response);
exit;
}
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 1) {
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => ''), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => true, 'checkpr' => $intChargeFromWallet, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Invalid otp');
echo json_encode($response);
exit;
}
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 0) {
if ($getBooingOTP == $OTPNumber) {
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => ''), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$response = array('success' => true, 'checkOTP' => false, 'walletPay' => true, 'checkpr' => $intChargeFromWallet, 'PhoneNumberDigit' => $hidePhoneNumberDigit);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Invalid otp');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'checkpr' => 0, 'message' => 'Booking not allowed.');
echo json_encode($response);
exit;
}
}
if ($ICSourceSysId == 3) {
if ($BookingData && $CashBalance >= (float) ceil($intChargeFromWallet)) {
foreach ($BookingData as $k => $value) {
$TPintSysId = isset($arrIntTpAirId[$k]) ? $arrIntTpAirId[$k] : 0;
$checkNonLccBooking = $objFlight->checkNonLccBooking($TPintSysId);
$IsBookingStatus = isset($checkNonLccBooking['IsBookingStatus']) ? $checkNonLccBooking['IsBookingStatus'] : 0;
//echo "<pre>";print_r($value);die;
$AirlineName = $value['AirlineName'];
$FlightNumber = $value['FlightNumber'];
if ($value && $IsBookingStatus != 1) {
$BookingdataAPI = array(
'FlightBookingData' => $value,
'sessionFlightSearchParams' => $sessionFlightSearchParams,
'CustomerSession' => $arrTrevllerDetails,
'SelectedBaggSessionNew' => $arrUrlData['SelectedBaggSessionNew'],
'SelectedMealSessionNew' => $arrUrlData['SelectedMealSessionNew'],
'selectedSeatSession' => $arrUrlData['selectedSeatSession'],
);
if ($value['IsLCC'] == 1 || $value['IsLCC'] == '1') {
///// This action perform on bookflight action
} else {
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiFlightBooking($BookingdataAPI, $this->intLoggedinAgencyId);
$FlightBookingTicketArr[$k] = $response;
$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
if ($ResponseStatus == 1) {
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => $strTicketPNRLCC,
"XRefBookingId" => $strBookingIdLCC,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1 //Booking Requested. Booking Confirmed Ticket In Process
);
$objFlight->updateBookingDetails($data, $TPintSysId); // FOR BOOKING CONFIRMED
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'Unable to book ' . $AirlineName . ' ' . $FlightNumber . ' please choose another flight.');
echo json_encode($response);
exit;
}
}
}
}
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'Sorry we could not process your booking. Please contact our customer support. (API Insufficient Balance)');
echo json_encode($response);
exit;
}
}
/* OTP setting */
$data = new Payment_Model_Checkotp();
$generateNumericOTP = $this->generateNumericOTP(6);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$html->assign(array('getBooingOTP' => $generateNumericOTP, 'agencyDetails' => $this->agencyDetails));
$bodyText = $html->render('OTPEmail.phtml');
$fromName = (isset($this->agencyDetails['DisplayName']) && !empty($this->agencyDetails['DisplayName'])) ? trim($this->agencyDetails['DisplayName']) : trim(trim($this->agencyDetails['Title']));
$emailData = array(
'fromEmail' => $this->intLoggedinUserEmailId,
'fromName' => $fromName,
'subject' => 'OTP for booking ' . Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss'),
'to' => array($this->intLoggedinUserEmailId),
'bodyHtml' => $bodyText,
'bodyText' => ''
);
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Zend_Session::namespaceUnset('OtpNumberSession');
// $OtpNumberSession = new Zend_Session_Namespace('OtpNumberSession');
// $OtpNumberSession->params = $generateNumericOTP;
$objFlight->updateBookingStatusTravelPlan(array("CustomerRemark" => $generateNumericOTP), $intTPSysId, $travelPlanDetais[0]['MasterTPSysId']);
$date = new Zend_Date();
$currentDate = $date->get('yyyy-MM-dd HH:mm:ss');
$date->add('2', Zend_Date::MINUTE);
$RandomCodeValidTo = $date->toString('yyyy-MM-dd HH:mm:ss');
$col = array('RandomCode' => $generateNumericOTP, 'RandomCodeValidFrom' => $currentDate, 'RandomCodeValidTo' => $RandomCodeValidTo);
//$message = "OTP for flight booking is $generateNumericOTP do not share it with anyone. valid for 2 minutes only";
$message = "OTP for CRM access is $generateNumericOTP do not share it with anyone.\nTRVCRM";
$this->postFields = "";
$this->postFields .= "&method=$this->SMSMETHOD";
$this->postFields .= "&api_key=$this->SMSAPIKEY";
$this->postFields .= "&sender=$this->SMSSENDER";
$this->postFields .= "&message=$message";
$this->postFields .= "&format=$this->SMSFORMAT";
$postURL = $this->SMSURL;
// $resultVal = $data->sendSmsDetails($postURL, $this->postFields,array('AgencySysId'=>$this->intLoggedinAgencyId));
//echo '<pre>';print_r($IsAllowFlightBooking);echo '</pre>';
//echo '<pre>';print_r($IsCheckWallet);echo '</pre>';die;
if ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1 && $IsSeriesFareData == 1) {
$this->postFields .= "&to=" . substr($LoggedinUserMobileNumber, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($LoggedinUserMobileNumber, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->intLoggedinAgencyId), $this->IsSMSApi);
$guid = isset($resultVal['data']['data']['group_id']) ? $resultVal['data']['data']['group_id'] : 'NA';
$response = array('success' => true, 'checkOTP' => true, 'walletPay' => false, 'PhoneNumberDigit' => $hidePhoneNumberDigit, 'guid' => $guid, 'trxstatus' => 'success');
echo json_encode($response);
exit;
} elseif ($IsCheckWallet == 1 && $IsAllowFlightBooking == 1) {
$this->postFields .= "&to=" . substr($LoggedinUserMobileNumber, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($LoggedinUserMobileNumber, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->intLoggedinAgencyId), $this->IsSMSApi);
$guid = isset($resultVal['data']['data']['group_id']) ? $resultVal['data']['data']['group_id'] : 'NA';
$response = array('success' => true, 'checkOTP' => true, 'walletPay' => false, 'PhoneNumberDigit' => $hidePhoneNumberDigit, 'guid' => $guid, 'trxstatus' => 'success');
echo json_encode($response);
exit;
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 1) {
$this->postFields .= "&to=" . substr($LoggedinUserMobileNumber, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($LoggedinUserMobileNumber, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->intLoggedinAgencyId), $this->IsSMSApi);
// echo "<pre>0";print_r($resultVal);exit;
$guid = isset($resultVal['data']['data']['group_id']) ? $resultVal['data']['data']['group_id'] : 'NA';
$wallet = Zend_Controller_Action_HelperBroker::getStaticHelper('Dashboard')->getWalletPrice($this->intLoggedinAgencyId);
$walletBalanceAmount = $wallet[0]['BalanceAmount'];
if ($walletBalanceAmount >= $intChargeFromWallet) {
$response = array('success' => true, 'checkOTP' => true, 'walletPay' => true, 'PhoneNumberDigit' => $hidePhoneNumberDigit, 'guid' => $guid, 'trxstatus' => 'success');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'You do not have sufficient balance to make this booking. Please recharge before proceed.');
echo json_encode($response);
exit;
}
} elseif ($IsCheckWallet == 0 && $IsAllowFlightBooking == 0) {
$this->postFields .= "&to=" . substr($MobileNumber, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($MobileNumber, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->intLoggedinAgencyId), $this->IsSMSApi);
//echo "<pre>4";print_r($resultVal);exit;
$guid = isset($resultVal['data']['data']['group_id']) ? $resultVal['data']['data']['group_id'] : 'NA';
$wallet = Zend_Controller_Action_HelperBroker::getStaticHelper('Dashboard')->getWalletPrice($this->intLoggedinAgencyId);
$walletBalanceAmount = $wallet[0]['BalanceAmount'];
if ($walletBalanceAmount >= $intChargeFromWallet) {
$response = array('success' => true, 'checkOTP' => true, 'walletPay' => true, 'PhoneNumberDigit' => $hidePhoneNumberDigit, 'guid' => $guid, 'trxstatus' => 'success');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'You do not have sufficient balance to make this booking. Please recharge before proceed.');
echo json_encode($response);
exit;
}
} elseif ($IsCheckWallet == 1 && $IsAllowFlightBooking == 0) {
$this->postFields .= "&to=" . substr($MobileNumber, -10);
$hidePhoneNumberDigit = $customHelper->hidePhoneNumberDigit($MobileNumber, 1);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$resultVal = $data->sendSmsDetails($postURL, $this->postFields, array('AgencySysId' => $this->intLoggedinAgencyId), $this->IsSMSApi);
//echo "<pre>7";print_r($resultVal);exit;
$guid = isset($resultVal['data']['data']['group_id']) ? $resultVal['data']['data']['group_id'] : 'NA';
$response = array('success' => true, 'checkOTP' => true, 'walletPay' => false, 'PhoneNumberDigit' => $hidePhoneNumberDigit, 'guid' => $guid, 'trxstatus' => 'success');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'Booking not allowed. somethings went wrong!!');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'checkOTP' => false, 'walletPay' => false, 'message' => 'Oops something went wrong.');
echo json_encode($response);
exit;
}
} else {
die('Invalid request');
}
}
public function checkFlightPaymentAction() {
$objFlight = new Travel_Model_TblFlight();
$param = $this->getRequest()->getPost();
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
echo "<pre>";
print_r($param);
print_r($arrUrlData);
die;
// print_r($arrUrlData['sessionLogin_user']);
// die;
}
public function generateNumericOTP($n) {
$generator = "1357902468";
$result = "";
for ($i = 1; $i <= $n; $i++) {
$result .= substr($generator, (rand() % (strlen($generator))), 1);
}
// Return result
return $result;
}
public function reviewBookingAction() {
// For Flight Header & Sale Summary Tab
$this->view->intLoggedinUserFirstName = $this->intLoggedinUserFirstName;
$this->view->intLoggedinUserEmailId = $this->intLoggedinUserEmailId;
$this->view->intLoggedinUserContactNo = $this->intLoggedinUserContactNo;
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$intGoingFlightId = !empty($this->view->intOutBoundId = $arrUrlData['intOutBoundId']) ? $this->view->intOutBoundId = $arrUrlData['intOutBoundId'] : 0;
$intReturnFlightId = !empty($this->view->intInBoundId = $arrUrlData['intInBoundId']) ? $this->view->intOutBoundId = $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = !empty($this->view->intInBoundId = $arrUrlData['intCustomerSysId']) ? $this->view->intOutBoundId = $arrUrlData['intCustomerSysId'] : 0;
$intTPSysId = !empty($this->view->intInBoundId = $arrUrlData['intTPSysId']) ? $this->view->intOutBoundId = $arrUrlData['intTPSysId'] : 0;
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$this->view->arrSelectedFlightDetails = $arrSelectedFlightDetails;
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
$arrFlightFare = array();
if (!empty($arrSelectedFlightFareDetails)) {
$j = 0;
$i = 0;
$temp = "";
foreach ($arrSelectedFlightFareDetails as $value) {
$intTBQAirInvenAPISysId = trim($value['TBQAirInvenAPISysId']);
if (!empty($temp) && $temp != $intTBQAirInvenAPISysId) {
$i++;
$j = 0;
$temp = "";
}
if ($temp == "") {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
} else if ($temp == trim($value['TBQAirInvenAPISysId'])) {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
}
$arrFlightFare[$i][$j]['OtherCharges'] = $value['OtherCharges'];
$arrFlightFare[$i][$j]['Discount'] = $value['Discount'];
$arrFlightFare[$i][$j]['ServiceFee'] = $value['ServiceFee'];
$arrFlightFare[$i][$j]['PublishedFare'] = $value['PublishedFare'];
$arrFlightFare[$i][$j]['CommissionEarned'] = $value['CommissionEarned'];
$arrFlightFare[$i][$j]['PLBEarned'] = $value['PLBEarned'];
$arrFlightFare[$i][$j]['IncentiveEarned'] = $value['IncentiveEarned'];
$arrFlightFare[$i][$j]['OfferedFare'] = $value['OfferedFare'];
$arrFlightFare[$i][$j]['TdsOnCommission'] = $value['TdsOnCommission'];
$arrFlightFare[$i][$j]['TdsOnPLB'] = $value['TdsOnPLB'];
$arrFlightFare[$i][$j]['TdsOnIncentive'] = $value['TdsOnIncentive'];
$j++;
}
}
$this->view->arrFlightFare = $arrFlightFare;
//echo "<pre>";print_r($arrFlightFare);echo "</pre>";//exit;
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$this->view->intFlightRoute = $intFlightRoute = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : 0;
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams->params['child']) ? $sessionFlightSearchParams->params['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams->params['infant']) ? $sessionFlightSearchParams->params['infant'] : 0;
$this->view->route = $route = isset($sessionFlightSearchParams->params['route']) ? $sessionFlightSearchParams->params['route'] : 0;
$this->view->interNationalSearch = $interNationalSearch = isset($sessionFlightSearchParams->params['interNationalSearch']) ? $sessionFlightSearchParams->params['interNationalSearch'] : 0;
$intTatalPaxCTForMarkUp = $adultCount + $childCount + $infantCount;
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
//echo "<pre>";print_r($sessionFlightSearchParams->params);echo "</pre>";
$arrPaxCount = array(
'intAdultsCount' => $adultCount,
'intChildCount' => $childCount,
'intInfantCount' => $infantCount
);
$this->view->arrPaxCount = $arrPaxCount;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
// echo "<pre>";print_r($arrTrevllerDetails);echo "</pre>";
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if (isset($intCustomerSysId) && !empty($intCustomerSysId) && $intCustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetsils = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$this->view->customerDetsils = $customerDetsils;
}
}
// For Flight Header , Sale Summary Tab Customers Details Ends...
$wallet = Zend_Controller_Action_HelperBroker::getStaticHelper('Dashboard')->getWalletPrice($this->intLoggedinAgencyId);
$this->view->walletBalanceAmount = $wallet[0]['BalanceAmount'];
$this->view->Error = $strError = trim($this->getRequest()->getParam('error_Message'));
$fullBaseUrl = $this->view->baseUrl();
$this->view->strPayWithWalletUrl = $fullBaseUrl . "/payment/wallet-pay";
$this->view->strRechargeNowUrl = $fullBaseUrl . "/payment/payment-options";
$this->view->strSearchPageUrl = $fullBaseUrl . "/flight/search-result";
$this->view->strReturnURL = $fullBaseUrl . "/flight/book-flight/data/" . $strUrlData;
$this->view->strErrorURL = $fullBaseUrl . "/flight/review-booking/data/" . $strUrlData;
$this->view->intPlanType = "1";
$this->view->strTrxType = "A";
$Customer = new Zend_Session_Namespace('Customer');
$this->view->intTpSysId = $intTpSysId = $Customer->intTPSysId;
$this->view->intCustomerSysId = $intCustomerSysId = $Customer->intCustomerSysId;
$sessionFareFinal = new Zend_Session_Namespace('sessionFareFinal');
if (!empty($sessionFlightInventoryBookingParams->intAirInvenSysId)) {
$TotalPublishedFare = $sessionFlightInventoryBookingParams->netAmt;
} else {
$TotalPublishedFare = $sessionFareFinal->TotalPublishedFare;
}
$sessionFlightPriceAndMarkupsDetails = new Zend_Session_Namespace('sessionFlightPriceAndMarkupsDetails');
//echo "<pre>";print_r($sessionFlightPriceAndMarkupsDetails->params);
//echo "<pre>";print_r($arrFlightFare);echo "</pre>";
$TotalBaseFare = 0;
$intGTXMarkUp = 0;
$intAgencyMarkUp = 0;
$intTDSOnAgencyMarkUp = 0;
$TotalPublishedFare = 0;
$intChargeFromWallet = 0;
$intCommisionEarnedForAgency = 0;
$intPLBEarnedForAgency = 0;
$intIncentiveEarnedForAgency = 0;
$intTotalEarningsForAgency = 0;
$intTotalGSTAgencyEarnings = 0;
$intAgencyFixMarkUp = 0;
$CostToAgent = 0;
//for ($intI=0; $intI <= count($arrFlightFare); $intI++){
foreach ($arrFlightFare as $FareResult) {
foreach ($FareResult as $FareBreakdown) {
$intPublishedFare = $FareBreakdown['PublishedFare'];
$intOfferedFare = $FareBreakdown['OfferedFare'];
$intCommissionEarned = $FareBreakdown['CommissionEarned'];
$intPLBEarned = $FareBreakdown['PLBEarned'];
$intIncentiveEarned = $FareBreakdown['IncentiveEarned'];
$arrAllCommissions = array(
'intCommissionEarned' => $intCommissionEarned,
'intPLBEarned' => $intPLBEarned,
'intIncentiveEarned' => $intIncentiveEarned
);
}
//echo $this->intLoggedinAgencyId;
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $intOfferedFare, $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps);echo "</pre>";
//$intFareWithGTXMarkUp = $arrPriceAndMarkUps['intFareWithGTXMarkUp'];
if (!empty($interNationalSearch)) {
$intGTXMarkUp += (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intFareWithGTXMarkUp = $intOfferedFare + (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUp += ($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intFareWithGTXMarkUp = $intOfferedFare + ($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnGTXMarkUp = ($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intAgencyFixMarkUp = ($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUp = ($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
}
//echo $intGTXMarkUp;
// Agency Earning Part....
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency += $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency;
// Agency Earning Part....
// Agency Earning Tax Part....
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings += $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
// Agency Earning Tax Part....
$CostToAgent += $intFareWithGTXMarkUp;
//echo $intChargeFromWallet += $TotalPublishedFare - ($intAgencyFixMarkUp + $intSTaxOnAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency);
$intCostToCustomer = $CostToAgent + $intTotalEarningsForAgency + $intTotalGSTAgencyEarnings;
$intChargeFromWallet = $CostToAgent;
}
//echo '<pre>';print_r($CostToAgent + $intTotalEarningsForAgency + $intTotalGSTAgencyEarnings);echo '</pre>';
//echo '<pre>';print_r($CostToAgent);echo '</pre>';
//echo $intChargeFromWallet.'=='.$intCostToCustomer.'='.$intTotalGSTAgencyEarnings;
$this->view->intTotalPublishedFare = $TotalPublishedFare;
$this->view->intTotalAmount = $TotalPublishedFare;
$this->view->intTax = $intTDSOnAgencyMarkUp;
$this->view->intAgentMarkUpAmount = $intAgencyMarkUp;
//$this->view->intGrandPayableAmount = $intGrandPayableAmount = $TotalPublishedFare;
$this->view->intGrandPayableAmount = $intCostToCustomer;
$this->view->intChargeFromWallet = ($intChargeFromWallet);
//$this->view->intChargeFromWallet = ($intChargeFromWallet - $intTotalGSTAgencyEarnings);
$arrPriceAndMarkups = array(
"intAgentMarkUpAmount" => 0,
"intAgencyMarkUpAmount" => $intTotalEarningsForAgency,
"intGTXMarkUpAmount" => $intGTXMarkUp,
"intTotalAmount" => ($CostToAgent - $intGTXMarkUp),
"intTax" => 0,
"GTXServiceTaxAmount" => 0,
"AgentServiceTaxAmount" => $intTotalGSTAgencyEarnings,
"AgentsCustomServiceTaxAmount" => "0",
"Pax" => $intTatalPaxCTForMarkUp,
"SupplierSourceStr" => "API",
"MarketPlaceId" => "1",
"TotalDiscount" => "0",
"CurrencyType" => "1"
);
//echo "<pre>";print_r($arrPriceAndMarkups);echo "</pre>";//exit;
$strPriceAndMarkups = json_encode($arrPriceAndMarkups);
$this->view->stringData = $strStringData = $this->getEnc($strPriceAndMarkups);
$this->view->intLoggedinUserId = $this->intLoggedinUserId;
$this->view->intLoggedinUserGroupSysId = $this->intLoggedinUserGroupId;
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinAgencyId;
$this->view->guid = $this->GUID();
$this->view->walletCode = $this->walletCode($this->intLoggedinAgencyId, $this->view->guid, $intCostToCustomer, $this->intLoggedinUserId, $intTPSysId, $intCustomerSysId, $strStringData);
$this->view->securecode = $this->secureCode($this->intLoggedinAgencyId, $this->view->guid);
}
public function printVoucherAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
//echo "<pre>";print_r($arrUrlData);//exit;
$intGoingFlightId = $this->view->intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$intReturnFlightId = $this->view->intOutBoundId = !empty($arrUrlData['intInBoundId']) ? $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$arrIntTpAirId = !empty($arrUrlData['arrIntTpAirId']) ? $arrUrlData['arrIntTpAirId'] : '';
//echo "<pre>"; print_r($arrIntTpAirId);
$intTpAirVersionId = "'" . implode("','", $arrIntTpAirId) . "'";
//$this->view->arrBookingResponse = $arrarrBookingResponse = !empty($arrUrlData['arrBookingResponse'])?$arrUrlData['arrBookingResponse']:'';
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$this->view->arrSelectedFlightDetails = $arrSelectedFlightDetails;
$arrFlightBookingResponse = $objFlight->FlightBookingResponse($intTpAirVersionId);
$this->view->arrFlightBookingResponse = $arrFlightBookingResponse;
$this->view->XRefBookingId = $arrFlightBookingResponse[0]['XRefBookingId'];
//echo "<pre>";print_r(json_decode($arrFlightBookingResponse[0]['APIBookingRes'],true));exit;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if (isset($intCustomerSysId) && !empty($intCustomerSysId) && $intCustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetsils = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$this->view->customerDetsils = $customerDetsils;
}
}
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$this->view->arrAgencyDetail = $getAgencyDetail;
}
public function bookingConfirmationAction() {
// For Flight Header & Sale Summary Tab IsTripjack OnwardAutoTicket
// if ($this->intLoggedinAgencyId == '2656') {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
// }
$objFlight = new Travel_Model_TblFlight();
$strUrlData = $TrackId = $this->getRequest()->getParam('data', NULL);
if ($strUrlData) {
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$withprice = isset($arrUrlData['withprice']) ? $arrUrlData['withprice'] : 0;
$paymentModebyUser = isset($arrUrlData['paymentModebyUser']) ? $arrUrlData['paymentModebyUser'] : 0;
//$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$IsInterNational = !empty($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$route = !empty($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$B2BType = !empty($sessionFlightSearchParams['B2BType']) ? $sessionFlightSearchParams['B2BType'] : 0;
$bookingAllowed = !empty($sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : 0;
$this->view->bookingAllowed = $bookingAllowed;
//echo "<pre>";print_r($arrUrlData);exit;
if ($this->getRequest()->isGet() || $this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
if (isset($arrUrlData['IsTripjack']) && $arrUrlData['IsTripjack'] == 1 || $arrUrlData['IsTripjack'] == '') {
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$intCustomerSysId = !empty($arrUrlData['customerSysId']) ? $arrUrlData['customerSysId'] : (!empty($this->getRequest()->getParam('customerSysId')) ? $this->getRequest()->getParam('customerSysId') : 0);
$intTPSysId = $this->view->intTPSysId = !empty($arrUrlData['TPSysId']) ? $arrUrlData['TPSysId'] : (!empty($this->getRequest()->getParam('TPSysId')) ? $this->getRequest()->getParam('TPSysId') : 0);
$TrxSysId = $this->view->TrxSysId = !empty($arrUrlData['TrxSysId']) ? $arrUrlData['TrxSysId'] : (!empty($this->getRequest()->getParam('TrxSysId')) ? $this->getRequest()->getParam('TrxSysId') : 0);
$guid = $this->view->guid = !empty($arrUrlData['guid']) ? $arrUrlData['guid'] : (!empty($this->getRequest()->getParam('guid')) ? $this->getRequest()->getParam('guid') : '');
$intOutBoundId = $this->view->intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : (!empty($this->getRequest()->getParam('intOutBoundId')) ? $this->getRequest()->getParam('intOutBoundId') : '');
$this->view->IsTripjack = $arrUrlData['IsTripjack'];
$ICSourceSysId = isset($intOutBoundId[0]['ICSourceSysId']) ? $intOutBoundId[0]['ICSourceSysId'] : 0;
$this->view->CurrencyRate = $this->CurrencyRate;
$this->view->CurrencyTitle = $this->CurrencyTitle;
$this->view->paymentModebyUser = $paymentModebyUser;
$this->view->sessionFlightSearchParams = $sessionFlightSearchParams;
$this->view->arrBookingResponse = $arrBookingResponse = json_decode($arrUrlData['arrBookingResponse'], true);
$this->view->SelectedBaggSessionNew = $SelectedBaggSessionNew = ($arrUrlData['SelectedBaggSessionNew']);
$this->view->SelectedMealSessionNew = $SelectedMealSessionNew = ($arrUrlData['SelectedMealSessionNew']);
$this->view->selectedSeatSession = $selectedSeatSession = ($arrUrlData['selectedSeatSession']);
$arrIntTpAirId = $this->view->arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$checkPaymentStatus = $this->paymentMdl->checkPaymentStatus($this->intLoggedinAgencyId, $intTPSysId);
$this->view->checkPaymentStatus = $checkPaymentStatus;
$arrTravelPlanAir = $objFlight->getTravelPlanAirData($intTPSysId);
$this->view->arrTravelPlanAir = $arrTravelPlanAir;
$status = $this->view->status = $arrBookingResponse['status']['success'];
$ErrorMessage = [];
if (!empty($arrBookingResponse)) {
foreach ($arrBookingResponse['errors'] as $error) {
$ErrorMessage[] = $error['message'];
}
} else {
$ErrorMessage[] = 'Oops api response error. please contact administrator';
}
$Errors = $this->view->ErrorMessage = implode(',', $ErrorMessage);
$customerID = $sessionFlightSearchParams['customerID'];
$intCountryCode = $sessionFlightSearchParams['intCountryCode'];
$GetCustomerData = $crmcustomerObj->GetCustomerWithDetails($customerID);
$IsB2bSiteURL = $this->agencyDetails['IsB2bSiteURL'];
$statusURL = isset($param['status']) ? $param['status'] : '';
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if (isset($intCustomerSysId) && !empty($intCustomerSysId) && $intCustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetsils = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$this->view->customerDetsils = $customerDetsils;
}
}
$objMarkup = new Markup_Model_Markup();
if (!empty(trim($intCountryCode)) && trim($intCountryCode) != "IN") {
$intAirType = 2;
} else {
$intAirType = 1;
}
if ($IsInterNational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
$arrAgencyUserDetail = $objMarkup->getAgencyUserDetail(array("AgencySysId" => $this->intLoggedinAgencyId, "ItemSourceType" => (int) $intAirType, "PlanType" => 1, 'MarketType' => 1));
$this->view->arrAgencyUserDetail = $arrAgencyUserDetail;
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$emailId = $arrTrevllerDetails[0][0]['EmailId'];
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailSendId = trim($getAgencyDetail['PrimaryEmail']);
$IsBookingEmail = (isset($arrAgencyUserDetail) && !empty($arrAgencyUserDetail['IsBookingEmail'])) ? $arrAgencyUserDetail['IsBookingEmail'] : 0;
if (isset($arrAgencyUserDetail) && !empty($arrAgencyUserDetail['EmailId']) && $IsBookingEmail == 1) {
$ToemailSendId = trim($arrAgencyUserDetail['EmailId']);
} else {
$ToemailSendId = $emailSendId; //$this->intLoggedinUserEmailId;
}
// echo "<pre>";print_r($this->intLoggedinAgencyId);
// echo "<pre>";print_r($ToemailSendId);
// echo "<pre>";print_r($arrAgencyUserDetail);
// echo "<pre>";print_r($emailSendId);
// exit;
$objFlight = new Travel_Model_TblFlight();
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$AirlineRefPNR = $arrCustomerInvoiceData[0]['AirlineRefPNR'];
$XRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$FlightFareBreakdown = $objFlight->getSelectedFlightFareDetails();
$IsSupplierInv = isset($APIBookingRes['value']['IsSupplierInv']) ? $APIBookingRes['value']['IsSupplierInv'] : 0;
$IsSeriesFareData = isset($APIBookingRes['value']['IsSeriesFareData']) ? $APIBookingRes['value']['IsSeriesFareData'] : 0;
$SupplierSysId = isset($APIBookingRes['value']['SupplierSysId']) ? $APIBookingRes['value']['SupplierSysId'] : 0;
$CurrencyRate = isset($APIBookingRes['value']['FairRules']['CurrencyRate']) ? $APIBookingRes['value']['FairRules']['CurrencyRate'] : 1;
$getAgencySupplierUserData = array();
if ($IsSeriesFareData == 1 && $IsSupplierInv == 1 && !empty($SupplierSysId)) {
$TblSupplier = new Travel_Model_TblSupplier();
$getAgencySupplierUserData = $TblSupplier->getSupplierById($SupplierSysId);
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('arrtravellerList' => $arrtravellerList, 'CurrencyRate' => $CurrencyRate, 'getSupportContact' => $getSupportContact, 'arrTrevllerDetails' => $arrTrevllerDetails, 'FlightFareBreakdown' => $FlightFareBreakdown, 'arrCustomerInvoiceData' => $arrCustomerInvoiceData, 'intTPSysId' => ($intTPSysId), 'type' => 'mailToCustomer', 'getAgencySupplierUserData' => $getAgencySupplierUserData, 'withprice' => $withprice));
if ($ICSourceSysId == 3) {
$bodyText = $html->render('e-ticket.phtml');
} else {
$bodyText = $html->render('e-tickettj.phtml');
}
// echo "<pre>";print_r($APIBookingRes['value']);
// echo "<pre>";print_r($bodyText);
// exit;
$emailData = array(
'fromEmail' => $emailSendId,
'fromName' => $fromName,
'subject' => 'Your Ticket Has Been Booked',
'to' => array($emailId),
'bodyHtml' => $bodyText,
'bodyText' => ''
);
$emailDataAg = array(
'fromEmail' => $emailSendId,
'fromName' => $fromName,
'subject' => 'Your Ticket Has Been Booked',
'to' => array($ToemailSendId), //array($this->intLoggedinUserEmailId),
'bodyHtml' => $bodyText,
'bodyText' => ''
);
if (empty($AirlineRefPNR)) {
$emailData['subject'] = $subject = 'Booking Status – Pending - ' . trim($arrCustomerInvoiceData[0]['SourceAirportCode']) . ' - ' . trim($arrCustomerInvoiceData[0]['DestAirportCode']) . ' (Ref: ' . $XRefBookingId . ')';
if ($this->intLoggedinAgencyId == '5310') {
$emailData['to'] = array($emailId, 'sales.auxotrip@gmail.com');
}
} else {
$subject = 'Your Ticket Has Been Booked';
}
//echo "<pre>";print_r($bodyText);echo "</pre>";die;
// echo "<pre>";print_r($emailData);echo "</pre>";
// die;
if ($statusURL == 'true' && !empty(trim($AirlineRefPNR))) {
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
///////////$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
///////////$emailResponse = json_decode($this->mailSentByElastice($emailDataAg, $arrEmailStatistics), true);
if ($IsSeriesFareData == 1 && $IsSupplierInv == 1 && !empty($getAgencySupplierUserData)) {
$supplierBodyText = $html->render('e-ticket-supplier.phtml');
$configsSupp = [
'to' => array(trim($getAgencySupplierUserData['EmailId'])),
'fromName' => $fromName,
'fromEmail' => $emailSendId,
'subject' => $subject,
'bodyHtml' => $supplierBodyText,
];
///////////$emailResponse = $this->mailSentByElastice($configsSupp, $arrEmailStatistics);
$configsSuppAg = array(
'fromEmail' => $emailSendId,
'fromName' => $fromName,
'subject' => $subject,
'to' => array($ToemailSendId), //array($this->intLoggedinUserEmailId),
'bodyHtml' => $supplierBodyText,
'bodyText' => ''
);
///////////$emailResponse = $this->mailSentByElastice($configsSuppAg, $arrEmailStatistics);
}
$departureDataTime = [];
$arrivalDateTime = [];
$fromtoDestination = [];
$airlineNameAirlineNumber = [];
if ($intOutBoundId) {
foreach ($intOutBoundId as $Data) {
$LocalFromTime = date('d-M-Y H:i', strtotime($Data['LocalFromTime']));
$LocalToTime = date('d-M-Y H:i', strtotime($Data['LocalToTime']));
$departureDataTime[] = $LocalFromTime;
$arrivalDateTime[] = $LocalToTime;
$fromtoDestination[] = $Data['SourceAirportCode'] . '-' . $Data['DestAirportCode'];
$airlineNameAirlineNumber[] = $Data['AirlineName'] . ' ' . $Data['FlightNumber'];
foreach ($Data['Segments'] as $seg) {
$SegmentsArr[] = $seg;
}
}
}
$responsePNR = [];
$BookingId = [];
if ($arrCustomerInvoiceData) {
foreach ($arrCustomerInvoiceData as $DataSet) {
$APIRes = json_decode($DataSet['APIBookingRes'], true);
$responsePNR[] = ($APIRes['response']['Response']['Response']['PNR']);
$BookingId[] = ($APIRes['response']['Response']['Response']['BookingId']);
}
}
$ResponseStatus = ($APIBookingRes['response']['Response']['ResponseStatus'] == 1) ? 'SUCCESS' : '';
$travellerInfos = isset($APIBookingRes['response']['itemInfos']['AIR']['travellerInfos']) ? $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] : '';
$status = isset($APIBookingRes['response']['order']['status']) ? $APIBookingRes['response']['order']['status'] : $ResponseStatus;
if (isset($travellerInfos[0]['pnrDetails']) && !empty(isset($travellerInfos[0]['pnrDetails']))) {
$PNRWhats = implode(',', (array_values($travellerInfos[0]['pnrDetails'])));
} else {
$PNRWhats = implode(',', (array_values($responsePNR)));
;
}
$PaxDetailsW = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $key => $value) {
$PaxDetailsW[] = trim($value['FirstName']) . ' ' . trim($value['LastName']);
}
}
$FirstName = (isset($arrtravellerList[0]['FirstName']) && !empty($arrtravellerList[0]['FirstName'])) ? trim($arrtravellerList[0]['FirstName']) : '';
$countrycodeISD = trim($arrTrevllerDetails[0][0]['countrycodeISD']);
$MobileNumber = $countrycodeISD . '' . trim($arrTrevllerDetails[0][0]['Contacts']);
if ($ICSourceSysId == 3) {
$XRefBookingId = implode('-', $BookingId);
}
//echo "<pre>";print_r($ICSourceSysId);
//die;
$whatsappArray = [
'mobileNoCountryCode' => $MobileNumber,
'fullName' => $FirstName,
'ticketStatus' => $status,
'airlineNameAirlineNumber' => implode(',', $airlineNameAirlineNumber),
'fromtoDestination' => implode(',', $fromtoDestination),
'departureDataTime' => implode(',', $departureDataTime),
'arrivalDateTime' => implode(',', $arrivalDateTime),
'pnrAndBookingId' => $PNRWhats . '/' . $XRefBookingId,
'noOfPax' => count(array_values(array_unique($PaxDetailsW))),
'PaxDetails' => implode(',', array_values(array_unique($PaxDetailsW))),
'checkurl' => $this->baseUrl,
'AgencyName' => trim($getAgencyDetail['DisplayName']),
'voucherlink' => trim($XRefBookingId),
];
$SendWhatsapp = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->SendWhatsapp($whatsappArray, $this->agencyDetails['SecurityKey']);
//echo "<pre>";print_r($SendWhatsapp);
// echo "<pre>";print_r($whatsappArray);
// exit;
$this->_redirect('flight/booking-confirmation/data/' . $param['data']);
}
} else {
die('FL');
$intGoingFlightId = $this->view->intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$intReturnFlightId = $this->view->intOutBoundId = !empty($arrUrlData['intInBoundId']) ? $arrUrlData['intInBoundId'] : 0;
$tripType = $this->view->tripType = !empty($arrUrlData['tripType']) ? $arrUrlData['tripType'] : 1;
$arrBookingResponse = $this->view->arrBookingResponse = isset($arrUrlData['arrBookingResponse']) ? json_decode($arrUrlData['arrBookingResponse'], true) : '';
if ($tripType == 2 && !$IsInterNational) {
$arrDepartBookingResponse = json_decode($arrBookingResponse[0], true);
$arrReturnBookingResponse = json_decode($arrBookingResponse[1], true);
$DepartErrorMessageAPI = isset($arrDepartBookingResponse['Response']['Error']['ErrorMessage']) ? $arrDepartBookingResponse['Response']['Error']['ErrorMessage'] : '';
$this->view->ErrorMessage = !empty($DepartErrorMessageAPI) ? $DepartErrorMessageAPI : '';
$this->view->PNR = $PNR = isset($arrDepartBookingResponse['Response']['Response']['PNR']) ? $arrDepartBookingResponse['Response']['Response']['PNR'] : '';
$this->view->BookingId = $BookingId = isset($arrDepartBookingResponse['Response']['Response']['BookingId']) ? $arrDepartBookingResponse['Response']['Response']['BookingId'] : '';
$ReturnErrorMessageAPI = isset($arrReturnBookingResponse['Response']['Error']['ErrorMessage']) ? $arrReturnBookingResponse['Response']['Error']['ErrorMessage'] : '';
$this->view->ReturnErrorMessage = !empty($ReturnErrorMessageAPI) ? $ReturnErrorMessageAPI : '';
$this->view->ReturnPNR = $PNR = isset($arrReturnBookingResponse['Response']['Response']['PNR']) ? $arrReturnBookingResponse['Response']['Response']['PNR'] : '';
$this->view->ReturnBookingId = $BookingId = isset($arrReturnBookingResponse['Response']['Response']['BookingId']) ? $arrReturnBookingResponse['Response']['Response']['BookingId'] : '';
$TraceId = isset($arrDepartBookingResponse['Response']['TraceId']) ? $arrDepartBookingResponse['Response']['TraceId'] : '';
if (!empty($TraceId)) {
$objFlight = new Travel_Model_TblFlight();
$objFlight->updateTraceIdExpired($TraceId);
}
} else if ($tripType == 2 && $IsInterNational) {
$arrDepartBookingResponse = $arrBookingResponse;
$DepartErrorMessageAPI = isset($arrDepartBookingResponse['Response']['Error']['ErrorMessage']) ? $arrDepartBookingResponse['Response']['Error']['ErrorMessage'] : '';
$this->view->ErrorMessage = !empty($DepartErrorMessageAPI) ? $DepartErrorMessageAPI : '';
$this->view->PNR = $PNR = isset($arrDepartBookingResponse['Response']['Response']['PNR']) ? $arrDepartBookingResponse['Response']['Response']['PNR'] : '';
$this->view->BookingId = $BookingId = isset($arrDepartBookingResponse['Response']['Response']['BookingId']) ? $arrDepartBookingResponse['Response']['Response']['BookingId'] : '';
$TraceId = isset($arrDepartBookingResponse['Response']['TraceId']) ? $arrDepartBookingResponse['Response']['TraceId'] : '';
if (!empty($TraceId)) {
$objFlight = new Travel_Model_TblFlight();
$objFlight->updateTraceIdExpired($TraceId);
}
} else {
$ErrorMessageAPI = isset($arrBookingResponse['Response']['Error']['ErrorMessage']) ? $arrBookingResponse['Response']['Error']['ErrorMessage'] : '';
$this->view->ErrorMessage = !empty($ErrorMessageAPI) ? $ErrorMessageAPI : (!empty($this->getRequest()->getParam('error_Message')) ? $this->getRequest()->getParam('error_Message') : '');
$this->view->PNR = $PNR = isset($arrBookingResponse['Response']['Response']['PNR']) ? $arrBookingResponse['Response']['Response']['PNR'] : '';
$this->view->BookingId = $BookingId = isset($arrBookingResponse['Response']['Response']['BookingId']) ? $arrBookingResponse['Response']['Response']['BookingId'] : '';
$TraceId = isset($arrBookingResponse['Response']['TraceId']) ? $arrBookingResponse['Response']['TraceId'] : '';
if (!empty($TraceId)) {
$objFlight = new Travel_Model_TblFlight();
$objFlight->updateTraceIdExpired($TraceId);
}
}
$this->view->TraceId = $TraceId;
$intCustomerSysId = !empty($arrUrlData['customerSysId']) ? $arrUrlData['customerSysId'] : (!empty($this->getRequest()->getParam('customerSysId')) ? $this->getRequest()->getParam('customerSysId') : 0);
$intTPSysId = $this->view->intTPSysId = !empty($arrUrlData['TPSysId']) ? $arrUrlData['TPSysId'] : (!empty($this->getRequest()->getParam('TPSysId')) ? $this->getRequest()->getParam('TPSysId') : 0);
$TrxSysId = $this->view->TrxSysId = !empty($arrUrlData['TrxSysId']) ? $arrUrlData['TrxSysId'] : (!empty($this->getRequest()->getParam('TrxSysId')) ? $this->getRequest()->getParam('TrxSysId') : 0);
$guid = $this->view->guid = !empty($arrUrlData['guid']) ? $arrUrlData['guid'] : (!empty($this->getRequest()->getParam('guid')) ? $this->getRequest()->getParam('guid') : '');
$arrTravelPlanAir = $objFlight->getTravelPlanAirData($intTPSysId);
$this->view->arrTravelPlanAir = $arrTravelPlanAir;
if (!empty($intCustomerSysId)) {
$objFlight = new Travel_Model_TblFlight();
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if (isset($intCustomerSysId) && !empty($intCustomerSysId) && $intCustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetsils = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$this->view->customerDetsils = $customerDetsils;
}
}
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
$this->view->arrSelectedFlightDetails = $arrSelectedFlightDetails;
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $intGoingFlightId . "','" . $intReturnFlightId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
$arrFlightFare = array();
if (!empty($arrSelectedFlightFareDetails)) {
$j = 0;
$i = 0;
$temp = "";
foreach ($arrSelectedFlightFareDetails as $value) {
$intTBQAirInvenAPISysId = trim($value['TBQAirInvenAPISysId']);
if (!empty($temp) && $temp != $intTBQAirInvenAPISysId) {
$i++;
$j = 0;
$temp = "";
}
if ($temp == "") {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
} else if ($temp == trim($value['TBQAirInvenAPISysId'])) {
$arrFlightFare[$i][$j]['TBQAirInvenAPISysId'] = $intTBQAirInvenAPISysId;
$arrFlightFare[$i][$j]['Currency'] = $value['Currency'];
$arrFlightFare[$i][$j]['PassengerType'] = $value['PassengerType'];
$arrFlightFare[$i][$j]['PassengerCount'] = $value['PassengerCount'];
$arrFlightFare[$i][$j]['BaseFare'] = $value['BaseFare'];
$arrFlightFare[$i][$j]['Tax'] = $value['Tax'];
$arrFlightFare[$i][$j]['YQTax'] = $value['YQTax'];
$arrFlightFare[$i][$j]['AdditionalTxnFeeOfrd'] = $value['AdditionalTxnFeeOfrd'];
$arrFlightFare[$i][$j]['AdditionalTxnFeePub'] = $value['AdditionalTxnFeePub'];
$temp = trim($value['TBQAirInvenAPISysId']);
}
$arrFlightFare[$i][$j]['OtherCharges'] = $value['OtherCharges'];
$arrFlightFare[$i][$j]['Discount'] = $value['Discount'];
$arrFlightFare[$i][$j]['ServiceFee'] = $value['ServiceFee'];
$arrFlightFare[$i][$j]['PublishedFare'] = $value['PublishedFare'];
$arrFlightFare[$i][$j]['CommissionEarned'] = $value['CommissionEarned'];
$arrFlightFare[$i][$j]['PLBEarned'] = $value['PLBEarned'];
$arrFlightFare[$i][$j]['IncentiveEarned'] = $value['IncentiveEarned'];
$arrFlightFare[$i][$j]['OfferedFare'] = $value['OfferedFare'];
$arrFlightFare[$i][$j]['TdsOnCommission'] = $value['TdsOnCommission'];
$arrFlightFare[$i][$j]['TdsOnPLB'] = $value['TdsOnPLB'];
$arrFlightFare[$i][$j]['TdsOnIncentive'] = $value['TdsOnIncentive'];
$j++;
}
}
$this->view->arrFlightFare = $arrFlightFare;
}
} else {
$this->_redirect('/');
}
$this->view->intFlightRoute = $infantCount = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$this->view->intAdultsCount = $adultCount = isset($sessionFlightSearchParams['adults']) ? $sessionFlightSearchParams['adults'] : 0;
$this->view->intChildrenCount = $childCount = isset($sessionFlightSearchParams['child']) ? $sessionFlightSearchParams['child'] : 0;
$this->view->intInfantCount = $infantCount = isset($sessionFlightSearchParams['infant']) ? $sessionFlightSearchParams['infant'] : 0;
$arrPaxCount = array(
'intAdultsCount' => $adultCount,
'intChildCount' => $childCount,
'intInfantCount' => $infantCount
);
$this->view->arrPaxCount = $arrPaxCount;
$this->view->AgencySysId = $this->intLoggedinAgencyId;
} else {
//echo "Please check post Data";
//exit;
}
}
public function payNowAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$Customer = new Zend_Session_Namespace('Customer');
$sessionFlightFareQuote = new Zend_Session_Namespace('sessionFlightFareQuote');
$CurrencyType = $sessionFlightFareQuote->response[0]['Fare']['Currency'];
$XRefTrxNo = 'GTE-' . rand(0, 1000);
$currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$insertBooking = array(
'AgencySysId' => $this->intLoggedinAgencyId, 'CustomerSysId' => $Customer->intCustomerSysId,
'XRefTrxNo' => $XRefTrxNo, 'MPSysId' => 0, 'InvoiceId' => '0', 'TrxOrdDocId' => '0', 'TrxDate' => $currentDate,
'TrxType' => '1', 'TrxPayMediaType' => '1', 'CrPartyAccSysId' => $this->intLoggedinAgencyId,
'DrPartyAccSysId' => $Customer->intCustomerSysId, 'CrPartyName' => 'Agent', 'DrPartyName' => 'Customer',
'CurrencyType' => $CurrencyType, 'Amount' => $sessionFlightFareQuote->response[0]['Fare']['PublishedFare'],
'TotalTax' => $sessionFlightFareQuote->response[0]['Fare']['Tax'], 'TotalDiscount' => $sessionFlightFareQuote->response[0]['Fare']['Discount'],
'NetAmount' => $sessionFlightFareQuote->response[0]['Fare']['PublishedFare'], 'PaidAmount' => $sessionFlightFareQuote->response[0]['Fare']['PublishedFare'],
'TBPoints' => 0, 'IsActive' => 1
);
// echo "<pre>";
// print_r($insertBooking); exit;
$objFlight = new Travel_Model_TblFlight();
$objFlight->booking($insertBooking);
$response = array('success' => true, 'XRefTrxNo' => base64_encode($XRefTrxNo), 'CustomerSysId' => $Customer->intCustomerSysId, 'AgencySysId' => $this->intLoggedinAgencyId);
echo json_encode($response);
exit;
}
}
public function showpopupAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
//$front->setParam('noViewRenderer', true);
$flightValues = $this->getRequest()->getParam('flightValues');
$flightcustomerId = $this->getRequest()->getParam('flightcustomerId');
$flightSearchType = $this->getRequest()->getParam('flightSearchType');
$tripType = $this->getRequest()->getParam('tripType');
$leadId = $this->getRequest()->getParam('leadId');
$isInternational = $this->getRequest()->getParam('isInternational');
//echo $flightdetails;
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ($flightValues) ";
$getflightData = $objFlight->getSelectedFlightDetails();
// $getflightData = $objFlight->getFlightSearchListForProposal($flightValues);
$this->_agencycustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = isset($flightcustomerId) ? $this->_agencycustomerObj->GetAgencyCustomerById($flightcustomerId) : '';
//echo "<pre>";print_r($customerDetails);die;
$this->view->flightDetails = $getflightData;
$this->view->flightcustomerId = $flightcustomerId;
$this->view->customerDetails = $customerDetails;
$this->view->flightSearchType = $flightSearchType;
$this->view->tripType = $tripType;
$this->view->leadId = $leadId;
$this->view->isInternational = $isInternational;
}
public function emailpreviewAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
//$front->setParam('noViewRenderer', true);
$flightValues = $this->getRequest()->getParam('flightValues');
$customer = $this->getRequest()->getParam('customer');
$tripType = $this->getRequest()->getParam('tripType');
$MarkupArray = json_decode($this->getRequest()->getParam('MarkupArray'));
$isInternational = $this->getRequest()->getParam('isInternational');
$objFlight = new Travel_Model_TblFlight();
if (isset($isInternational) && !empty($isInternational) && $isInternational == 1) {
$arrayValues = explode(',', str_replace("'", '', $flightValues));
$getflightData = $objFlight->getInterNationalFlightByMasterId($flightValues);
$this->view->arrayValues = $arrayValues;
$getflightDataArray = array();
foreach ($getflightData as $key => $value) {
$d = 0;
if (in_array($value['AirInvenSysId'], $arrayValues)) {
$getflightDataArray[$value['AirInvenSysId']][] = $getflightData[$key];
}
$d++;
}
$this->view->getflightDataArray = $getflightDataArray;
} else {
$objFlight->strCondition = " TBQAirInvenSysId IN ($flightValues) ";
$getflightData = $objFlight->getSelectedFlightDetails();
}
//$objFlight = new Travel_Model_TblFlight();
//$getflightData = $objFlight->getFlightSearchListForProposal($flightdetails);
//echo "<pre>";print_r($getflightData);die;
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$this->view->agencyDetails = $getAgencyDetail;
$this->view->flightDetails = $getflightData;
$this->view->MarkupArray = $MarkupArray;
$this->view->customer = $customer;
$this->view->tripType = $tripType;
$this->view->isInternational = $isInternational;
}
public function getSearchSupplierFlightAction() {
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$cityId = $this->getRequest()->getParam('cityId');
if ($cityId != "" && $cityId != "0") {
$searchSupplierSelect = '';
$objFlight = new Travel_Model_TblFlight();
$intSearchSupplierList = $objFlight->getSuppliersList($cityId, $this->intLoggedinUserId);
if (!empty($intSearchSupplierList)) {
$searchSupplierSelect = '<script src="public/assets/js/pages/selectAjaxTag.js"></script>';
$searchSupplierSelect .= '<select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option>';
foreach ($intSearchSupplierList as $intSearchSupplier) {
$searchSupplierSelect .= '<option value="' . $intSearchSupplier['SupplierSysId'] . '">' . $intSearchSupplier['SupplierName'] . '</option>';
}
$searchSupplierSelect .= '</select>';
} else {
$searchSupplierSelect = '<script src="public/assets/js/pages/selectAjaxTag.js"></script><select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option></select>';
}
} else {
$searchSupplierSelect = '<script src="public/assets/js/pages/selectAjaxTag.js"></script><select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option></select>';
}
echo $searchSupplierSelect;
exit;
}
}
// to refresh dynamic filter values
public function getNearByPriceAction() {
$this->_helper->layout->disableLayout();
$arrSearchedAirlinesPriceSlots = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getDynamicPriceSlots();
$this->view->arrSearchedAirlinesPriceSlots = $arrSearchedAirlinesPriceSlots;
$this->render('get-near-by-price');
}
public function getSearchedAirlinesAction() {
$this->_helper->layout->disableLayout();
$strAirlinesIds = trim($this->getRequest()->getParam('airlinesIds'));
$arrSearchedAirlines = Zend_Controller_Action_HelperBroker::getStaticHelper('Filters')->getAirLines($strAirlinesIds);
$this->view->arrSearchedAirlines = $arrSearchedAirlines;
$this->render('get-searched-airlines');
}
public function getSearchedPricerangeAction() {
$this->_helper->layout->disableLayout();
$this->render('get-searched-pricerange');
}
// to refresh dynamic filter values
public function addflightinvdataAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$objPackage = new Travel_Model_TblPackage();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$getData = $this->getRequest()->getPost();
$createddate = date('Y-m-d');
if ($getData['stopcount'] > 0) {
$isdirect = 0;
} else {
$isdirect = 0;
}
$localfromtime = $getData['departuretime'][0];
$deptime = date("Y-m-d h:i", strtotime($localfromtime));
$arrivaltime = date("Y-m-d h:i", strtotime($getData['arrivaltime'][0]));
$data = array(
"FlightNumber" => $getData['stopsflightnum'][0],
"AirlineSysId" => $getData['airlineID'][0],
"ICSourceSysId" => 0,
"IsFromAgency" => 1,
"LocalFromTime" => $deptime,
"LocalToTime" => $arrivaltime,
"FromUTCTime" => $deptime,
"ToUTCTime" => $arrivaltime,
"IsLCC" => 0,
"IsDirect" => $isdirect,
"DayLightSavingDiff" => 1,
"FlyingMinutes" => 0,
"FlightCabinClass" => 2,
"SourcePlaceSysId" => $getData['departurecitycode'][0],
"DestPlaceSysId" => $getData['arrivalcitycode'][0],
"SourceAirportCode" => $getData['departureapcode'][0],
"DestAirportCode" => $getData['arrivalapcode'][0],
"AirportHaultMinutes" => $getData['flymin'],
"StopCount" => $getData['stopcount'],
"Stops" => $getData['stopcount'],
"IsRefundable" => 1,
"FareClass" => 'U',
"TotalFlightMembers" => 0,
"CurrencyType" => 1,
"PublishedFare" => $getData['infantcost'] + $getData['adultcost'],
"CommissionEarned" => 255.90,
"apiTraceId" => '',
"ApiResultIndex" => '',
"JourneyType" => 0,
"TripType" => '',
"Rating" => 0,
"FllightFeatureMask" => 1,
"UpdatedByISSysId" => 1,
"CreatedByISSysId" => 1,
"ImageTN" => '',
"ImgForList" => '',
"ImgeDetails" => '',
"UpdateDate" => $createddate,
"CreateDate" => $createddate,
"ApproveBy" => 0,
"ApprovalDate" => $createddate,
"IsApproved" => 1,
"IsActive" => 1,
"IsMarkForDel" => 0
);
$updateId = $objPackage->insertData('TB_IC_Trans_Air', $data);
$stopcount = $getData['stopcount'];
if ($stopcount > 0) {
for ($i = $stopcount; $i <= $stopcount; $i++) {
$localfromtime = $getData['departuretime'][$stopcount];
$deptime = date("Y-m-d h:i", strtotime($localfromtime));
$arrivaltimestop = date("Y-m-d h:i", strtotime($getData['arrivaltime'][$stopcount]));
$stoparr = array(
"AirInvenSysId" => $updateId,
"SourcePlaceSysId" => $getData['departurecitycode'][$stopcount],
"Sequance" => $stopcount,
"DestPlaceSysId" => $getData['arrivalcitycode'][$stopcount],
"StayDuration" => 0,
"FlightDuration" => 0,
"AirlineCode" => $getData['airlineID'][$stopcount],
"AirlineName" => $getData['airline'][$stopcount],
"FlightNumber" => $getData['stopsflightnum'][$stopcount],
'FareClass' => 'U',
'OriginAirportCode' => $getData['departureapcode'][$stopcount],
'DestinationAirportCode' => $getData['arrivalapcode'][$stopcount],
'IsFlightChange' => '1',
'NewFInvenSysId' => 0,
'FlightCabinClass' => 2,
"IsRefundable" => 1,
"ArrivalTime" => $arrivaltimestop,
"DepartureTime" => $deptime,
"HaultInclusions" => '',
"CurrencyType" => 0,
"PublishedFare" => 0.00,
"CommissionEarned" => 0.00,
"CreateDate" => $createddate,
"UpdateDate" => $createddate,
"IsActive" => 1,
"IsMarkForDelete" => 0
);
$updateId = $objPackage->insertData('TB_IC_Trans_Air_Stop', $stoparr);
}
}
}
public function getairlinenamesearchAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
// print_r($this->getRequest()->getParam("term"));
// exit;
try {
$arrResponse = array();
if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
$term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
$objFlight = new Travel_Model_TblFlight();
$condCity = "tbl.Title like '" . $term . "%'";
$arrResponse = $objFlight->getAirlineName($condCity);
// print_r($arrResponse);die;
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function autosuggestAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
// print_r($this->getRequest()->getParam("term"));
// exit;
try {
$arrResponse = array();
if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
$term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
$objFlight = new Travel_Model_TblFlight();
$condCity = "tbl.Title like '" . $term . "%' OR AirportCode = '" . $term . "'";
$arrResponse = $objFlight->getAirPortAutoSuggest($condCity);
// print_r($arrResponse);die;
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function getCustomerDetailsAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$mobilNo = trim($this->getRequest()->getParam('mobilNo'));
$intMemberSysIdRequest = trim($this->getRequest()->getParam('intMemberSysId'));
if (!empty($mobilNo)) {
$objGest = new Travel_Model_Tbltbbcuser();
$result = $objGest->getCustomerAndMembersDetails($mobilNo);
$response = '';
if (!empty($result)) {
$customerDOB = (array) $result[0]['customerDOB'];
//echo "<pre>";print_r($result);exit;
$Customer['CustomerSysId'] = trim($result[0]['CustomerSysId']);
$Customer['CustomerRelation'] = trim($result[0]['customerRel']);
$Customer['CustomerTitle'] = trim($result[0]['Title']);
$Customer['CustomerFirstName'] = trim($result[0]['FirstName']);
$Customer['CustomerLastName'] = trim($result[0]['LastName']);
$Customer['CustomerEmailId'] = trim($result[0]['EmailId']);
$Customer['CustomerContacts'] = trim($result[0]['Contacts']);
$Customer['CustomerDOB'] = !empty($customerDOB['date']) ? trim($customerDOB['date']) : '';
$Customer['CustomerAddress'] = !empty($result[0]['customerAddress']) ? trim($result[0]['customerAddress']) : '';
$Customer['CustomerCitySysId'] = !empty($result[0]['customerCitySysId']) ? trim($result[0]['customerCitySysId']) : '';
if (!empty($result[0]['CustomerSysId'])) {
$response .= json_encode($Customer);
} else {
$response .= '0';
}
}
echo $response;
exit;
}
}
}
public function emailVoucherAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$emailId = trim($this->getRequest()->getParam('emailId'));
$FromName = trim($this->getRequest()->getParam('FromName'));
$FromEmail = trim($this->getRequest()->getParam('FromEmail'));
$bodyText = $this->getRequest()->getParam('bodyText');
if (empty($emailId)) {
$response = array('success' => false, 'msg' => 'Please enter Email ID.');
echo json_encode($response);
exit;
}
if (!filter_var($emailId, FILTER_VALIDATE_EMAIL)) {
$msg = "Email address is not valid.";
$response = array('success' => false, 'msg' => $msg);
echo json_encode($response);
exit;
}
$emailData = array('fromEmail' => $FromEmail, 'fromName' => $FromName, 'subject' => 'Flight Booking Voucher', 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
$emailResponse = json_decode($this->mailSentByElastice($emailData, $arrEmailStatistics), true);
try {
if ($emailResponse['success']) {
$msg = "Voucher Emailed successfully.";
$response = array('success' => true, 'msg' => $msg);
echo json_encode($response);
exit;
}
} catch (Exception $err) {
if ($mail->send($transport)) {
$msg = "Oops! there might be some technical issue, please try after some time.";
$response = array('success' => false, 'msg' => $msg);
echo json_encode($response);
exit;
}
}
}
}
//save search query. created by Er Amit Kumar Dubey on 20 june 2017 at 3:13 PM
public function saveFlightLeadAction() {
Zend_Session::namespaceUnset('sessionFlightSearchParams');
if ($this->_request->isXmlHttpRequest()) {
/* Disable Layout */
$SearchTraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getPost();
$offlinePropsal = isset($post['offlinePropsal']) ? $post['offlinePropsal'] : 0;
$forPackageSearch = isset($post['forPackageSearch']) ? $post['forPackageSearch'] : 0;
$leadsource = isset($post['lead_source']) ? $post['lead_source'] : 0;
// echo "<pre>";print_r($post);exit;
$route = $this->getRequest()->getPost('route');
$from = $this->getRequest()->getPost('from');
$to = $this->getRequest()->getPost('to');
$sourceCityText = $this->getRequest()->getPost('sourceCityText');
$destinationCityText = $this->getRequest()->getPost('destinationCityText');
$departure_dates = $this->getRequest()->getPost('departure_dates');
$adults = $this->getRequest()->getPost('adults');
$child = $this->getRequest()->getPost('child');
$infant = $this->getRequest()->getPost('infant');
$flight_class = $this->getRequest()->getPost('flight_class');
$return_dates = $this->getRequest()->getPost('return_dates');
$customerID = $this->getRequest()->getPost('customerID');
$IsOperationalLead = $this->getRequest()->getPost('IsOperationalLead') ? $this->getRequest()->getPost('IsOperationalLead') : 0;
$OpsAgentSysId = ($this->getRequest()->getPost('OpsAgentSysId') && $IsOperationalLead == 1) ? $this->getRequest()->getPost('OpsAgentSysId') : '';
$ExpectedClosureDate = $this->getRequest()->getPost('ExpectedClosureDate');
$ExpectedValue = $this->getRequest()->getPost('ExpectedValue');
if ($offlinePropsal == 1) {
$customerID = base64_decode($customerID);
}
$flightSearchType = $this->getRequest()->getPost('flightSearchType');
$editLeadId = $this->getRequest()->getPost('editLeadId');
$currentOwnerSysId = $this->getRequest()->getPost('currentOwnerSysId');
$countrySysId = (NULL !== $this->getRequest()->getPost('ContSysId')) ? $this->getRequest()->getPost('ContSysId') : '';
$SourceCountrySysId = (NULL !== $this->getRequest()->getPost('SourceContSysId')) ? $this->getRequest()->getPost('SourceContSysId') : '';
$leadRemark = (NULL !== $this->getRequest()->getPost('leadRemark')) ? $this->getRequest()->getPost('leadRemark') : '';
$crmcustomerObj = new Travel_Model_CRM_Customer();
$GetCustomerData = $crmcustomerObj->GetCustomerWithDetails($customerID);
$roomjson = array();
$childcount = $child;
$roomjson[1]['route'] = $route;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
$roomjson[1]['Infant'] = $infant;
$roomjson[1]['ChildAge_1'] = $infant;
$roomjson[1]['departuredate'] = $departure_dates;
$roomjson[1]['returndate'] = $return_dates;
$roomjson[1]['fromaircode'] = $from;
$roomjson[1]['toaircode'] = $to;
$roomjson[1]['airclass'] = $flight_class;
$RoomInfoJson = json_encode($roomjson);
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$sessionFlightSearchParams->params = $post; // Putting all form data to Session
// echo "<pre>";print_r($GetCustomerData);exit;
$Cities__ = [];
if ($route == 3) {
$departure_dates = $departure_dates[0];
$intCountryCode = [];
$intSourceCityId = [];
$intDestinationCityId = [];
$intOriginCountryCode = 'IN';
$intDestinationCountryCode = 'IN';
if ($from) {
foreach ($from as $key => $value) {
$string = isset($sourceCityText[$key]) ? $sourceCityText[$key] : '';
$sourceCityText__ = substr($string, 0, strpos($string, ','));
$string2 = isset($destinationCityText[$key]) ? $destinationCityText[$key] : '';
$destinationCityText__ = substr($string2, 0, strpos($string2, ','));
$Cities__[] = $sourceCityText__ . '-' . $destinationCityText__;
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $value;
$arrSourceCityId = $objAirport->getAirportList();
if (!empty($arrSourceCityId)) {
$intSourceCityId[] = $arrSourceCityId[0]['CityId'];
$intCountryCode[] = $arrSourceCityId[0]['CountryCode'];
if (trim($arrSourceCityId[0]['CountryCode']) != 'IN') {
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
}
} else {
$intSourceCityId = [];
$intCountryCode = [];
}
$objAirport->strAirportCode = isset($to[$key]) ? $to[$key] : '';
$arrDestinationCityId = $objAirport->getAirportList();
if (!empty($arrDestinationCityId)) {
$intDestinationCityId[] = $arrDestinationCityId[0]['CityId'];
if (trim($arrDestinationCityId[0]['CountryCode']) != 'IN') {
$intDestinationCountryCode = trim($arrDestinationCityId[0]['CountryCode']);
}
} else {
$intDestinationCityId = [];
}
}
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else if ($intDestinationCountryCode != "IN" || empty($intDestinationCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else {
$sessionFlightSearchParams->params['interNationalSearch'] = false;
}
// echo "<pre>";print_r($intOriginCountryCode);
// echo "<pre>";print_r($intDestinationCountryCode);
// echo "<pre>";print_r($intSourceCityId);
// echo "<pre>";print_r($intDestinationCityId);
// echo "<pre>";print_r($Cities__);
// echo "<pre>";print_r($post);
// die;
} else {
if (empty($from)) {
$response = array('success' => false, 'msg' => 'Please select source city.');
echo json_encode($response);
exit;
}
if (empty($to)) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if ($from == $to) {
$response = array('success' => false, 'msg' => 'The \'Departure City\' and \'Destination City\' cannot be same. Please re-type.');
echo json_encode($response);
exit;
}
if (empty($departure_dates) || trim($departure_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select departure date');
echo json_encode($response);
exit;
}
if ($route == 2) {
if (empty($return_dates) || trim($return_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select return date');
echo json_encode($response);
exit;
}
}
if (empty($adults)) {
$response = array('success' => false, 'msg' => 'Please select the number of adults.');
echo json_encode($response);
exit;
}
if (empty($flight_class)) {
$response = array('success' => false, 'msg' => 'Please select the class.');
echo json_encode($response);
exit;
}
}
//echo "<pre>";print_r($post);exit;
if (!empty($departure_dates)) {
$arrDepatureDate = explode("/", $departure_dates);
if (!empty($arrDepatureDate) > 0) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
}
}
if (!empty($return_dates)) {
$arrReturnDepatureDate = explode("/", $return_dates);
if (!empty($arrReturnDepatureDate)) {
$strReturnDate = $arrReturnDepatureDate[2] . "-" . $arrReturnDepatureDate[1] . "-" . $arrReturnDepatureDate[0];
}
}
if (empty((int) $leadsource)) {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($this->intLoggedinAgencyId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$TCurrencyType = trim($this->agencyDetails['TrxCurrency']);
$FCurrencyType = 1;
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getCurrencyRate($FCurrencyType, $TCurrencyType, $this->intLoggedinAgencyId);
$CurrencyRate = isset($apiResponse['Rate']) ? $apiResponse['Rate'] : 1;
$CurrencyTitle = isset($apiResponse['Symbol']) ? $apiResponse['Symbol'] : 'INR';
$CurrencyId = isset($apiResponse['CurrencyId']) ? $apiResponse['CurrencyId'] : 1;
// echo "<pre>"; print_r($apiResponse); exit;
$sessionFlightSearchParams->params['MasterAgencySysId'] = $this->intLoggedinAgencyId;
$sessionFlightSearchParams->params['AgencySysId'] = $GetCustomerData['AgencySysId'];
$sessionFlightSearchParams->params['CustomerSysId'] = $GetCustomerData['CustomerSysId'];
$sessionFlightSearchParams->params['UserSysId'] = $GetCustomerData['UserSysId'];
$sessionFlightSearchParams->params['B2BType'] = $GetCustomerData['IsB2BAgent'];
$sessionFlightSearchParams->params['CurrencyRate'] = $CurrencyRate;
$sessionFlightSearchParams->params['CurrencyTitle'] = $CurrencyTitle;
$sessionFlightSearchParams->params['CurrencyId'] = $CurrencyId;
$sessionFlightSearchParams->params['SearchTraceId'] = $SearchTraceId;
$sessionFlightSearchParams->params['sourceCityAirportCode'] = $from;
$sessionFlightSearchParams->params['destinationCityAirportCode'] = $to;
$sessionFlightSearchParams->params['sourceCityText'] = $sourceCityText;
$sessionFlightSearchParams->params['destinationCityText'] = $destinationCityText;
$sessionFlightSearchParams->params['lead_source'] = $leadsource;
if ($route == 3) {
$departure_dates = $departure_dates[0];
$intSourceCityId = $intSourceCityId[0];
$intDestinationCityId = $intDestinationCityId[0];
$sourceCityText = $sourceCityText[0];
$destinationCityText = $destinationCityText[0];
$from = $from[0];
$to = $to[0];
$countrySysId = $countrySysId[0];
} else {
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $from;
$arrSourceCityId = $objAirport->getAirportList();
if (!empty($arrSourceCityId)) {
$intSourceCityId = $arrSourceCityId[0]['CityId'];
$intCountryCode = $arrSourceCityId[0]['CountryCode'];
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
} else {
$intSourceCityId = "";
$intCountryCode = "";
}
$objAirport->strAirportCode = $to;
$arrDestinationCityId = $objAirport->getAirportList();
if (!empty($arrDestinationCityId)) {
$intDestinationCityId = $arrDestinationCityId[0]['CityId'];
$intDestinationCountryCode = trim($arrDestinationCityId[0]['CountryCode']);
} else {
$intDestinationCityId = "";
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else if ($intDestinationCountryCode != "IN" || empty($intDestinationCountryCode)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
} else {
$sessionFlightSearchParams->params['interNationalSearch'] = false;
}
}
$sessionFlightSearchParams->params['sourceCityId'] = $intSourceCityId;
$sessionFlightSearchParams->params['destinationCityId'] = $intDestinationCityId;
$sessionFlightSearchParams->params['customerID'] = $customerID;
$sessionFlightSearchParams->params['flightSearchType'] = $flightSearchType;
$sessionFlightSearchParams->params['editLeadId'] = $editLeadId;
$sessionFlightSearchParams->params['currentOwnerSysId'] = (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $this->intLoggedinUserId;
$sessionFlightSearchParams->params['intCountryCode'] = $intCountryCode;
if ($offlinePropsal == 1) {
$sessionFlightSearchParams->params['bookingAllowed'] = 2;
}
// echo "<pre>";print_r($sessionFlightSearchParams->params);exit;
if ($forPackageSearch == 1) {
$arrUrlData['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
$tempData = array(
'TPSysId' => $editLeadId,
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight = new Travel_Model_TblFlight();
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
$response = array('success' => true, 'SearchTraceId' => $SearchTraceId, 'leadEncodeId' => '', 'SearchParams' => $sessionFlightSearchParams->params);
echo json_encode($response);
exit;
}
/* $sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->leadID = '';
$sessionLogin_lead_customer->FirstName = '';
$sessionLogin_lead_customer->EmailId = ''; */
//create search history for query created by Er Amit Kumar Dubey on 12 april 2017 at 10:52 PM
$createDate = date('Y-m-d H:i:s');
$historyData = array(
'TPSysId' => '',
'AgencySysId' => $this->intLoggedinAgencyId,
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $customerID,
'PlanType' => 1,
'SourcePlaces' => isset($sourceCityText) ? trim($sourceCityText) : '',
'SourcePlaceSysId' => isset($intSourceCityId) ? $intSourceCityId : '',
'DestinationPlaces' => isset($destinationCityText) ? trim($destinationCityText) : '',
'DestinationPlaceSysId' => isset($intDestinationCityId) ? $intDestinationCityId : '',
'PackTypeMask' => '',
'InclusionMark' => '',
'Rooms' => 0,
'TotAdultCount' => $adults,
'TotChildCount' => $child,
'TotInfantCount' => $infant,
'PriceRangeFrom' => '',
'PriceRangeTo' => '',
'AdditionalSrvMark' => '',
'StartDate' => isset($strDepatureDate) ? $strDepatureDate : $createDate,
'ValidTill' => isset($strReturnDate) ? $strReturnDate : $createDate,
'Rating' => $flight_class,
"SearchDate" => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
//echo "<pre>"; print_r($historyData);die;
$this->_crmcusttravelplanhistory = new Travel_Model_CRM_CustomerTravelPlanSearchHistory();
$this->_crmcusttravelplanhistory->addCustomerTravelPlanSearchHistory($historyData);
//end of create search history
//start for customer profile history data
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$checkrecord = $custtravelhistoryObj->getCustomerTravelHistoryForCity($customerID, $this->intLoggedinAgencyId, $intDestinationCityId);
if (count($checkrecord) == 0) {
$customerHistoryArray = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $customerID,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => isset($strDepatureDate) ? $strDepatureDate : $createDate,
'ContSysId' => $countrySysId ? $countrySysId : '',
'CitySysId' => isset($intDestinationCityId) ? $intDestinationCityId : '',
'PlanType' => 1,
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => '0'
);
// print_r($customerHistoryArray);die;
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
}
//#end of customer profile data
//insert query
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
if ($customerID > 0) {
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($customerID);
}
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
//update crm lead account record when created new query
if ($customerDetails['AgencyCRMLeadSysId']) {
$userleadAccountArray = array(
'LeadStageSysId' => 50, //50 id for change status in create query for crm lead account table
'UpdatedDate' => $createDate,
);
$whereleadAccount = "AgencyCRMLeadSysId = " . $customerDetails['AgencyCRMLeadSysId'];
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$customercrmRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userleadAccountArray, $whereleadAccount);
}
//#end of record
//deleted previous quey
$createNewQuery = (NULL != $this->getRequest()->getPost('createNewQuery')) ? $this->getRequest()->getPost('createNewQuery') : '';
$NewQueryLeadHiddenId = (NULL != $this->getRequest()->getPost('NewQueryLeadHiddenId')) ? trim($this->getRequest()->getPost('NewQueryLeadHiddenId')) : '';
//echo $createNewQuery."/".$NewQueryLeadHiddenId;
if (($NewQueryLeadHiddenId != "") && ($createNewQuery == 'false')) {
// if(($NewQueryLeadHiddenId !="")){
$where = "TPSysId = " . $NewQueryLeadHiddenId;
$updatetravelplan = array(
"IsMarkForDel" => true,
'IsActive' => False
);
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplan, $where);
}
//#end
$planbookingID = 'Q/' . date('y');
$data = array(
'PlanBookingId' => $planbookingID,
'StatusType' => 1,
'CustomerSysId' => $customerID,
'AdditionalReq' => '',
'PlanType' => 1,
'InventoryType' => 1,
'TemplatePckSysId' => !empty($editLeadId) ? trim($editLeadId) : 0,
'CurrencyType' => 0,
'LeadSourceSysId' => $leadsource,
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => isset($cardcharges) ? $cardcharges : '',
'SourcePlaceSysId' => isset($intSourceCityId) ? $intSourceCityId : '',
'DestinationPlacesSysId' => isset($intDestinationCityId) ? $intDestinationCityId : '',
'SourcePlaces' => isset($sourceCityText) ? trim($sourceCityText) : '',
'DestinationPlaces' => isset($destinationCityText) ? trim($destinationCityText) : '',
'Cities' => trim($sourceCityText) . "," . trim($destinationCityText),
'CreatorSysId' => $this->intLoggedinUserId,
'AgencySysId' => $this->intLoggedinAgencyId,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $this->intLoggedinUserId,
'SupplierSysId' => 0,
'IsHotelFromApi' => 0,
'CreateDate' => $createDate,
'StartDate' => isset($strDepatureDate) ? $strDepatureDate : '',
'ValidTill' => isset($strReturnDate) ? $strReturnDate : '',
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($IsB2BCustomer),
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
);
if ($route == 3) {
$data['Cities'] = implode(',', $Cities__);
}
// echo '<pre>';
// print_r($data);
########### Start Add Data in Travel Table(Base Table) ###################
if (isset($editLeadId) && !empty($editLeadId)) {
$leadID = $editLeadId;
} else {
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
}
//comment for save again search data
//$leadID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
$sessionFlightSearchParams->params['editLeadId'] = $leadID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $this->intLoggedinAgencyId,
'StartDate' => $createDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$this->_crmcustomertravelItenary = new Travel_Model_CRM_CustomerTravelItenary();
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
$getData = [
'ExpectedClosureDate'=> $ExpectedClosureDate,
'ExpectedValue'=> $ExpectedValue,
];
$ClosureData = $this->_crmcusttravelplan->expectedClosureData($leadID, $getData);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
$airData = array(
'TPIntSysId' => $lasttravelitenaryID,
'AgencySysId' => $this->intLoggedinAgencyId,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'AdultPax' => $adults,
'FlightCabinClass' => '',
'LocalFromTime' => isset($strDepatureDate) ? $strDepatureDate : '',
'LocalToTime' => isset($strReturnDate) ? $strReturnDate : '',
'ChildPax' => $child,
'InfentPax' => $infant,
'SourceAirportCode' => $from,
'DestAirportCode' => $to,
'SupplierSysId' => 3,
'TripType' => $route,
'ICSourceSysId' => 3,
'IsFromAPI' => 1,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1
);
// echo "<pre>"; print_r($airData);
$this->_crmcusttravelplanAir = new Travel_Model_CRM_CustomerTravelPlanAir();
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
// echo "<pre>"; print_r($lastairID);
// die;
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $this->intLoggedinAgencyId,
'CustomerSysId' => $customerID,
'AgentSysId' => $this->intLoggedinUserId,
'Remarks' => $leadRemark,
'TPSysId' => $leadID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
// echo "<pre>";print_r($sessionFlightSearchParams->params);exit;
//#end of insert query
if (isset($lastairID) && !empty($lastairID)) {
if ($offlinePropsal == 1) {
$arrUrlData['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
$tempData = array(
'TPSysId' => $leadID,
'TraceId' => $SearchTraceId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight = new Travel_Model_TblFlight();
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
}
$response = array('success' => true, 'editLeadId' => $leadID, 'leadEncodeId' => base64_encode($leadID));
} else {
$response = array('success' => false);
}
echo json_encode($response);
exit;
}
}
public function pageNotFoundAction() {
$this->view->error = "Oops! The Page you requested was not found!";
}
public function paymentFailedAction() {
$this->view->error = "Oops! Payment has been failed! Please contact administrator for more information.";
$strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$this->view->TrxSysId = $arrUrlData['TrxSysId'];
$this->view->guid = $arrUrlData['guid'];
}
public function bookRoundTripFlightsAction() {
$strUrlData = $this->getRequest()->getParam('strUrlData');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$intOutBoundId = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$intInBoundId = !empty($arrUrlData['intInBoundId']) ? $arrUrlData['intInBoundId'] : 0;
$intCustomerSysId = !empty($arrUrlData['intCustomerSysId']) ? $arrUrlData['intCustomerSysId'] : 0;
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ('" . $intOutBoundId . "','" . $intInBoundId . "') ";
$arrSelectedFlightDetails = $objFlight->getSelectedFlightDetails();
if (!empty($arrSelectedFlightDetails)) {
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
}
$request = [];
$i = 0;
foreach ($arrSelectedFlightDetails as $result) {
$AirInvenSysId = trim($result['AirInvenSysId']);
$apiTraceId = trim($result['apiTraceId']);
$ApiResultIndex = trim($result['ApiResultIndex']);
$SourceAirportCode = trim($result['SourceAirportCode']);
$DestAirportCode = trim($result['DestAirportCode']);
$IsLCC = trim($result['IsLCC']);
$JourneyType = trim($result['JourneyType']);
$TripType = trim($result['TripType']);
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $AirInvenSysId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$data = [
"TraceId" => $apiTraceId,
"ResultIndex" => $ApiResultIndex,
"Origin" => $SourceAirportCode,
"Destination" => $DestAirportCode,
"JourneyType" => $JourneyType,
"TripType" => $TripType,
"IsLCC" => $IsLCC,
"arrFairDetails" => $arrSelectedFlightFareDetails,
"arrTrevllerDetails" => $arrTrevllerDetails,
"agencyEmailId" => $this->intLoggedinUserEmailId,
"getAgencyDetail" => $getAgencyDetail
];
$requestData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateRoundTripRequest($data, $IsLCC);
if ($IsLCC) {
$request[$i]['url'] = FLIGHT_API_TICKET_URL;
} else {
$request[$i]['url'] = FLIGHT_API_BOOKING_URL;
}
$request[$i]['post'] = $requestData;
$i++;
}
$response = $this->multiRequest($request);
} else {
// Error
}
return $response;
}
public function multiRequest($data, $options = array()) {
// array of curl handles
$curly = array();
// data to be returned
$result = array();
// multi handle
$mh = curl_multi_init();
// loop through $data and create curl handles
// then add them to the multi-handle
foreach ($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
curl_setopt($curly[$id], CURLOPT_ENCODING, "gzip");
curl_setopt($curly[$id], CURLOPT_URL, $url);
curl_setopt($curly[$id], CURLOPT_HEADER, 0);
curl_setopt($curly[$id], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
// post?
if (is_array($d)) {
if (!empty($d['post'])) {
$data_stringh = json_encode($d['post']);
curl_setopt($curly[$id], CURLOPT_POST, true);
curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($curly[$id], CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
}
}
if (!empty($options)) {
curl_setopt_array($curly[$id], $options);
}
curl_multi_add_handle($mh, $curly[$id]);
}
// execute the handles
$running = null;
do {
curl_multi_exec($mh, $running);
} while ($running > 0);
// get content and remove handles
foreach ($curly as $id => $c) {
$result[$id] = curl_multi_getcontent($c);
curl_multi_remove_handle($mh, $c);
}
// all done
curl_multi_close($mh);
return $result;
}
public function multiRequestTJ($data, $options = array()) {
// array of curl handles
$curly = array();
// data to be returned
$result = array();
// multi handle
$mh = curl_multi_init();
// loop through $data and create curl handles
// then add them to the multi-handle
foreach ($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
echo '<pre>';
print_r($url);
curl_setopt($curly[$id], CURLOPT_ENCODING, "gzip");
curl_setopt($curly[$id], CURLOPT_URL, $url);
curl_setopt($curly[$id], CURLOPT_HEADER, 0);
curl_setopt($curly[$id], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
// post?
if (is_array($d)) {
if (!empty($d['post'])) {
$data_stringh = json_encode($d['post']);
echo '<pre>';
print_r($data_stringh);
curl_setopt($curly[$id], CURLOPT_POST, true);
curl_setopt($curly[$id], 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)
));
}
}
if (!empty($options)) {
curl_setopt_array($curly[$id], $options);
}
curl_multi_add_handle($mh, $curly[$id]);
}
// execute the handles
$running = null;
do {
curl_multi_exec($mh, $running);
} while ($running > 0);
// get content and remove handles
foreach ($curly as $id => $c) {
$result[$id] = curl_multi_getcontent($c);
curl_multi_remove_handle($mh, $c);
}
// all done
curl_multi_close($mh);
return $result;
}
public function generateNonLccTicketAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$post = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$strUrlData = $TrackId = $this->getRequest()->getParam('TrackId');
$FlightTempData = $objFlight->GetFlightTempData($strUrlData);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$intTPSysId = !empty($arrUrlData['intTPSysId']) ? $arrUrlData['intTPSysId'] : 0;
$intOutBoundId = $BookingData = !empty($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : 0;
$arrBookingResponse = $BookingData = !empty($arrUrlData['arrBookingResponse']) ? json_decode($arrUrlData['arrBookingResponse'], true) : 0;
$arrIntTpAirId = $arrUrlData['arrIntTpAirId'];
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$TravelArray = [];
if ($arrTrevllerList) {
foreach ($arrTrevllerList as $KT => $travel) {
$TravelArray[$travel['IsReturn']][$KT] = $travel;
}
}
$TrevllerList = array_map('array_values', $TravelArray);
if ($arrBookingResponse) {
$FlightBookingTicketArr = [];
foreach ($arrBookingResponse as $k => $response) {
$TPintSysId = $arrIntTpAirId[$k];
$value = isset($BookingData[$k]) ? $BookingData[$k] : '';
$ResponseStatus = isset($response['Response']['ResponseStatus']) ? $response['Response']['ResponseStatus'] : '0';
$apiTraceId = isset($response['Response']['TraceId']) ? $response['Response']['TraceId'] : '0';
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingIdLCC = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNRLCC = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
if ($ResponseStatus == 1) {
$data = [
"TraceId" => $apiTraceId,
"PNR" => $strTicketPNRLCC,
"BookingId" => $strBookingIdLCC
];
$strJsonResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($data, $this->intLoggedinAgencyId);
$responses = json_decode($strJsonResponse, true);
//$generateNonLccTicket = new Zend_Session_Namespace('generateNonLccTicket');
//$responses = $generateNonLccTicket->params;
$FlightBookingTicketArr[$k] = $responses;
$ErrorCode = isset($responses['Response']['Error']['ErrorCode']) ? $responses['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($responses['Response']['Error']['ErrorMessage']) ? $responses['Response']['Error']['ErrorMessage'] : '';
$strBookingId = isset($responses['Response']['Response']['BookingId']) ? $responses['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($responses['Response']['Response']['PNR']) ? $responses['Response']['Response']['PNR'] : '';
$TicketStatus = isset($responses['Response']['Response']['TicketStatus']) ? $responses['Response']['Response']['TicketStatus'] : '';
$Passenger = isset($responses['Response']['Response']['FlightItinerary']['Passenger']) ? $responses['Response']['Response']['FlightItinerary']['Passenger'] : '';
$Message = isset($responses['Response']['Response']['Message']) ? $responses['Response']['Response']['Message'] : '';
$AirlineRefPNR = (isset($responses['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) && !empty($responses['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) ? $responses['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR'] : '');
if ($ErrorCode == 0 && $TicketStatus == 1) {
$responseArray = array(
'value' => $value,
'response' => $responses
);
$UpdateData = array(
"AirlineRefPNR" => $strTicketPNR,
"XRefBookingId" => $strBookingId,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
$objFlight->updateBookingDetails($UpdateData, $TPintSysId);
if (isset($TrevllerList[$k]) && !empty($TrevllerList[$k]) && $TicketStatus == 1) {
foreach ($TrevllerList[$k] as $key => $value) {
$pax = $Passenger[$key];
$TicketId = $pax['Ticket']['TicketId'];
$TicketNumber = $pax['Ticket']['TicketNumber'];
$dataPax = array(
"TicketId" => !empty($TicketId) ? $TicketId : '',
"TicketNumber" => $TicketNumber,
"TicketFullJson" => json_encode($pax)
);
$objFlight->updateTravelPlanPax($dataPax, $value['TPPaxSysId']); // FOR TRAVELLERS DETAILS CONFIRMED
}
}
}
}
}
$arrUrlData['arrBookingResponse'] = json_encode($FlightBookingTicketArr);
$strUrlData = $arrUrlData['urlData'];
//echo "<pre>";print_r($arrUrlData);exit;
$tempData = array(
'TPSysId' => $intTPSysId,
'TraceId' => $TrackId,
'APIBookingData' => json_encode($arrUrlData),
);
$objFlight->deleteFlightTempData($TrackId);
$objFlight->insertFlightTempData($tempData);
$response = array('success' => true, 'TrackId' => $TrackId, 'msg' => 'Flight is confirmed Successfully. Please check your inbox for flight Itinerary.', 'IsLCC' => $IsLCC, 'urlData' => $strUrlData, 'formAction' => "/flight/booking-confirmation/data/" . $TrackId . "?status=true");
echo json_encode($response);
exit;
}
echo "<pre>==";
print_r($arrBookingResponse);
echo "<pre>";
print_r($arrUrlData);
exit;
$TraceId = $this->getRequest()->getParam('TraceId');
$BookingId = $this->getRequest()->getParam('BookingId');
$PNR = $this->getRequest()->getParam('PNR');
$TPSysId = $this->getRequest()->getParam('TPSysId');
$TicketFor = $this->getRequest()->getParam('TicketFor');
$CustomerEmailId = $this->getRequest()->getParam('CustomerEmailId');
$IsReturn = $this->getRequest()->getParam('IsReturn');
$AirVersionId = $this->getRequest()->getParam('AirVersionId');
$AirVersionId = isset($AirVersionId) ? $AirVersionId : 0;
$arrTravelPlanAir = $objFlight->getTravelPlanAirData($TPSysId, $AirVersionId);
$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking($TPSysId, $IsReturn);
$VersionId = isset($arrTravelPlanAir[$TicketFor]['VersionId']) ? $arrTravelPlanAir[$TicketFor]['VersionId'] : '';
//$VersionId = $AirVersionId;
$SourceAirportCode = isset($arrTravelPlanAir[$TicketFor]['SourceAirportCode']) ? $arrTravelPlanAir[$TicketFor]['SourceAirportCode'] : '';
$DestAirportCode = isset($arrTravelPlanAir[$TicketFor]['DestAirportCode']) ? $arrTravelPlanAir[$TicketFor]['DestAirportCode'] : '';
if (!empty($VersionId)) {
$data = [
"TraceId" => $TraceId,
"PNR" => $PNR,
"BookingId" => $BookingId
];
$strJsonResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->generateNonLccTicket($data, $this->intLoggedinAgencyId);
$response = json_decode($strJsonResponse, true);
//echo "<pre>";print_r($response);exit;
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingId = isset($response['Response']['Response']['BookingId']) ? $response['Response']['Response']['BookingId'] : '';
$strTicketPNR = isset($response['Response']['Response']['PNR']) ? $response['Response']['Response']['PNR'] : '';
$TicketStatus = isset($response['Response']['Response']['TicketStatus']) ? $response['Response']['Response']['TicketStatus'] : '';
$Passenger = isset($response['Response']['Response']['FlightItinerary']['Passenger']) ? $response['Response']['Response']['FlightItinerary']['Passenger'] : '';
$Message = isset($response['Response']['Response']['Message']) ? $response['Response']['Response']['Message'] : '';
$AirlineRefPNR = (isset($response['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) && !empty($response['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) ? $response['Response']['Response']['FlightItinerary']['Segments'][0]['AirlinePNR'] : '');
if ($ErrorCode == 0 && $TicketStatus == 1) {
$data = array(
"XRefBookingId" => $strBookingId . "/" . $strTicketPNR,
"APIBookingRes" => json_encode($response),
"XRefPNR" => 1,
"IsBookingStatus" => 1,
"AirlineRefPNR" => $AirlineRefPNR
);
$responseArray = array(
'value' => $value,
'response' => $response
);
$data = array(
"AirlineRefPNR" => $strTicketPNRLCC,
"XRefBookingId" => $strBookingIdLCC,
"APIBookingRes" => json_encode($responseArray),
"XRefPNR" => 1,
"IsBookingStatus" => 1
);
//echo "<pre>";print_r($data);exit;
$objFlight->updateBookingDetails($data, $VersionId); // FOR Ticket CONFIRMED
if (isset($arrTrevllerList) && !empty($arrTrevllerList)) {
foreach ($arrTrevllerList as $key => $value) {
if (isset($Passenger[$key]['Ticket'])) {
$Ticket = $Passenger[$key]['Ticket'];
$data = array(
"TicketId" => $Ticket['TicketId'],
"TicketNumber" => $Ticket['TicketNumber'],
"TicketFullJson" => json_encode($Passenger[$key])
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
}
//Mail Booking Itenary To Customer
$objFlight = new Travel_Model_TblFlight();
$arrFlightFare = $objFlight->customerInvoiceData($TPSysId);
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $TPSysId);
}
//echo '<pre>';print_r($arrFlightFare);echo '</pre>';die;
if ($arrFlightFare) {
foreach ($arrFlightFare as $k => $values) {
$arrtravellerList = $objFlight->travellerListBySabir($TPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($TPSysId, $values['AirVersionId']);
//echo '<pre>';print_r($arrCustomerInvoiceData);echo '</pre>';
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetailsNew = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $TPSysId);
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
$html->assign('type', 'mailToCustomer');
$html->assign('arrResponse', $response);
$html->assign('arrTrevllerDetails', $arrTrevllerDetailsNew);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$bodyText = $html->render('mail-booking-content-new.phtml');
$subject = "Flight Booking Itinerary From " . $SourceAirportCode . " To " . $DestAirportCode;
$customerEmailId = isset($arrTrevllerDetailsNew[0][0]['EmailId']) ? $arrTrevllerDetailsNew[0][0]['EmailId'] : '';
$emailData = array('fromEmail' => trim($this->intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $this->intLoggedinUserEmailId, "gaurav@hellogtx.com", "prashant@catpl.co.in"), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $TPSysId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics);
} catch (Exception $err) {
print_r($err, true);
}
}
}
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// $crmcustomerObj = new Travel_Model_CRM_Customer();
// $arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($this->intLoggedinAgencyId);
// $html->assign('type', 'mailToCustomer');
// $html->assign('arrResponse', $response);
// $html->assign('arrAgencyDetail', $arrAgencyDetail);
// $html->assign('arrFlightFare', $arrFlightFare[0]);
// $bodyText = $html->render('mail-booking-content.phtml');
// $subject = "Flight Booking Itinerary From ".$SourceAirportCode." To ".$DestAirportCode;
// $emailData = array('fromEmail'=>trim($this->intLoggedinUserEmailId),'fromName'=>trim($arrAgencyDetail['DisplayName']),'subject'=> $subject,'to'=>array($CustomerEmailId,$this->intLoggedinUserEmailId,"gaurav@hellogtx.com","prashant@catpl.co.in"),'bodyHtml'=>$bodyText,'bodyText'=>'');
// try {
// // Added By Pardeep Panchal For Email Count...
// $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
// $arrEmailStatistics = array(
// "TPSysId" => $TPSysId,
// "TypeSysId" => 1, // 1 For Email 2 For SMS
// "AgencySysId" => $this->intLoggedinAgencyId,
// "AgentSysId" => $this->intLoggedinUserId,
// "Title" => $subject,
// "Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
// "Status" => 0,
// "RefSysId" => "",
// "RefSysStatus" => "",
// "CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
// );
//
// // Added By Pardeep Panchal For Email Count Ends...
// $this->mailSentByElastice($emailData,$arrEmailStatistics);
// } catch (Exception $err) {
// print_r($err, true);
// }
//Mail Booking Itenary To Customer
$response = array('success' => true, 'msg' => 'Flight is confirmed Successfully. Please check your inbox for flight Itinerary.');
echo json_encode($response);
exit;
} elseif ($ErrorCode == 0 && $TicketStatus == 4) {
$data = [
"TraceId" => $TraceId,
"PNR" => $PNR,
"BookingId" => $BookingId
];
$strJsonResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetFlightBookingDetails($data);
$response = json_decode($strJsonResponse, true);
$ErrorCode = isset($response['Response']['Error']['ErrorCode']) ? $response['Response']['Error']['ErrorCode'] : '0';
$ErrorMessage = isset($response['Response']['Error']['ErrorMessage']) ? $response['Response']['Error']['ErrorMessage'] : '';
$strBookingId = isset($response['Response']['FlightItinerary']['BookingId']) ? $response['Response']['FlightItinerary']['BookingId'] : '';
$strTicketPNR = isset($response['Response']['FlightItinerary']['PNR']) ? $response['Response']['FlightItinerary']['PNR'] : '';
$TicketStatus = isset($response['Response']['FlightItinerary']['TicketStatus']) ? $response['Response']['FlightItinerary']['TicketStatus'] : '';
$Passenger = isset($response['Response']['FlightItinerary']['Passenger']) ? $response['Response']['FlightItinerary']['Passenger'] : '';
$Message = isset($response['Response']['Message']) ? $response['Response']['Message'] : '';
$AirlineRefPNR = (isset($response['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) && !empty($response['Response']['FlightItinerary']['Segments'][0]['AirlinePNR']) ? $response['Response']['FlightItinerary']['Segments'][0]['AirlinePNR'] : '');
$createARR['Response']['Error'] = $response['Response']['Error'];
$createARR['Response']['ResponseStatus'] = $response['Response']['ResponseStatus'];
$createARR['Response']['TraceId'] = $response['Response']['TraceId'];
$createARR['Response']['Response']['PNR'] = $response['Response']['FlightItinerary']['PNR'];
$createARR['Response']['Response']['BookingId'] = $response['Response']['FlightItinerary']['BookingId'];
$createARR['Response']['Response']['FlightItinerary'] = $response['Response']['FlightItinerary'];
$dataupdate = array(
"XRefBookingId" => $strBookingId . "/" . $strTicketPNR,
"APIBookingRes" => json_encode($createARR),
"XRefPNR" => 1,
"IsBookingStatus" => 1,
"AirlineRefPNR" => $AirlineRefPNR
);
// echo $VersionId;
// echo "<pre>";print_r($dataupdate);
$objFlight->updateBookingDetails($dataupdate, $VersionId); // FOR Ticket CONFIRMED
if (isset($arrTrevllerList) && !empty($arrTrevllerList)) {
foreach ($arrTrevllerList as $key => $value) {
if (isset($Passenger[$key]['Ticket'])) {
$Ticket = $Passenger[$key]['Ticket'];
$data = array(
"TicketId" => $Ticket['TicketId'],
"TicketNumber" => $Ticket['TicketNumber'],
"TicketFullJson" => json_encode($Passenger[$key])
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
}
$data = array(
"StatusType" => 17,
"ErrorMessage" => $Message
);
$objFlight->updateBookingStatusTravelPlan($data, $TPSysId);
$response = array('success' => true, 'msg' => 'Flight is confirmed Successfully. Please check your inbox for flight Itinerary.');
echo json_encode($response);
exit;
// echo '<pre>';print_r($response);die;
// die('d444');
} elseif ($ErrorCode == 0 && $TicketStatus == 0) {
$data = array(
"StatusType" => 72,
"ErrorMessage" => $Message
);
$objFlight->updateBookingStatusTravelPlan($data, $TPSysId);
$response = array('success' => false, 'msg' => $Message . " Please contact administrator for more information");
echo json_encode($response);
exit;
} else {
$data = array(
"StatusType" => 72,
"ErrorMessage" => $ErrorMessage
);
$objFlight->updateBookingStatusTravelPlan($data, $TPSysId);
$response = array('success' => false, 'msg' => $ErrorMessage . ". Please contact administrator for more information");
echo json_encode($response);
exit;
}
}
} else {
die('Invalid Request..!');
}
}
public function time_Diff_Minutes($startTime, $endTime) {
$to_time = strtotime($endTime);
$from_time = strtotime($startTime);
$minutes = ($to_time - $from_time) / 60;
return ($minutes < 0 ? 0 : abs($minutes));
}
public function getQuickProposalForFlightAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
Zend_Session::namespaceUnset('flightValuesId');
$sessionflightValuesId = new Zend_Session_Namespace('flightValuesId');
$post = $this->getRequest()->getPost();
$dealsType = isset($post['dealsType']) ? $post['dealsType'] : '';
if (isset($post['fareRuleTextBased']) && $dealsType == 1) {
$post['fareRuleOneWay'] = $this->createImageFromCkeditor($post['fareRuleTextBased']);
} else {
$post['fareRuleOneWay'] = $this->createImageFromCkeditor($post['fareRuleOneWay']);
}
$objFlight = new Travel_Model_TblFlight();
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$this->_crmcustomertravelItenary = new Travel_Model_CRM_CustomerTravelItenary();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$this->_crmcusttravelplanAir = new Travel_Model_CRM_CustomerTravelPlanAir();
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$strRoute = $sessionFlightSearchParams->params['route'];
$interNationalSearch = trim($sessionFlightSearchParams->params['interNationalSearch']);
$tripType = $post['tripType'];
$intSourceCityId = $post['sourceCityId'];
$intDestinationCityId = $post['destinationCityId'];
$strSourceAirportCode = $post['source_place_id'];
$strDestinationAirportCode = $post['destination_place_id'];
$StopCount = $post['stops'];
$airline_name = $post['airline_name'];
$hidden_selected_airline_sys_id = $post['hidden_selected_airline_sys_id'];
$airlineNo = $post['airlineNo'];
$departure_date_oneway = $post['departure_date_oneway'];
$source_place = $post['source_place'];
$source_place_id = $post['source_place_id'];
$arrival_date_oneway = $post['arrival_date_oneway'];
$destination_place = $post['destination_place'];
$destination_place_id = $post['destination_place_id'];
$currency_type_oneway = $post['currency_type_oneway'];
$adults_count_oneWay = $post['adults_count_oneWay'];
$child_count_oneWay = $post['child_count_oneWay'];
$infant_count_oneWay = $post['infant_count_oneWay'];
$total_cost = $post['total_cost'];
$total_markup = $post['total_markup'];
$total_gst = $post['total_gst'];
$total_pax = $post['total_pax'];
$grand_total = $post['grand_total'];
$refundable = $post['refundable'];
$MarkupArray = json_decode($this->getRequest()->getPost('MarkupArray'));
$PaxFareDetaials = [];
$flightDataArray = [];
if ($dealsType == 1) {
$PaxFareDetaials[0]['PaxType'] = 1;
$PaxFareDetaials[0]['PaxCount'] = $post['paxAdTx'];
$PaxFareDetaials[0]['basefare'] = $post['costAdTx'];
$PaxFareDetaials[0]['markup'] = $post['markupAdTx'];
$PaxFareDetaials[0]['total'] = $post['totalAdTx'];
$PaxFareDetaials[0]['GstType'] = $post['AdtextBased'];
$PaxFareDetaials[0]['supplier_name'] = $post['supplier_name_text'];
$PaxFareDetaials[0]['supplier_id'] = $post['hidden_selected_supplier_sys_text_id'];
$PaxFareDetaials[0]['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
if ($post['paxChTx'] > 0 && $post['costChTx'] > 0) {
$PaxFareDetaials[1]['PaxType'] = 2;
$PaxFareDetaials[1]['PaxCount'] = $post['paxChTx'];
$PaxFareDetaials[1]['basefare'] = $post['costChTx'];
$PaxFareDetaials[1]['markup'] = $post['markupChTx'];
$PaxFareDetaials[1]['total'] = $post['totalChTx'];
$PaxFareDetaials[1]['GstType'] = $post['ChtextBased'];
}
if ($post['paxInTx'] > 0 && $post['costInTx'] > 0) {
$PaxFareDetaials[2]['PaxType'] = 3;
$PaxFareDetaials[2]['PaxCount'] = $post['paxInTx'];
$PaxFareDetaials[2]['basefare'] = $post['costInTx'];
$PaxFareDetaials[2]['markup'] = $post['markupInTx'];
$PaxFareDetaials[2]['total'] = $post['totalInTx'];
$PaxFareDetaials[2]['GstType'] = $post['IntextBased'];
}
} else {
$sessionFlightSearchParams->params['adults'] = $post['adults_count_oneWay'][0];
$sessionFlightSearchParams->params['child'] = $post['child_count_oneWay'][0];
$sessionFlightSearchParams->params['infant'] = $post['infant_count_oneWay'][0];
$sessionFlightSearchParams->params['route'] = $post['tripType'];
$PaxFareDetaials[0]['PaxType'] = 1;
$PaxFareDetaials[0]['PaxCount'] = $post['adults_count_oneWay'][0];
$PaxFareDetaials[0]['basefare'] = array_sum($post['costAd']);
$PaxFareDetaials[0]['markup'] = array_sum($post['markupAd']);
$PaxFareDetaials[0]['total'] = array_sum($post['totalAd']);
$PaxFareDetaials[0]['GstType'] = $post['gst_roundTrip_in_1'][0];
$PaxFareDetaials[0]['supplier_name'] = $post['supplierName'];
$PaxFareDetaials[0]['supplier_id'] = $post['supplierSysId'];
$PaxFareDetaials[0]['sessionFlightSearchParams'] = $sessionFlightSearchParams->params;
if (isset($post['child_count_oneWay'][0]) && $post['child_count_oneWay'][0] > 0 && $post['costCh']) {
$PaxFareDetaials[1]['PaxType'] = 2;
$PaxFareDetaials[1]['PaxCount'] = $post['child_count_oneWay'][0];
$PaxFareDetaials[1]['basefare'] = array_sum($post['costCh']);
$PaxFareDetaials[1]['markup'] = array_sum($post['markupCh']);
$PaxFareDetaials[1]['total'] = array_sum($post['totalCh']);
$PaxFareDetaials[1]['GstType'] = $post['gst_roundTrip_in_1'][0];
}
if (isset($post['infant_count_oneWay'][0]) && $post['infant_count_oneWay'][0] > 0 && $post['costIn']) {
$PaxFareDetaials[2]['PaxType'] = 3;
$PaxFareDetaials[2]['PaxCount'] = $post['infant_count_oneWay'][0];
$PaxFareDetaials[2]['basefare'] = array_sum($post['costIn']);
$PaxFareDetaials[2]['markup'] = array_sum($post['markupIn']);
$PaxFareDetaials[2]['total'] = array_sum($post['totalIn']);
$PaxFareDetaials[2]['GstType'] = $post['gst_roundTrip_in_1'][0];
}
if (!empty($airline_name)) {
foreach ($airline_name as $k => $val) {
$originAirportCode = $source_place_id[$k];
$destinationAirportCode = $destination_place_id[$k];
$originAirportName = $source_place[$k];
$destinationAirportName = $destination_place[$k];
$strDepatureDate = $departure_date_oneway[$k];
$strarrivalDate = $arrival_date_oneway[$k];
$DepTime = explode(" ", $strDepatureDate);
$arrDepatureDate = explode("/", $DepTime[0]);
if (!empty($arrDepatureDate)) {
$initialOriginDepTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . ' ' . $DepTime[1];
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
$StopPointArrivalTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . 'T' . $DepTime[1];
}
$arrTime = explode(" ", $strarrivalDate);
$arrarrivalDate = explode("/", $arrTime[0]);
if (!empty($arrarrivalDate)) {
$destinationArrTime = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0] . ' ' . $arrTime[1];
$strarrivalDate = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0];
}
$originDepTime = ($initialOriginDepTime);
$destinationArrTime = ($destinationArrTime);
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->CalculateHoursMinutes($originDepTime, $destinationArrTime);
$airlineNoEx = explode('-', $airlineNo[$k]);
$AirlineCode = $airlineNoEx[0];
$filePath = $this->getflightlogo($AirlineCode);
$arrSegments = array(
"originAirportName" => $originAirportName,
"destinationAirportName" => $destinationAirportName,
"destinationAirportCode" => $destinationAirportCode,
"destinationArrTime" => $destinationArrTime,
"SegFlightNumber" => $airlineNo[$k],
"AirlineCode" => $AirlineCode,
"AirlineName" => $val,
"FareClass" => '',
"originAirportCode" => $originAirportCode,
"originDepTime" => $originDepTime,
"FlightDuration" => $strDuration,
"DepTerminal" => '',
"ArrTerminal" => '',
"filePath" => $filePath,
);
$flightDataArray[$k]['AirlineName'] = $val;
$flightDataArray[$k]['AirlineCode'] = $AirlineCode;
$flightDataArray[$k]['FlightNumber'] = $airlineNo[$k];
$flightDataArray[$k]['LocalFromTime'] = $originDepTime;
$flightDataArray[$k]['LocalToTime'] = $destinationArrTime;
$flightDataArray[$k]['Segments'] = [$arrSegments];
}
}
}
$PaxFareDetaials[0]['flightData'] = $flightDataArray;
// echo "<pre>";print_r($PaxFareDetaials);
// die;
//echo count($airline_name);
// echo "<pre>";print_r($post);die;
//$gfgdfgdf = $this->getLeadCustomerDetail();
//echo "<pre>";print_r($sessionFlightSearchParams->params);
// echo "<pre>";print_r($this->getRequest()->getPost('data'));die;
$ICSourceSysId = $this->InfoSourceSysId;
$IsFromAgency = 1;
$DayLightSavingDiff = 0;
$AirportHaultMinutes = 0;
$Rating = 0;
$FllightFeatureMask = 0;
$UpdatedByISSysId = $this->intLoggedinUserId;
$CreatedByISSysId = $this->intLoggedinUserId;
$ImageTN = '';
$ImgForList = '';
$ImgeDetails = '';
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
// echo "<pre>";print_r($departure_date_oneway[0]);die;
if ($interNationalSearch == 1 && $tripType == 2) {
if(isset($departure_date_oneway[0]) && !empty($departure_date_oneway[0])){
$strDepatureDate = $departure_date_oneway[0];
$strarrivalDate = $arrival_date_oneway[0];
$DepTime = explode(" ", $strDepatureDate);
$arrDepatureDate = explode("/", $DepTime[0]);
if (!empty($arrDepatureDate)) {
$initialOriginDepTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . ' ' . $DepTime[1];
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
$StopPointArrivalTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . 'T' . $DepTime[1];
}
$localFromDateTime = date("Y-m-d H:i", strtotime($strDepatureDate));
$arrTime = explode(" ", $strarrivalDate);
$arrarrivalDate = explode("/", $arrTime[0]);
if (!empty($arrarrivalDate)) {
$destinationArrTime = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0] . ' ' . $arrTime[1];
$strarrivalDate = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0];
}
$localToDateTime = date("Y-m-d H:i", strtotime($strarrivalDate));
}
$FlyingMinutes = $this->time_Diff_Minutes($initialOriginDepTime, $destinationArrTime);
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = '';
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = 1;
$arrInsertFlightData['IsRefundable'] = $refundable;
$arrInsertFlightData['apiTraceId'] = 0;
$arrInsertFlightData['AirlineSysId'] = $hidden_selected_airline_sys_id[0];
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = '1';
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
$arrInsertFlightData['IsDirect'] = 0;
$arrInsertFlightData['FareClass'] = '';
$arrInsertFlightData['DayLightSavingDiff'] = '';
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId[0];
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId[0];
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode[0];
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode[0];
$arrInsertFlightData['AirportHaultMinutes'] = 0;
$arrInsertFlightData['StopCount'] = 0;
$arrInsertFlightData['Stops'] = '';
$arrInsertFlightData['NoOfSeatAvailable'] = 0;
$arrInsertFlightData['TotalFlightMembers'] = $post['total_pax_roundTrip'];
$arrInsertFlightData['CurrencyType'] = $currency_type_oneway[0];
$arrInsertFlightData['PublishedFare'] = $post['grand_total_roundTrip']; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = 0;
$arrInsertFlightData['ApiResultIndex'] = '';
$arrInsertFlightData['JourneyType'] = $post['JourneyType'];
$arrInsertFlightData['TripType'] = '0';
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = '';
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = '';
$arrInsertFlightData['ImgForList'] = '';
$arrInsertFlightData['ImgeDetails'] = '';
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$arrInsertFlightData['IsInternational'] = !empty($interNationalSearch) ? $interNationalSearch : '0';
$arrInsertFlightData['IsQuickProposal'] = 1;
$arrInsertFlightData['QuickProposalData'] = '';
$arrInsertFlightData['ICSourceSysId'] = 9;
$intFlightParentRecordId = $objFlight->addFlightDetails($arrInsertFlightData);
$arrFairRules = array(
"TBOAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => $currency_type_oneway[0],
"BaseFare" => $post['total_cost_roundTrip'],
"Tax" => $post['total_gst_roundTrip'],
"YQTax" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"OtherCharges" => 0,
"Discount" => 0,
"ServiceFee" => $post['total_markup_roundTrip'],
"PublishedFare" => $post['grand_total_roundTrip'],
"CommissionEarned" => 0,
"PLBEarned" => 0,
"IncentiveEarned" => 0,
"OfferedFare" => $post['total_cost_roundTrip'],
"TdsOnCommission" => 0,
"TdsOnPLB" => 0,
"TdsOnIncentive" => 0,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => $IsActive,
"IsMarkForDel" => $IsMarkForDel
);
$objFlight->addFlightFairRuleDetails($arrFairRules);
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $intFlightParentRecordId,
"Currency" => $currency_type_oneway[0],
"PassengerType" => 1,
"PassengerCount" => $post['total_pax_roundTrip'],
"BaseFare" => $post['total_cost_roundTrip'],
"Tax" => $post['total_gst_roundTrip'],
"YQTax" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
$sessionflightValuesId->params['AirInvenSysId_0'] = '' . $intFlightParentRecordId . '';
if (!empty($airline_name)) {
foreach ($airline_name as $k => $val) {
$strDepatureDate = $departure_date_oneway[$k];
$strarrivalDate = $arrival_date_oneway[$k];
$DepTime = explode(" ", $strDepatureDate);
//echo "<pre>";print_r($DepTime);
$arrDepatureDate = explode("/", $DepTime[0]);
if (!empty($arrDepatureDate)) {
$initialOriginDepTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . ' ' . $DepTime[1];
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
$StopPointArrivalTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . 'T' . $DepTime[1];
}
$arrTime = explode(" ", $strarrivalDate);
$arrarrivalDate = explode("/", $arrTime[0]);
if (!empty($arrarrivalDate)) {
$destinationArrTime = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0] . ' ' . $arrTime[1];
$strarrivalDate = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0];
}
$dtA = new DateTime($initialOriginDepTime);
$dtB = new DateTime($destinationArrTime);
if ($dtA >= $dtB) {
$response = array('status' => false, 'message' => 'Arrival date time should be greater than departure date time. ' . ($k + 1) . '');
echo json_encode($response);
exit;
}
$localFromDateTime = date("Y-m-d H:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d H:i", strtotime($strarrivalDate));
$FlyingMinutes = $this->time_Diff_Minutes($initialOriginDepTime, $destinationArrTime);
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
$currencySysId = $currency_type_oneway[$k];
$QuickProposalData = array(
'leadID' => $post['leadID'],
'sac_code' => $post['sac_code'],
'gsttype' => $post['gsttype'],
'flightcount' => $post['flightcount'],
'CustomerSysId' => $post['CustomerSysId'],
'customername' => $post['customername'],
'customerSysIdSel' => $post['customerSysIdSel'],
'tripType' => $post['tripType'],
'JourneyType' => $post['JourneyType'],
'emailID' => $post['emailID'],
'IsB2BAgent' => $post['IsB2BAgent'],
'aId' => $post['aId'],
'editLeadId' => $post['editLeadId'],
'isInternational' => $post['isInternational'],
'hidden_selected_airline_sys_id' => $post['hidden_selected_airline_sys_id'][$k],
'airlineNo' => $post['airlineNo'][$k],
'departure_date_oneway' => $post['departure_date_oneway'][$k],
'source_place' => $post['source_place'][$k],
'source_place_id' => $post['source_place_id'][$k],
'sourceCityId' => $post['sourceCityId'][$k],
'destination_place' => $post['destination_place'][$k],
'destination_place_id' => $post['destination_place_id'][$k],
'destinationCityId' => $post['destinationCityId'][$k],
'arrival_date_oneway' => $post['arrival_date_oneway'][$k],
'stops' => $post['stops'][$k],
'currency_type_oneway' => $post['currency_type_oneway'][$k],
'adults_count_oneWay' => $post['adults_count_oneWay'][$k],
'costAd' => $post['costAd'][$k],
'markupAd' => $post['markupAd'][$k],
'totalAd' => $post['totalAd'][$k],
'child_count_oneWay' => $post['child_count_oneWay'][$k],
'costCh' => $post['costCh'][$k],
'markupCh' => $post['markupCh'][$k],
'totalCh' => $post['totalCh'][$k],
'infant_count_oneWay' => $post['infant_count_oneWay'][$k],
'costIn' => $post['costIn'][$k],
'markupIn' => $post['markupIn'][$k],
'totalIn' => $post['totalIn'][$k],
'total_pax' => $post['total_pax'][$k],
'total_cost' => $post['total_cost'][$k],
'total_markup' => $post['total_markup'][$k],
'total_gst' => $post['total_gst'][$k],
'grand_total' => $post['grand_total'][$k],
'pax_roundTrip_1' => isset($post['pax_roundTrip_1']) ? $post['pax_roundTrip_1'] : '',
'cost_roundTrip_1' => isset($post['cost_roundTrip_1']) ? $post['cost_roundTrip_1'] : '',
'markup_roundTrip_1' => isset($post['markup_roundTrip_1']) ? $post['markup_roundTrip_1'] : '',
'gst_roundTrip_1' => isset($post['gst_roundTrip_1']) ? $post['gst_roundTrip_1'] : '',
'total_roundTrip_1' => isset($post['total_roundTrip_1']) ? $post['total_roundTrip_1'] : '',
'pax_roundTrip_2' => isset($post['pax_roundTrip_2']) ? $post['pax_roundTrip_2'] : '',
'cost_roundTrip_2' => isset($post['cost_roundTrip_2']) ? $post['cost_roundTrip_2'] : '',
'markup_roundTrip_2' => isset($post['markup_roundTrip_2']) ? $post['markup_roundTrip_2'] : '',
'gst_roundTrip_2' => isset($post['gst_roundTrip_2']) ? $post['gst_roundTrip_2'] : '',
'total_roundTrip_2' => isset($post['total_roundTrip_2']) ? $post['total_roundTrip_2'] : '',
'pax_roundTrip_3' => isset($post['pax_roundTrip_3']) ? $post['pax_roundTrip_3'] : '',
'cost_roundTrip_3' => isset($post['cost_roundTrip_3']) ? $post['cost_roundTrip_3'] : '',
'markup_roundTrip_3' => isset($post['markup_roundTrip_3']) ? $post['markup_roundTrip_3'] : '',
'total_roundTrip_3' => isset($post['total_roundTrip_3']) ? $post['total_roundTrip_3'] : '',
'total_pax_roundTrip' => isset($post['total_pax_roundTrip']) ? $post['total_pax_roundTrip'] : '',
'total_cost_roundTrip' => isset($post['total_cost_roundTrip']) ? $post['total_cost_roundTrip'] : '',
'total_markup_roundTrip' => isset($post['total_markup_roundTrip']) ? $post['total_markup_roundTrip'] : '',
'total_gst_roundTrip' => isset($post['total_gst_roundTrip']) ? $post['total_gst_roundTrip'] : '',
'grand_total_roundTrip' => isset($post['grand_total_roundTrip']) ? $post['grand_total_roundTrip'] : '',
'supplierName' => isset($post['supplierName']) ? $post['supplierName'] : '',
'supplierSysId' => isset($post['supplierSysId']) ? $post['supplierSysId'] : '',
'selectedFlightType' => isset($post['selectedFlightType']) ? $post['selectedFlightType'] : '',
'fareRuleOneWay' => isset($post['fareRuleOneWay']) ? $post['fareRuleOneWay'] : '',
'refundable' => isset($post['refundable']) ? $post['refundable'] : '',
'allowooking' => isset($post['allowooking']) ? $post['allowooking'] : '',
'flightRateMayBeChange' => isset($post['flightRateMayBeChange']) ? $post['flightRateMayBeChange'] : '',
'MarkupArray' => isset($MarkupArray) ? $MarkupArray[$k] : '',
);
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $airlineNo[$k];
$arrInsertFlightData['AirInvenSysId'] = $intFlightParentRecordId;
$arrInsertFlightData['IsLCC'] = 1;
$arrInsertFlightData['IsRefundable'] = $refundable;
$arrInsertFlightData['apiTraceId'] = 0;
$arrInsertFlightData['AirlineSysId'] = $hidden_selected_airline_sys_id[$k];
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
$arrInsertFlightData['IsDirect'] = 1;
$arrInsertFlightData['FareClass'] = '';
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId[$k];
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId[$k];
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode[$k];
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode[$k];
$arrInsertFlightData['AirportHaultMinutes'] = 0;
$arrInsertFlightData['StopCount'] = $StopCount[$k];
$arrInsertFlightData['Stops'] = $StopCount[$k];
$arrInsertFlightData['NoOfSeatAvailable'] = 0;
$arrInsertFlightData['TotalFlightMembers'] = $total_pax[$k];
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $grand_total[$k]; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = 0;
$arrInsertFlightData['ApiResultIndex'] = '';
$arrInsertFlightData['JourneyType'] = $post['JourneyType'];
$arrInsertFlightData['TripType'] = ($k == 0) ? 1 : $tripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$arrInsertFlightData['IsInternational'] = !empty($interNationalSearch) ? $interNationalSearch : '0';
$arrInsertFlightData['IsQuickProposal'] = 1;
$arrInsertFlightData['ICSourceSysId'] = 9;
$arrInsertFlightData['QuickProposalData'] = json_encode($QuickProposalData);
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
// FOR FLIGHT SEGMENTS.....
$arrSegments = array(
"AirInvenAPISysId" => $AirInvenSysId,
"TripIndicator" => 1,
"Baggage" => '0 Kg',
"CabinBaggage" => '7 KG',
"SegmentIndicator" => 1,
"Duration" => $FlyingMinutes,
"GroundTime" => 0,
"Mile" => 0,
"StopOver" => '',
"StopPoint" => '',
"StopPointArrivalTime" => $StopPointArrivalTime,
"Craft" => 0,
"Remark" => '',
"IsETicketEligible" => 1,
"FlightStatus" => 'Confirmed',
"Status" => ''
);
//$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
}
}
} else {
if (!empty($airline_name)) {
foreach ($airline_name as $k => $val) {
$strDepatureDate = $departure_date_oneway[$k];
$strarrivalDate = $arrival_date_oneway[$k];
$DepTime = explode(" ", $strDepatureDate);
$arrDepatureDate = explode("/", $DepTime[0]);
if (!empty($arrDepatureDate)) {
$initialOriginDepTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . ' ' . $DepTime[1];
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
$StopPointArrivalTime = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0] . 'T' . $DepTime[1];
}
$arrTime = explode(" ", $strarrivalDate);
$arrarrivalDate = explode("/", $arrTime[0]);
if (!empty($arrarrivalDate)) {
$destinationArrTime = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0] . ' ' . $arrTime[1];
$strarrivalDate = $arrarrivalDate[2] . "-" . $arrarrivalDate[1] . "-" . $arrarrivalDate[0];
}
$dtA = new DateTime($initialOriginDepTime);
$dtB = new DateTime($destinationArrTime);
if ($dtA >= $dtB) {
$response = array('status' => false, 'message' => 'Arrival date time should be greater than departure date time. ' . ($k + 1) . '');
echo json_encode($response);
exit;
}
$localFromDateTime = date("Y-m-d H:i", strtotime($strDepatureDate));
$localToDateTime = date("Y-m-d H:i", strtotime($strarrivalDate));
$FlyingMinutes = $this->time_Diff_Minutes($initialOriginDepTime, $destinationArrTime);
$UpdateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$CreateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$ApproveBy = $this->intLoggedinUserId;
$ApprovalDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$IsApproved = '1';
$IsActive = '1';
$IsMarkForDel = 0;
$currencySysId = $currency_type_oneway[$k];
$QuickProposalData = array(
'leadID' => $post['leadID'],
'sac_code' => $post['sac_code'],
'gsttype' => $post['gsttype'],
'flightcount' => $post['flightcount'],
'CustomerSysId' => $post['CustomerSysId'],
'customername' => $post['customername'],
'customerSysIdSel' => $post['customerSysIdSel'],
'tripType' => $post['tripType'],
'JourneyType' => $post['JourneyType'],
'emailID' => $post['emailID'],
'IsB2BAgent' => $post['IsB2BAgent'],
'aId' => $post['aId'],
'editLeadId' => $post['editLeadId'],
'isInternational' => $post['isInternational'],
'hidden_selected_airline_sys_id' => $post['hidden_selected_airline_sys_id'][$k],
'airlineNo' => $post['airlineNo'][$k],
'departure_date_oneway' => $post['departure_date_oneway'][$k],
'source_place' => $post['source_place'][$k],
'source_place_id' => $post['source_place_id'][$k],
'sourceCityId' => $post['sourceCityId'][$k],
'destination_place' => $post['destination_place'][$k],
'destination_place_id' => $post['destination_place_id'][$k],
'destinationCityId' => $post['destinationCityId'][$k],
'arrival_date_oneway' => $post['arrival_date_oneway'][$k],
'stops' => $post['stops'][$k],
'currency_type_oneway' => $post['currency_type_oneway'][$k],
'adults_count_oneWay' => $post['adults_count_oneWay'][$k],
'costAd' => $post['costAd'][$k],
'markupAd' => $post['markupAd'][$k],
'totalAd' => $post['totalAd'][$k],
'child_count_oneWay' => $post['child_count_oneWay'][$k],
'costCh' => $post['costCh'][$k],
'markupCh' => $post['markupCh'][$k],
'totalCh' => $post['totalCh'][$k],
'infant_count_oneWay' => $post['infant_count_oneWay'][$k],
'costIn' => $post['costIn'][$k],
'markupIn' => $post['markupIn'][$k],
'totalIn' => $post['totalIn'][$k],
'total_pax' => $post['total_pax'][$k],
'total_cost' => $post['total_cost'][$k],
'total_markup' => $post['total_markup'][$k],
'total_gst' => $post['total_gst'][$k],
'grand_total' => $post['grand_total'][$k],
'pax_roundTrip_1' => isset($post['pax_roundTrip_1']) ? $post['pax_roundTrip_1'] : '',
'cost_roundTrip_1' => isset($post['cost_roundTrip_1']) ? $post['cost_roundTrip_1'] : '',
'markup_roundTrip_1' => isset($post['markup_roundTrip_1']) ? $post['markup_roundTrip_1'] : '',
'gst_roundTrip_1' => isset($post['gst_roundTrip_1']) ? $post['gst_roundTrip_1'] : '',
'total_roundTrip_1' => isset($post['total_roundTrip_1']) ? $post['total_roundTrip_1'] : '',
'pax_roundTrip_2' => isset($post['pax_roundTrip_2']) ? $post['pax_roundTrip_2'] : '',
'cost_roundTrip_2' => isset($post['cost_roundTrip_2']) ? $post['cost_roundTrip_2'] : '',
'markup_roundTrip_2' => isset($post['markup_roundTrip_2']) ? $post['markup_roundTrip_2'] : '',
'gst_roundTrip_2' => isset($post['gst_roundTrip_2']) ? $post['gst_roundTrip_2'] : '',
'total_roundTrip_2' => isset($post['total_roundTrip_2']) ? $post['total_roundTrip_2'] : '',
'pax_roundTrip_3' => isset($post['pax_roundTrip_3']) ? $post['pax_roundTrip_3'] : '',
'cost_roundTrip_3' => isset($post['cost_roundTrip_3']) ? $post['cost_roundTrip_3'] : '',
'markup_roundTrip_3' => isset($post['markup_roundTrip_3']) ? $post['markup_roundTrip_3'] : '',
'total_roundTrip_3' => isset($post['total_roundTrip_3']) ? $post['total_roundTrip_3'] : '',
'total_pax_roundTrip' => isset($post['total_pax_roundTrip']) ? $post['total_pax_roundTrip'] : '',
'total_cost_roundTrip' => isset($post['total_cost_roundTrip']) ? $post['total_cost_roundTrip'] : '',
'total_markup_roundTrip' => isset($post['total_markup_roundTrip']) ? $post['total_markup_roundTrip'] : '',
'total_gst_roundTrip' => isset($post['total_gst_roundTrip']) ? $post['total_gst_roundTrip'] : '',
'grand_total_roundTrip' => isset($post['grand_total_roundTrip']) ? $post['grand_total_roundTrip'] : '',
'supplierName' => isset($post['supplierName']) ? $post['supplierName'] : '',
'supplierSysId' => isset($post['supplierSysId']) ? $post['supplierSysId'] : '',
'selectedFlightType' => isset($post['selectedFlightType']) ? $post['selectedFlightType'] : '',
'fareRuleOneWay' => isset($post['fareRuleOneWay']) ? $post['fareRuleOneWay'] : '',
'refundable' => isset($post['refundable']) ? $post['refundable'] : '',
'allowooking' => isset($post['allowooking']) ? $post['allowooking'] : '',
'flightRateMayBeChange' => isset($post['flightRateMayBeChange']) ? $post['flightRateMayBeChange'] : '',
'MarkupArray' => isset($MarkupArray) ? $MarkupArray[$k] : '',
);
$arrFairRules = array(
"TBOAirInvenAPISysId" => "",
"Currency" => $currencySysId,
"BaseFare" => $total_cost[$k],
"Tax" => $total_gst[$k],
"YQTax" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"OtherCharges" => 0,
"Discount" => 0,
"ServiceFee" => $total_markup[$k],
"PublishedFare" => $grand_total[$k],
"CommissionEarned" => 0,
"PLBEarned" => 0,
"IncentiveEarned" => 0,
"OfferedFare" => $total_cost[$k],
"TdsOnCommission" => 0,
"TdsOnPLB" => 0,
"TdsOnIncentive" => 0,
"UpdateDate" => $UpdateDate,
"CreateDate" => $CreateDate,
"IsActive" => $IsActive,
"IsMarkForDel" => $IsMarkForDel
);
$arrInsertFlightData = array();
$arrInsertFlightData['FlightNumber'] = $airlineNo[$k];
$arrInsertFlightData['AirInvenSysId'] = 0;
$arrInsertFlightData['IsLCC'] = 1;
$arrInsertFlightData['IsRefundable'] = $refundable;
$arrInsertFlightData['apiTraceId'] = 0;
$arrInsertFlightData['AirlineSysId'] = $hidden_selected_airline_sys_id[$k];
$arrInsertFlightData['ICSourceSysId'] = $ICSourceSysId;
$arrInsertFlightData['IsFromAgency'] = $IsFromAgency;
$arrInsertFlightData['LocalFromTime'] = $localFromDateTime;
$arrInsertFlightData['FromUTCTime'] = $initialOriginDepTime;
$arrInsertFlightData['LocalToTime'] = $localToDateTime;
$arrInsertFlightData['ToUTCTime'] = $destinationArrTime;
$arrInsertFlightData['IsDirect'] = 1;
$arrInsertFlightData['FareClass'] = '';
$arrInsertFlightData['DayLightSavingDiff'] = $DayLightSavingDiff;
$arrInsertFlightData['FlyingMinutes'] = $FlyingMinutes;
$arrInsertFlightData['SourcePlaceSysId'] = $intSourceCityId[$k];
$arrInsertFlightData['DestPlaceSysId'] = $intDestinationCityId[$k];
$arrInsertFlightData['SourceAirportCode'] = $strSourceAirportCode[$k];
$arrInsertFlightData['DestAirportCode'] = $strDestinationAirportCode[$k];
$arrInsertFlightData['AirportHaultMinutes'] = 0;
$arrInsertFlightData['StopCount'] = $StopCount[$k];
$arrInsertFlightData['Stops'] = $StopCount[$k];
$arrInsertFlightData['NoOfSeatAvailable'] = 0;
$arrInsertFlightData['TotalFlightMembers'] = $total_pax[$k];
$arrInsertFlightData['CurrencyType'] = $currencySysId;
$arrInsertFlightData['PublishedFare'] = $grand_total[$k]; // As Discussed with GG
$arrInsertFlightData['CommissionEarned'] = 0;
$arrInsertFlightData['ApiResultIndex'] = '';
$arrInsertFlightData['JourneyType'] = $post['JourneyType'];
$arrInsertFlightData['TripType'] = ($k == 0) ? 1 : $tripType;
$arrInsertFlightData['Rating'] = $Rating;
$arrInsertFlightData['FllightFeatureMask'] = $FllightFeatureMask;
$arrInsertFlightData['UpdatedByISSysId'] = $UpdatedByISSysId;
$arrInsertFlightData['CreatedByISSysId'] = $CreatedByISSysId;
$arrInsertFlightData['ImageTN'] = $ImageTN;
$arrInsertFlightData['ImgForList'] = $ImgForList;
$arrInsertFlightData['ImgeDetails'] = $ImgeDetails;
$arrInsertFlightData['UpdateDate'] = $UpdateDate;
$arrInsertFlightData['CreateDate'] = $CreateDate;
$arrInsertFlightData['ApproveBy'] = $ApproveBy;
$arrInsertFlightData['ApprovalDate'] = $ApprovalDate;
$arrInsertFlightData['IsApproved'] = $IsApproved;
$arrInsertFlightData['IsActive'] = $IsActive;
$arrInsertFlightData['IsMarkForDel'] = $IsMarkForDel;
$arrInsertFlightData['IsInternational'] = !empty($interNationalSearch) ? $interNationalSearch : '0';
$arrInsertFlightData['IsQuickProposal'] = 1;
$arrInsertFlightData['ICSourceSysId'] = 9;
$arrInsertFlightData['QuickProposalData'] = json_encode($QuickProposalData);
$intFlightLastInsertId = $objFlight->addFlightDetails($arrInsertFlightData);
$AirInvenSysId = $intFlightLastInsertId;
$sessionflightValuesId->params['AirInvenSysId_' . $k] = '' . $AirInvenSysId . '';
// FOR FLIGHT FAIR-RULES.....
$arrFairRules['TBOAirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightFairRuleDetails($arrFairRules);
// FOR FLIGHT FAIR-RULES.....
// FOR FLIGHT SEGMENTS.....
$arrSegments = array(
"AirInvenAPISysId" => $AirInvenSysId,
"TripIndicator" => 1,
"Baggage" => '0 Kg',
"CabinBaggage" => '7 KG',
"SegmentIndicator" => 1,
"Duration" => $FlyingMinutes,
"GroundTime" => 0,
"Mile" => 0,
"StopOver" => '',
"StopPoint" => '',
"StopPointArrivalTime" => $StopPointArrivalTime,
"Craft" => 0,
"Remark" => '',
"IsETicketEligible" => 1,
"FlightStatus" => 'Confirmed',
"Status" => ''
);
//$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
$arrFareBreakdown = array(
"TBQAirInvenAPISysId" => $AirInvenSysId,
"Currency" => $currencySysId,
"PassengerType" => 1,
"PassengerCount" => $total_pax[$k],
"BaseFare" => $total_cost[$k],
"Tax" => $total_gst[$k],
"YQTax" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0
);
$objFlight->addFlightFareBreakdown($arrFareBreakdown);
}
}
}
/// Add New Lead start
$flightValues = implode(',', $sessionflightValuesId->params);
$customerEmail = $post['emailID'];
$cardcharges = 0;
$editLeadId = $post['editLeadId'];
$tripType = $this->getRequest()->getPost('tripType');
$isInternational = $this->getRequest()->getPost('isInternational');
$MarkupArray = json_decode($this->getRequest()->getPost('MarkupArray'));
$agencySysID = $this->intLoggedinAgencyId;
$CustomerSysId = !empty($this->getRequest()->getPost('CustomerSysId')) ? trim($this->getRequest()->getPost('CustomerSysId')) : 0;
$CustomerSysIdSel = !empty($this->getRequest()->getPost('customerSysIdSel')) ? base64_decode(trim($this->getRequest()->getPost('customerSysIdSel'))) : 0;
$SACCode = !empty($this->getRequest()->getPost('sac_code')) ? $this->getRequest()->getPost('sac_code') : 440063; // default value 440063 for Tour Oprators..
$gsttype = !empty($this->getRequest()->getPost('gsttype')) ? $this->getRequest()->getPost('gsttype') : '';
if ($CustomerSysId != $CustomerSysIdSel) {
$CustomerSysIdNew = $CustomerSysIdSel;
} else {
$CustomerSysIdNew = $CustomerSysId;
}
//echo $CustomerSysIdNew;die;
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerById($CustomerSysIdNew);
$customerRcord = $getcustomerdetails['CustomerSysId'];
$customeremail = trim($getcustomerdetails['EmailId']);
$agentsysID = $this->intLoggedinUserId;
$getflightData = array();
if ($flightValues) {
$objFlight->strCondition = " TBQAirInvenSysId IN ($flightValues) ";
$getflightData = $objFlight->getSelectedFlightDetails();
}
//echo "<pre>";print_r($getflightData);die;
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$status = '2';
$createDate = date('Y-m-d H:i:s');
$strDepatureDate = $departure_date_oneway[0];
$DepTime = explode(" ", $strDepatureDate);
$departure_dates_string = $DepTime[0];
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
//$adults = $sessionFlightSearchParams->params['adults'];
$flight_class = $sessionFlightSearchParams->params['flight_class'];
$route = $sessionFlightSearchParams->params['route'];
$strDepatureDateReturn = isset($departure_date_oneway[1]) ? $departure_date_oneway[1] : $sessionFlightSearchParams->params['return_dates'];
$DepRetTime = explode(" ", $strDepatureDateReturn);
$return_dates_string = $DepRetTime[0];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($explode_return_date[2]) && !empty($explode_return_date)) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
$adults = $adults_count_oneWay[0];
$child = $child_count_oneWay[0];
$infant = $infant_count_oneWay[0];
$oneway_origin_text = $source_place_id[0];
$oneway_destination_text = $destination_place_id[0];
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$IsInterNational = $sessionFlightSearchParams->params['interNationalSearch'];
if ($IsInterNational) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$roomjson = array();
$childcount = $child;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
$roomjson[1]['Infant'] = $infant;
$roomjson[1]['ChildAge_1'] = $infant;
$roomjson[1]['departuredate'] = $DepTime[0];
$roomjson[1]['returndate'] = $DepRetTime[0];
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
$roomjson[1]['airclass'] = $flight_class;
$RoomInfoJson = json_encode($roomjson);
if (empty($editLeadId)) {
$planbookingID = 'QS/' . date('y');
$data = array(
'PlanBookingId' => $planbookingID,
'StatusType' => $status,
'CustomerSysId' => $customerRcord,
'AdditionalReq' => '',
'PlanType' => 1,
'InventoryType' => 1,
'TemplatePckSysId' => !empty($editLeadId) ? trim($editLeadId) : 0,
'CurrencyType' => isset($getflightData[0]['CurrencyType']) ? (int) $getflightData[0]['CurrencyType'] : 0,
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaceSysId' => isset($getflightData[0]['SourcePlaceSysId']) ? $getflightData[0]['SourcePlaceSysId'] : 0,
'DestinationPlacesSysId' => isset($getflightData[0]['DestinationPlacesSysId']) ? $getflightData[0]['DestinationPlacesSysId'] : 0,
'SourcePlaces' => isset($getflightData[0]['SourcePlaceName']) ? $getflightData[0]['SourcePlaceName'] : '',
'DestinationPlaces' => isset($getflightData[0]['DestPlaceName']) ? $getflightData[0]['DestPlaceName'] : '',
'Cities' => @$getflightData[0]['SourcePlaceName'] . "-" . @$getflightData[0]['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => $post['supplierSysId'],
'IsHotelFromApi' => 1,
'CreateDate' => $createDate,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent'])
);
########### Start Add Data in Travel Table(Base Table) ###################
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
} else {
$leadID = trim($editLeadId);
if (!empty($leadID)) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplan, $where);
}
}
########### End Add Data in Travel Air Table and Query Section ###################
$intTatalPaxCTForMarkUp = $adults + $child + $infant;
if ($dealsType == 1) {
//echo "<pre>";print_r($sessionFlightSearchParams->params);die;
$sourceCityAirportCode = $sessionFlightSearchParams->params['sourceCityAirportCode'];
$destinationCityAirportCode = $sessionFlightSearchParams->params['destinationCityAirportCode'];
$sourceCityId = (int) $sessionFlightSearchParams->params['sourceCityId'];
$destinationCityId = (int) $sessionFlightSearchParams->params['destinationCityId'];
$sourceCityText = explode(',', $sessionFlightSearchParams->params['sourceCityText']);
$Origincity = $sourceCityText[0];
$destinationCityText = explode(',', $sessionFlightSearchParams->params['destinationCityText']);
$DestinationCity = $destinationCityText[0];
$departure_dates = $sessionFlightSearchParams->params['departure_dates'];
$return_dates = $sessionFlightSearchParams->params['return_dates'];
$departure_date = implode('-', array_reverse(explode('/', $departure_dates)));
$return_date = implode('-', array_reverse(explode('/', $return_dates)));
$roomjson = array();
$roomjson[1]['Adult'] = (int) $post['paxAdTx'];
$roomjson[1]['Child'] = (int) $post['paxChTx'];
$roomjson[1]['Infant'] = (int) $post['paxInTx'];
$roomjson[1]['ChildAge_1'] = 0;
$roomjson[1]['departuredate'] = $departure_dates;
$roomjson[1]['returndate'] = $return_dates;
$RoomInfoJson = json_encode($roomjson);
$planbookingID = 'QS/' . date('y');
$FlightContent = trim($post['fareRuleOneWay']);
$flightDetailAdultCost = ($post['costAdTx']) ? $post['costAdTx'] : 0;
$flightDetailChildCost = ($post['costChTx']) ? $post['costChTx'] : 0;
$flightDetailInfantCost = ($post['costInTx']) ? $post['costInTx'] : 0;
$flightDetailCost = ($post['total_cost_textBased']) ? $post['total_cost_textBased'] : 0;
$flightDetailMarkup = ($post['total_markup_textBased']) ? $post['total_markup_textBased'] : 0;
$flightDetailGst = ($post['total_gst_textBased']) ? $post['total_gst_textBased'] : 0;
$flightDetailTotal = ($post['grand_total_textBased']) ? $post['grand_total_textBased'] : 0;
$flightPriceArray = json_encode(array('flightDetailAdultCost' => $flightDetailAdultCost, 'flightDetailChildCost' => $flightDetailChildCost, 'flightDetailInfantCost' => $flightDetailInfantCost, 'flightDetailCost' => $flightDetailCost, 'flightDetailMarkup' => $flightDetailMarkup, 'flightDetailGst' => $flightDetailGst, 'flightDetailTotal' => $flightDetailTotal));
$finalEmailContent = json_encode(array('FlightContent' => $FlightContent, 'flightPriceArray' => $flightPriceArray));
$totalCost = (float) $flightDetailTotal;
$data = array(
'PlanBookingId' => $planbookingID,
'TPId' => 0,
'Title' => $Origincity . "-" . $DestinationCity,
'MasterTPSysId' => $leadID,
'Price' => (isset($post['total_cost_textBased'])) ? (int) $post['total_cost_textBased'] : 0, //$total_cost[$i],
'TotalCost' => (isset($post['grand_total_textBased'])) ? (int) $post['grand_total_textBased'] : 0,
'NetPrice' => (isset($post['grand_total_textBased'])) ? (int) $post['grand_total_textBased'] : 0,
'StatusType' => '4',
'ProposalEmailTo' => $customeremail,
'PlanType' => 1,
'InventoryType' => 1,
'CurrencyType' => 1,
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaces' => $Origincity,
'SourcePlaceSysId' => $sourceCityId,
'DestinationPlacesSysId' => $destinationCityId,
'DestinationPlaces' => $DestinationCity,
'Cities' => $Origincity . "-" . $DestinationCity,
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => $post['hidden_selected_supplier_sys_text_id'],
'IsHotelFromApi' => 0,
'CustomerSysId' => $customerRcord,
'StartDate' => $return_date,
'ValidTill' => $return_date,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent']),
'IsPriceShared' => trim($isPriceShared),
'GSTSharedMode' => trim($gsttype),
'SACCode' => trim($SACCode),
'PackSpecType' => 4,
'EconomyMask' => 7,
'EmailText' => (isset($finalEmailContent) && $finalEmailContent != '') ? $finalEmailContent : '',
'AgentServiceTaxAmount' => (float) $flightDetailGst,
'AgencyMarkUp' => (float) $flightDetailMarkup
);
// echo "<pre>";print_r($data);exit;
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
$airData = array(
'TPIntSysId' => (int) $lasttravelitenaryID,
'AgencySysId' => (int) $agencySysID,
'FlightNumber' => 0,
'AirlineSysId' => 0,
'CreateDate' => $createDate,
'Cost' => $flightDetailCost,
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 18,
'AgentServiceTaxAmount' => (float) $flightDetailGst,
'AgentsCustomServiceTaxAmount' => 0,
'TotalCost' => (float) $flightDetailTotal,
'MarkUp' => (float) $flightDetailMarkup,
'AgencyMarkUp' => 0,
'AgencyCommission' => 0,
'GTXMarkUp' => 0,
'FlightCabinClass' => 0,
'AdultPax' => (int) $post['paxAdTx'],
'LocalFromTime' => $departure_date,
'LocalToTime' => $departure_date,
'FromUTCTime' => $departure_date,
'ToUTCTime' => $departure_date,
'ChildPax' => (int) $post['paxChTx'],
'InfentPax' => (int) $post['paxInTx'],
'SourceAirportCode' => $sourceCityAirportCode,
'DestAirportCode' => $destinationCityAirportCode,
'TripType' => (int) $tripType,
'CurrencyType' => 1,
'SupplierSysId' => (int) $post['hidden_selected_supplier_sys_text_id'],
'ICSourceSysId' => 0,
'InvnItemSysId' => 0,
'IsFromAPI' => 0,
'UpdateDate' => $createDate,
'encodedata' => $post['fareRuleOneWay'],
'APIBookingRes' => json_encode(array_values($PaxFareDetaials)),
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'AirlineRefPNR' => '',
'IsBookingStatus' => '',
'ICSourceSysId' => 9,
);
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
}
} else {
for ($i = 0; $i < count($getflightData); $i++) {
$planbookingID = 'QS/' . date('y');
//$agencySysID = $this->intLoggedinUserAgencySysId ;
$agentMarkup = $MarkupArray[$i];
$arrAllCommissions = array(
'intCommissionEarned' => $getflightData[$i]['CommissionEarned'],
'intPLBEarned' => $getflightData[$i]['PLBEarned'],
'intIncentiveEarned' => $getflightData[$i]['IncentiveEarned']
);
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $getflightData[$i]['OfferedFare'], $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps);echo "</pre>";die('d');
$intOfferedFare = $arrPriceAndMarkUps['intOfferedFare'];
$intGTXMarkUp = ($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnGTXMarkUp = ($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intAgencyFixMarkUp = ($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUp = ($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency = $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency;
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
$publishFareForAgency = $intOfferedFare + $intGTXMarkUp;
$intPublishFare = $publishFareForAgency + $intTotalEarningsForAgency + $intTotalGSTAgencyEarnings;
//service tax for base fare
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($arrPriceAndMarkUps['intOfferedFare'], "F", 0);
//$netPriceArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount'])?$arrServiceTaxOnNetPayable['serviceTaxAmount']:0;
$netPriceArrayServiceTax = 0;
//service tax for GTX MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($arrPriceAndMarkUps['intGTXMarkUp'], "F", 0);
$GTXMarkupArrayServiceTax = 0;
//service tax for Agency MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax(@$arrPriceAndMarkUps['intAgencyMarkUp'], "F", 0);
$AgencyMarkupArrayServiceTax = $intSTaxOnAgencyFixMarkUp;
//service tax for Agent MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($MarkupArray[$i], "F", 0);
$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
$flightDetailMarkup = !empty($arrServiceTaxOnNetPayable['BasePrice']) ? $arrServiceTaxOnNetPayable['BasePrice'] : 0;
//end of service tax
$Taxes = 0;
//$totalCost = $intOfferedFare+$MarkupArray[$i]+$intGTXMarkUp+@$intAgencyFixMarkUp+$Taxes+$GTXMarkupArrayServiceTax+$AgencyMarkupArrayServiceTax+$MarkupArrayServiceTax+$arrPriceAndMarkUps['intTotalEarningsForAgency'];
//$totalCost = $grand_total[$i];
$totalCost = $getflightData[$i]['PublishedFare'];
$totalCostArray[$i] = $totalCost;
$TPId = trim($getflightData[$i]['AirlineSysId']);
$isPriceShared = 1;
$data = array(
'PlanBookingId' => $planbookingID,
'TPId' => $TPId,
'MasterTPSysId' => $leadID,
'Price' => $getflightData[$i]['OfferedFare'], //$total_cost[$i],
'TotalCost' => $totalCost,
'NetPrice' => $totalCost,
'StatusType' => '4',
'ProposalEmailTo' => $customeremail,
'PlanType' => 1,
'InventoryType' => 1,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaces' => $getflightData[$i]['SourcePlaceName'],
'SourcePlaceSysId' => $getflightData[$i]['SourcePlaceSysId'],
'DestinationPlacesSysId' => $getflightData[$i]['DestPlaceSysId'],
'DestinationPlaces' => $getflightData[$i]['DestPlaceName'],
'Cities' => $getflightData[$i]['SourcePlaceName'] . "-" . $getflightData[$i]['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => $post['supplierSysId'],
'IsHotelFromApi' => 0,
'CustomerSysId' => $customerRcord,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent']),
'IsPriceShared' => trim($isPriceShared),
'GSTSharedMode' => trim($gsttype),
'SACCode' => trim($SACCode),
'PackSpecType' => 4,
'EconomyMask' => 6,
'AgentServiceTaxAmount' => (float) $MarkupArrayServiceTax,
'AgencyMarkUp' => (float) $flightDetailMarkup
);
########### Start Add Data in Travel Table(Base Table) ###################
if ($i == 0) {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
} else {
$lastID = $lastID;
}
//$sessionLogin_lead_customer->leadID = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
if ($interNationalSearch == 1) {
$total_gst_ = isset($post['total_gst_roundTrip']) ? $post['total_gst_roundTrip'] : '';
} else {
$total_gst_ = $total_gst[$i];
}
$arrival_date = $getflightData[$i]['ArrivalTime'];
$departure_date = $getflightData[$i]['DepartureTime'];
$airData = array(
'TPIntSysId' => (int) $lasttravelitenaryID,
'AgencySysId' => (int) $agencySysID,
'FlightNumber' => $getflightData[$i]['FlightNumber'],
'AirlineSysId' => (int) $getflightData[$i]['AirlineSysId'],
'CreateDate' => $createDate,
'Cost' => $intOfferedFare,
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 18,
'AgentServiceTaxAmount' => (float) $total_gst_,
'AgentsCustomServiceTaxAmount' => 0,
'TotalCost' => (float) $totalCost,
'MarkUp' => (float) $getflightData[$i]['ServiceFee'] > 0 ? $getflightData[$i]['ServiceFee'] : 0,
'AgencyMarkUp' => 0,
'AgencyCommission' => 0,
'GTXMarkUp' => 0,
'FlightCabinClass' => !empty($sessionFlightSearchParams->params['flight_class']) ? $sessionFlightSearchParams->params['flight_class'] : 0,
'AdultPax' => (int) $adults,
'LocalFromTime' => $departure_date->format('Y-m-d H:i:s'),
'LocalToTime' => $arrival_date->format('Y-m-d H:i:s'),
'FromUTCTime' => $departure_date->format('Y-m-d H:i:s'),
'ToUTCTime' => $arrival_date->format('Y-m-d H:i:s'),
'ChildPax' => (int) $child,
'InfentPax' => (int) $infant,
'SourceAirportCode' => trim($getflightData[$i]['SourceAirportCode']),
'DestAirportCode' => trim($getflightData[$i]['DestAirportCode']),
'TripType' => (int) $tripType,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'SupplierSysId' => (int) $post['supplierSysId'],
'ICSourceSysId' => 0,
'InvnItemSysId' => (int) $getflightData[$i]['AirInvenSysId'],
'IsFromAPI' => 0,
'UpdateDate' => $createDate,
'encodedata' => $post['fareRuleOneWay'],
'APIBookingRes' => json_encode(array_values($PaxFareDetaials)),
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'AirlineRefPNR' => '',
'IsBookingStatus' => '',
'ICSourceSysId' => 9,
);
//echo "<pre>";print_r($airData);exit;
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
########### End Add Data in Travel Air Table ###################
}
}
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $getflightData[0]['SourceAirportCode'];
$OriginAirportArray = $objAirport->getAirportList();
$Origincity = $OriginAirportArray[0]['CityName'];
$objAirport->strAirportCode = $getflightData[0]['DestAirportCode'];
$DestinationAirportArray = $objAirport->getAirportList();
$DestinationCity = $DestinationAirportArray[0]['CityName'];
$path = $_SERVER['SERVER_NAME'] . '/public/assets/images/logo-global-travel.jpg';
$childDetails = ($adults > 0) ? ', ' . $adults . ' Child(ren) ' : '';
$InfantDetails = ($infant > 0) ? ', ' . $infant . ' Infant' : '';
if ($child > 0) {
$child = ', ' . $child . ' Child(s)';
} else {
$child = '';
}
if ($infant > 0) {
$infant = ', ' . $infant . ' Infant(s)';
} else {
$infant = '';
}
$totalPax = $adults . ' Adult(s)' . $child . $infant;
$bookingUrl = $this->view->baseUrl('flight-proposal/view-flight-proposal-quick/id/' . base64_encode($lastID));
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencySysID);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agentemail = trim($sessionLogin_user->EmailId);
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
if ($arrAgentDetail['IsB2CSite'] == 1) {
$bookingUrl = $arrAgentDetail['Url'] . "/detail/index/view/id/" . base64_encode($bookingUrl);
}
$getAgentDetail = array(
'AgentName' => $arrAgentDetail['FirstName'] . " " . $arrAgentDetail['LastName'],
'AgentContact' => $sessionLogin_user->contactnum,
'AgentEmailId' => $sessionLogin_user->EmailId,
'ContactNo1' => $arrAgentDetail['ContactNo1'],
'Signature' => $arrAgentDetail['Signature'],
'Logo' => $arrAgentDetail['Logo'],
'AgencySysId' => $arrAgentDetail['AgencySysId']
);
$html->assign('type', 'flightPreviewEmailForm');
$html->assign('customerDetails', $getcustomerdetails);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('getAgencyDetail', $getAgencyDetail);
$html->assign('Origincity', $Origincity);
$html->assign('DestinationCity', $DestinationCity);
$html->assign('departure_date', $departure_date);
$html->assign('getflightData', $getflightData);
$html->assign('childDetails', $childDetails);
$html->assign('InfantDetails', $InfantDetails);
$html->assign('sessionFlightSearchParams', $sessionFlightSearchParams->params);
$html->assign('isInternational', $isInternational);
$html->assign('flightValues', $flightValues);
$html->assign('tripType', $tripType);
$html->assign('totalCostArray', $totalCostArray);
$html->assign('totalCost', $totalCost);
$html->assign('allowooking', $post['allowooking']);
$html->assign('totalPax', $totalPax);
$html->assign('bookingUrl', $bookingUrl);
$html->assign('fareRuleOneWay', $post['fareRuleOneWay']);
$html->assign('dealsType', $dealsType);
$bodyText = $html->render('SendFlightQuickPropsal.phtml');
if ($dealsType == 1) {
$sourceCityText = explode(',', $sessionFlightSearchParams->params['sourceCityText']);
$Origincity = $sourceCityText[0];
$destinationCityText = explode(',', $sessionFlightSearchParams->params['destinationCityText']);
$DestinationCity = $destinationCityText[0];
}
// echo "<pre>";print_r($bodyText);die;
//echo $bodyText;die('mail');
//#end of send email to customer
//$emailSendId=(isset($getAgencyDetail['EmailIdForCustomer']) && !empty($getAgencyDetail['EmailIdForCustomer']) && ($getAgencyDetail['IsEmailIdForCustVarified']==1))?trim($getAgencyDetail['EmailIdForCustomer']):trim($agentemail);
$emailSendId = trim($agentemail);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailId = trim($customerEmail);
$subject = trim($getcustomerdetails['FirstName']) . " your " . $Origincity . " to " . $DestinationCity . " Flight details from " . trim($getAgencyDetail['DisplayName']);
$emailData = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => $subject, 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailDataAgent = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => $subject, 'to' => array(trim($getAgentDetail['AgentEmailId'])), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $lastID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinAgencyId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
// Added By Pardeep Panchal For Email Count Ends...
$mailsent = $this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $getcustomerdetails['CustomerSysId']);
$mailsent1 = $this->mailSentByElastice($emailDataAgent, $arrEmailStatistics);
//update acustomer
if ($leadID) {
$agencyuserArray = array(
'UpdateDate' => Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss')
);
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$whereAgencyCustomer = " AgencySysId=" . $this->intLoggedinAgencyId . " AND CustomerSysId=" . $customerRcord . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
//#end of update customer
if ($mailsent) {
$navarrow = ($tripType == 1) ? "→" : "⇄";
//echo print_r($sessionflightValuesId->params);die('dd');
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$primarycontact = $sessionLogin_user->ContactNo1 ? $sessionLogin_user->ContactNo1 : 'N/A';
$agencyDisplayName = $fromName;
$custname = $getcustomerdetails['FirstName'] ? trim($getcustomerdetails['FirstName']) . ' ' . trim($getcustomerdetails['LastName']) : 'Customer';
$whatsappmessageFlight = '';
if($isInternational==1 && $tripType==2 && !empty($flightValues)){
$objFlight = new Travel_Model_TblFlight();
$getflightData = $objFlight->getInterNationalFlightByMasterId($flightValues);
}
// echo "<pre>";print_r($getflightData);die;
foreach ($getflightData as $ffKey => $ffVal) {
if(!isset($ffVal['DepartureTime'])){
$ffVal['DepartureTime'] = $ffVal['OriginDepartureTime'];
}
if(!isset($ffVal['ArrivalTime'])){
$ffVal['ArrivalTime'] = $ffVal['DestArrivalTime'];
}
if($isInternational==1 && $tripType==2){
$totalCostArray[$ffKey] = $ffVal['PublishedFareTotal'];
//$airline_name[0] = $ffVal['AirlineName'];
}
$hours = floor($ffVal['FlightDuration'] / 60);
$minutes = ($ffVal['FlightDuration'] % 60);
$duration = '%0a%0a*Duration:* ' . $hours . 'h ' . $minutes . 'm,';
$routeDetail = '%0a' . trim($ffVal['SourceAirportCode']) . ' - ' . trim($ffVal['DestAirportCode']) . ' on ' . $ffVal['DepartureTime']->format('H:i M d, Y') . ' - ' . $ffVal['ArrivalTime']->format('H:i M d, Y');
$finalHtml = '%0a%0a*' . trim($ffVal['AirlineName']) . '(' . trim($ffVal['FlightNumber']) . '):*' . $routeDetail . $duration . '%0a%0a*Total Cost:* ' . trim($ffVal['CurrencySymbol']) . ' ' . round($totalCostArray[$ffKey]) . '/-';
$adultDetails = ($adults) ? $adults : '';
$childDetails = ($child > 0) ? ', ' . $child . ' Child(s)' : '';
$InfantDetails = ($infant > 0) ? ', ' . $infant . ' Infant(s)' : '';
$NoofPax = '%0a%0a*No of Pax:* ' . $totalPax;
$TravelDate = ($departure_date) ? '%0a%0a*Travel Date:* ' . $departure_date->format('d-M-y') : '';
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $ffVal['SourceAirportCode'];
$OriginAirportArr = $objAirport->getAirportList();
$SourcePlaceName = $OriginAirportArr[0]['CityName'];
$objAirport->strAirportCode = $ffVal['DestAirportCode'];
$DestinationAirportArr = $objAirport->getAirportList();
$DestPlaceName = $DestinationAirportArr[0]['CityName'];
$OrigincityTitle = $SourcePlaceName . ' (' . trim($ffVal['SourceAirportCode']) . ')';
$DestinationCityTitle = $DestPlaceName . ' (' . trim($ffVal['DestAirportCode']) . ')';
$whatsappmessageFlight .= "%0a%0a*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*%0a%0a*To Destination:* $DestinationCityTitle %0a%0a*From Destination:* $OrigincityTitle $NoofPax $finalHtml ";
}
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($bookingUrl, $this->BITLYLOGIN, $this->BITLYAPIKEY);
if ($bitly_response['errorCode'] == 0) {
$bookingUrl = $bitly_response['results'][trim($bookingUrl)]['shortUrl'];
}
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your Flight query for $DestinationCity from $Origincity.$whatsappmessageFlight %0a%0aTo view flight details and *book online* click on the below link:%0a$bookingUrl %0a%0aYou can also call $firstname at $primarycontact or email at $emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
// $whatsappmessage = "*Dear $custname*,%0a%0aThanks for your Flight query for $DestinationCity from $Origincity.%0a%0a*To Destination:* $DestinationCityTitle %0a%0a*From Destination:* $OrigincityTitle $NoofPax $finalHtml %0a%0aTo view flight details and *book online* click on the below link:%0a$bookingUrl %0a%0aYou can also call $firstname at $primarycontact or email at $emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
$response = array('status' => true, 'whatsapp' => $whatsappmessage, 'contactno' => trim($getcustomerdetails['countrycode']) . trim($getcustomerdetails['Contacts']), 'message' => 'Proposal sent to customer successfully');
echo json_encode($response);
exit;
} else {
$response = array('status' => false, 'message' => 'Oops unable send Proposal to customer. please try again..');
echo json_encode($response);
exit;
}
//echo 'Proposal sent to customer successfully';
} catch (Exception $err) {
print_r($err, true);
}
// echo "<pre>";print_r($post);
// echo "<pre>";print_r($AirInvenSysId);
// die('wait...');
}
}
public function getlogsAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$param = $this->getRequest()->getParams();
$folder = isset($param['folder']) ? $param['folder'] : '';
if (!empty($folder)) {
$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/" . $folder . '/';
} else {
$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/";
}
$file_folder_2 = scandir($file_folder, 1);
//echo '<pre>';print_r($file_folder_2);echo '</pre>';
//$file_folder = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/flight/FlightSearch/"; // folder to load files
if (is_dir($file_folder)) {
if ($file_folder_2) {
foreach ($file_folder_2 as $file) {
if (!empty($folder)) {
echo "file name:<a target='_blank' href='" . $this->baseUrl . "/public/logs/flight/" . $folder . "/" . $file . "'>" . $file . "</a><br>";
} else {
echo "Folder name:<a href='" . $this->baseUrl . "/flight/getlogs/folder/" . $file . "/'>" . $file . "</a><br>";
}
}
}
// if ($dh = opendir($file_folder)){
// while (($file = readdir($dh)) !== false){
// if(!empty($folder)){
// echo "file name:<a target='_blank' href='".$this->baseUrl."/public/logs/flight/".$folder."/".$file."'>" . $file . "</a><br>";
// }else{
// echo "Folder name:<a href='".$this->baseUrl."/flight/getlogs/folder/".$file."/'>" . $file . "</a><br>";
// }
// }
// closedir($dh);
// }
}
}
public function getbookdataAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$param = $this->getRequest()->getParams();
$TPSysId = isset($param['id']) ? $param['id'] : '';
$objFlight = new Travel_Model_TblFlight();
$traceIDData = $objFlight->GetFlightTempDataAll($TPSysId);
echo '<pre>';
print_r($traceIDData);
die;
}
public function checkArrayKeyExist($arr) {
$newArr = [];
foreach ($arr as $key => $value) {
if (strlen($arr[$key])) {
$newArr[$key] = $value;
}
}
return array_values(array_unique($newArr));
}
public function checkBookingStatusAction() {
$Bookres["bookingId"] = "TJ104122871928";
$Bookres["status"]["success"] = 1;
$response = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->bookingDetailsTripJack($Bookres, $this->intLoggedinAgencyId);
}
}