| 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 Hotel
*
* @name Buy List Hotel
* @author Harpreet
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Hotel Related function
*
*/
class BookingFlightController extends Catabatic_ValidateGtx {
private $intLoggedinUserId = '';
private $intLoggedinUserGroupSysId = '';
private $intLoggedinUserAgencySysId = '';
private $intLoggedinAgencyId = '';
private $intLoggedinUserTrxCurrency = '';
private $InfoSourceSysId = '';
private $baseUrl;
private $agencyDetails;
private $roleID;
private $intLoggedinUserFirstName;
private $intLoggedinUserEmailId;
private $intLoggedinUserContactNo;
private $CurrencyRate;
private $CurrencyTitle;
private $CurrencyId;
private $_crmcustomerObj;
private $_crmcustomertravelItenary;
private $_crmcusttravelplan;
private $_crmcusttravelplanAir;
private $paymentMdl;
private $_objFlight;
public function init() {
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinAgencyId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->agencyDetails = $sessionLogin_user->agencyDetails;
$this->roleID = $sessionLogin_user->UserRole;
$this->intLoggedinUserFirstName = $sessionLogin_user->FirstName;
$this->intLoggedinUserEmailId = $sessionLogin_user->EmailId;
$this->intLoggedinUserContactNo = $sessionLogin_user->ContactNo1;
if (!empty($this->intLoggedinUserAgencySysId)) {
$this->InfoSourceSysId = '2'; /* Information Source is Agent */
}
if (empty($this->intLoggedinUserId)) {
$this->_redirect('/login/');
}
$this->CurrencyRate = 1;
$this->CurrencyTitle = 'INR';
$this->CurrencyId = 1;
$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->paymentMdl = new Payment_Model_Payment();
$this->_objFlight = new Travel_Model_TblFlight();
}
// Added By Pardeep Panchal...
public function indexAction() {
//$param = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->view->AgencySysId = $this->intLoggedinUserAgencySysId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchArr = $getData;
$objFlight->searchArr = $getData;
}
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
if ($from_date != NULL && $to_date != NULL) {
$getData = array();
$getData = array(
'TravelToDate' => $to_date,
'TravelFromDate' => $from_date
);
$objFlight->searchArr = $getData;
}
if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
$strFlightBookingListSQL = $objFlight->getFlightBookingList();
} else {
$strFlightBookingListSQL = $objFlight->getFlightBookingList($ReportingToSysId);
}
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($strFlightBookingListSQL));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->controller = $this;
$this->view->arrFlightBookingList = $paginator;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($this->intLoggedinUserAgencySysId);
$this->view->leadSourceList = $getleadSource;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($this->roleID);
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsAbleToManageTask'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId, $this->ReportingToSysId);
}
$this->view->agencyUser = $agencyUser;
$AgencyWhatsappEnabled = $this->_helper->General->getWhatsappEnabledSetting();
$this->view->whatsappEnabled = $AgencyWhatsappEnabled;
// echo "<pre>" ; print_r($strFlightBookingListSQL) ; die();
}
public function queueAction() {
//
//$param = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
// echo "<pre>";
// print_r($param);
// exit;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchArr = $getData;
$objFlight->searchArr = $getData;
}
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
if ($from_date != NULL && $to_date != NULL) {
$getData = array();
$getData = array(
'TravelToDate' => $to_date,
'TravelFromDate' => $from_date
);
$objFlight->searchArr = $getData;
}
if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
$strFlightBookingListSQL = $objFlight->getFlightBookingListQueue();
} else {
$strFlightBookingListSQL = $objFlight->getFlightBookingListQueue($ReportingToSysId);
}
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($strFlightBookingListSQL));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->controller = $this;
$this->view->arrFlightBookingList = $paginator;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$AgencyWhatsappEnabled = $this->_helper->General->getWhatsappEnabledSetting();
$this->view->whatsappEnabled = $AgencyWhatsappEnabled;
}
public function holdAction() {
//$param = $this->getRequest()->getParams();
$objFlight = new Travel_Model_TblFlight();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
// echo "<pre>";
// print_r($param);
// exit;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchArr = $getData;
$objFlight->searchArr = $getData;
}
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
if ($from_date != NULL && $to_date != NULL) {
$getData = array();
$getData = array(
'TravelToDate' => $to_date,
'TravelFromDate' => $from_date
);
$objFlight->searchArr = $getData;
}
if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
$strFlightBookingListSQL = $objFlight->getFlightBookingListHold();
} else {
$strFlightBookingListSQL = $objFlight->getFlightBookingListHold($ReportingToSysId);
}
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($strFlightBookingListSQL));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->controller = $this;
$this->view->arrFlightBookingList = $paginator;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($this->intLoggedinUserAgencySysId);
$this->view->leadSourceList = $getleadSource;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($this->roleID);
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsAbleToManageTask'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId, $this->ReportingToSysId);
}
$this->view->agencyUser = $agencyUser;
$AgencyWhatsappEnabled = $this->_helper->General->getWhatsappEnabledSetting();
$this->view->whatsappEnabled = $AgencyWhatsappEnabled;
}
public function viewFlightBookingAction() {
$intTPSysId = $this->view->TPSysId = base64_decode($this->getRequest()->getParam("id"));
$version = $this->view->version = $this->getRequest()->getParam("version");
$objFlight = new Travel_Model_TblFlight();
$arrFlightBookingList = $objFlight->viewFlightBookingDetails($intTPSysId, $version);
// echo "<pre>";print_r($arrFlightBookingList);echo "</pre>";die;
$this->view->arrFlightBookingList = $arrFlightBookingList;
$intCustomerSysId = $arrFlightBookingList[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
}
public function viewBookingVoucherAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
// $arrCustomerInvoiceData = $objFlight->customerInvoiceData($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
// echo "<pre>";print_r($arrCustomerInvoiceData);echo "</pre>";exit;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
}
public function customerInvoiceAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$code = $this->getRequest()->getParam("code");
$Id = $this->getRequest()->getParam("id");
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$TblMiscellaneous = new Travel_Model_TblMiscellaneous();
$getProposalInvoiceData = $TblMiscellaneous->getProposalInvoiceData($intTPSysId,$this->intLoggedinAgencyId);
if(isset($getProposalInvoiceData['MasterMiscSysId']) && !empty($getProposalInvoiceData['MasterMiscSysId'])){
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($getProposalInvoiceData['MasterMiscSysId'])), 1);
$this->_redirect('finance/miscellaneous/printinvoice/id/' . base64_encode($getProposalInvoiceData['MasterMiscSysId']) . '/code/' . $secureCode);
}
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$FlightFareBreakdown = $objFlight->getSelectedFlightFareDetails();
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
$arrAgencyDetail = [];
if ($IsB2BProposal == 1) {
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($B2BAgencySysId);
}
$this->view->getCustomerDetails = $getCustomerDetails;
$this->view->FlightFareBreakdown = $FlightFareBreakdown;
$this->view->arrAgencyDetail = $arrAgencyDetail;
// echo "<pre>";
// print_r($FlightFareBreakdown);
// exit;
$RoomInfoJson = $arrCustomerInvoiceData[0]['RoomInfoJson'];
$intAdultsCT = 0;
$intChildsCT = 0;
$intInfantsCT = 0;
$paxTOtalArr = json_decode($RoomInfoJson);
if (!empty($paxTOtalArr)) {
foreach ($paxTOtalArr as $PaxTotal) {
$intAdultsCT += @$PaxTotal->Adult;
$intChildsCT += @$PaxTotal->Child;
$intInfantsCT += @$PaxTotal->Infant;
$departuredate = @$PaxTotal->departuredate;
$returndate = trim(@$PaxTotal->returndate);
$totalmember = trim(@$PaxTotal->totalmember);
}
}
$intTatalPaxCT = $intAdultsCT + $intChildsCT;
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$arrSelectedFlightFareDetails = $objFlight->getSelectedFlightFareDetails();
$intPLBEarnedTotal = 0;
$intTdsOnPLBTotal = 0;
$intIncentiveEarnedTotal = 0;
$intTdsOnIncentiveTotal = 0;
$intTotalOfferedFare = 0;
$intTotalAgencyCommisionFixANDPercent = 0;
$intTotalCommisionEarnedForAgency = 0;
$intAgentPLBEarned = 0;
$intAgentIncentiveEarned = 0;
$intTotalAgencyFixMarkUp = 0;
$intTotalAgencyTdsOnCommission = 0;
$intTatalSTax = 0;
$intSTaxOnGTXMarkUp = 0;
$intSTaxOnAgencyFixMarkUp = 0;
$intGSTOnAgencyCommisionEarned = 0;
$intGSTOnAgencyPLBEarned = 0;
$intGSTOnAgencyIncentiveEarned = 0;
//echo "<pre>";print_r($arrSelectedFlightFareDetails);exit;
$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++;
}
}
//$intTotalOfferedForAllPax = [];
foreach ($arrFlightFare as $key => $FareBreakdown) {
$intYQTaxToT = 0;
$intTotalOfferedForAllPax = [];
//echo "<pre>";print_r($FareBreakdown);die;
foreach ($FareBreakdown as $k => $result) {
$intTBQAirInvenAPISysId = $result['TBQAirInvenAPISysId'];
$intCurrency = $result['Currency'];
$intPassengerType = $result['PassengerType'];
$intOfferedFare = $result['OfferedFare'];
$intPublishedFare = $result['PublishedFare'];
$intYQTaxToT += $result['YQTax'];
$intAdditionalTxnFeeOfrd = $result['AdditionalTxnFeeOfrd'];
$intAdditionalTxnFeePub = $result['AdditionalTxnFeePub'];
$intServiceFee = $result['ServiceFee'];
$intOtherCharges = $result['OtherCharges'];
$intServiceFee = $result['ServiceFee'];
$intTdsOnCommission = $result['TdsOnCommission'];
$intPLBEarned = $result['PLBEarned'];
$intTdsOnPLB = $result['TdsOnPLB'];
$intIncentiveEarned = $result['IncentiveEarned'];
$intTdsOnIncentive = $result['TdsOnIncentive'];
$intCommissionEarned = $result['CommissionEarned'];
$arrAllCommissions = array(
'intCommissionEarned' => $intCommissionEarned,
'intPLBEarned' => $intPLBEarned,
'intIncentiveEarned' => $intIncentiveEarned
);
$intTotalDisCount = $intCommissionEarned + $intPLBEarned + $intIncentiveEarned;
$intDiscountPerHead = $intTotalDisCount / $intTatalPaxCT;
$intOfferedFare = ($intOfferedFare);
if ($intPassengerType == 1) {
$intPassengerCount = $result['PassengerCount'];
$intBaseFare = $result['BaseFare'];
$intTax = $result['Tax'];
$intFarePerHeadPublish = $intBaseFare + $intTax + $intOtherCharges;
$intDiscountPerHead = ($intDiscountPerHead * $intPassengerCount);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead;
$intAdultFareOffered = $intBaseFareCal + $intTax;
$intTotalOfferedForAllPax[] = $intAdultFareOffered;
}
if ($intPassengerType == 2) {
$intPassengerCount = $result['PassengerCount'];
$intBaseFare = $result['BaseFare'];
$intTax = $result['Tax'];
$intFarePerHeadPublish = $intBaseFare + $intTax;
$intDiscountPerHead = ($intDiscountPerHead * $intPassengerCount);
$intBaseFareCal = $intBaseFare - $intDiscountPerHead;
$intChildFareOffered = $intBaseFareCal + $intTax;
$intTotalOfferedForAllPax[] = $intChildFareOffered;
}
if ($intPassengerType == 3) {
$intPassengerCount = $result['PassengerCount'];
$intBaseFare = $result['BaseFare'];
$intTax = $result['Tax'];
$intFarePerHeadPublish = $intBaseFare + $intTax;
$intInfantFareOffered = $intBaseFare + $intTax;
$intTotalOfferedForAllPax[] = $intInfantFareOffered;
}
}
}
//echo "<pre>";print_r($intTotalOfferedForAllPax);echo "</pre>";
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
// echo "<pre>";print_r($arrCustomerInvoiceData[0]);echo "</pre>";die;
$this->view->intTotalOfferedForAllPax = $intTotalOfferedForAllPax;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$arrAPIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
if (is_array($arrAPIBookingRes)) {
$arrAPIBookingRes = $arrAPIBookingRes;
} else {
$arrAPIBookingRes = json_decode($arrAPIBookingRes, true);
}
$arrPassenger = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['Passenger']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['Passenger'] : '';
$Segments = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['Segments']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['Segments'] : '';
$InvoiceNo = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['InvoiceNo']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['InvoiceNo'] : '';
$InvoiceCreatedOn = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['InvoiceCreatedOn']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['InvoiceCreatedOn'] : '';
$CancellationCharges = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['CancellationCharges']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['CancellationCharges'] : '';
$FareRuleDetails = isset($arrAPIBookingRes['Response']['Response']['FlightItinerary']['FareRules']) ? $arrAPIBookingRes['Response']['Response']['FlightItinerary']['FareRules'] : '';
$sectorFrom = [];
$sectorTo = [];
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
if ($Segments) {
foreach ($Segments as $value) {
$Origin = $value['Origin']['Airport']['AirportCode'];
$Destination = $value['Destination']['Airport']['AirportCode'];
$sectorFrom[] = $Origin;
$sectorTo[] = $Destination;
}
}
$array = array_merge($sectorFrom, $sectorTo);
$arr1[] = array_shift($array);
$arr1[] = array_shift($array);
$arr2 = array_unique($array);
$new_codes = array_merge($arr1, $arr2);
$sector_codes = (implode('-', $new_codes));
if ($IsInternational) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$invoiceData = [];
if ($arrPassenger) {
$intPaxCT = 1;
$SegmentAdditionalInfo = [];
$Meal = [];
$AgencyMarkUp = ($arrCustomerInvoiceData[0]['AgencyMarkUp'] + $arrCustomerInvoiceData[0]['AgencyCommission'] + $arrCustomerInvoiceData[0]['MarkUp']);
//$ARR_SALUTION = unserialize(ARR_SALUTION);
foreach ($arrPassenger as $ks => $trevllerValue) {
$SegmentsAr = isset($Segments[0]) ? $Segments[0] : $Segments[0];
$Origin = $SegmentsAr['Origin']['Airport']['AirportCode'];
$Destination = $SegmentsAr['Destination']['Airport']['AirportCode'];
$AirlineCode = $SegmentsAr['Airline']['AirlineCode'];
$FlightNumber = $SegmentsAr['Airline']['FlightNumber'];
$FareClass = $SegmentsAr['Airline']['FareClass'];
$Ssr0 = isset($trevllerValue['Ssr'][0]) ? $trevllerValue['Ssr'][0]['SsrCode'] : '';
$Ssr1 = isset($trevllerValue['Ssr'][1]) ? $trevllerValue['Ssr'][1]['SsrCode'] : '';
$CustomerTitle = $trevllerValue['Title'];
$intBaseFare = $BaseFare = $trevllerValue['Fare']['BaseFare'];
// $K3GST = isset($trevllerValue['Fare']['TaxBreakup'][0])?$trevllerValue['Fare']['TaxBreakup'][0]['value']:'0';
$K3GST = 0;
$TaxBreakup = $trevllerValue['Fare']['TaxBreakup'];
$YQTax = $trevllerValue['Fare']['YQTax'];
$TotalBaggageCharges = $trevllerValue['Fare']['TotalBaggageCharges'];
$TotalMealCharges = $trevllerValue['Fare']['TotalMealCharges'];
$TotalSeatCharges = $trevllerValue['Fare']['TotalSeatCharges'];
$TotalSpecialServiceCharges = $trevllerValue['Fare']['TotalSpecialServiceCharges'];
$CommissionEarned = $trevllerValue['Fare']['CommissionEarned'];
$PLBEarned = $trevllerValue['Fare']['PLBEarned'];
$IncentiveEarned = $trevllerValue['Fare']['IncentiveEarned'];
$OfferedFare = $trevllerValue['Fare']['OfferedFare'];
$intOtherCharges = $trevllerValue['Fare']['OtherCharges'];
$ServiceFee = $trevllerValue['Fare']['ServiceFee'];
$AdditionalTxnFeepub = $trevllerValue['Fare']['AdditionalTxnFeePub'];
$AdditionalTxnFeeOfrd = $trevllerValue['Fare']['AdditionalTxnFeeOfrd'];
$intTax = $trevllerValue['Fare']['Tax'];
$TdsOnCommission = $trevllerValue['Fare']['TdsOnCommission'];
$TdsOnIncentive = $trevllerValue['Fare']['TdsOnIncentive'];
$TdsOnPLB = $trevllerValue['Fare']['TdsOnPLB'];
$intTax = $intTax - $CommissionEarned;
//echo '<pre>';print_r($sector);
$arrAllCommissions = array(
'intCommissionEarned' => $CommissionEarned,
'intPLBEarned' => $PLBEarned,
'intIncentiveEarned' => $IncentiveEarned
);
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $OfferedFare, $intCountryCode);
$intGTXMarkUp = $arrPriceAndMarkUps['intGTXMarkUp'];
// echo '<pre>';
// var_dump((int) $arrCustomerInvoiceData[0]['TripType']);
// echo '</pre>';
if ($IsInternational) {
$intTotalOtherCharge = $intOtherCharges + ($intGTXMarkUp * (int) $TripType);
} else {
$intTotalOtherCharge = $intOtherCharges + ($intGTXMarkUp);
}
$CustomerFirstName = $trevllerValue['FirstName'];
$CustomerLastName = $trevllerValue['LastName'];
$Status = (isset($trevllerValue['Ticket']['Status']) && !empty($trevllerValue['Ticket']['Status']) ? $trevllerValue['Ticket']['Status'] : '');
$TicketNumber = (isset($trevllerValue['Ticket']['TicketNumber']) && !empty($trevllerValue['Ticket']['TicketNumber']) ? $trevllerValue['Ticket']['TicketNumber'] : '');
$TicketId = (isset($trevllerValue['Ticket']['TicketId']) && !empty($trevllerValue['Ticket']['TicketId']) ? $trevllerValue['Ticket']['TicketId'] : '');
$ValidatingAirline = (isset($trevllerValue['Ticket']['ValidatingAirline']) && !empty($trevllerValue['Ticket']['ValidatingAirline']) ? $trevllerValue['Ticket']['ValidatingAirline'] : '');
$SegmentAdditionalInfo[$ks] = (isset($trevllerValue['SegmentAdditionalInfo'][0]['Baggage']) && !empty($trevllerValue['SegmentAdditionalInfo'][0]['Baggage']) ? $trevllerValue['SegmentAdditionalInfo'][0]['Baggage'] : array());
$Mealother = (isset($trevllerValue['SegmentAdditionalInfo'][0]['Meal']) && !empty($trevllerValue['SegmentAdditionalInfo'][0]['Meal']) ? $trevllerValue['SegmentAdditionalInfo'][0]['Meal'] : array());
if (!empty($Mealother)) {
$Meal[] = $Mealother;
} else {
$Meal[] = (isset($trevllerValue['Meal']['Description']) && !empty($trevllerValue['Meal']['Description']) ? $trevllerValue['Meal']['Description'] . '(subject to availability)' : array());
}
$fare = isset($intTotalOfferedForAllPaxs[$ks]) ? $intTotalOfferedForAllPaxs[$ks] : '0';
$TotalFare = $fare + $AdditionalTxnFeeOfrd + $ServiceFee + $intTotalOtherCharge + $TotalBaggageCharges + $TotalMealCharges;
$tnumber = (isset($arrtravellerList[$TicketId]['ChangeRequestStatus']) && $arrtravellerList[$TicketId]['ChangeRequestStatus'] == '1') ? 'Cancelled' : $TicketNumber;
$invoiceData[] = array(
'ProposalID' => $arrCustomerInvoiceData[0]['TPSysId'] . "/V" . $arrCustomerInvoiceData[0]['VersionId'],
'TPSysId' => $arrCustomerInvoiceData[0]['TPSysId'],
'MasterTPSysId' => 0,
'AgentSysId' => $arrCustomerInvoiceData[0]['AgentSysId'],
'CustomerSysId' => $arrCustomerInvoiceData[0]['CustomerSysId'],
'SACCode' => '',
'InvoiceDate' => $InvoiceCreatedOn,
'Price' => $TotalFare,
'DiscountVal' => 0,
'TotalMarkUpApply' => $AgencyMarkUp,
'BaseCost' => 0,
'NETTOTAL' => 0,
'adultPax' => $intAdultsCT,
'childPax' => $intChildsCT,
'description' => $ValidatingAirline . ' ' . $tnumber . ". Adult:-" . $intAdultsCT . " Child:-" . $intChildsCT . " Departure Date:-" . $sector_codes . ' Flight:-' . $AirlineCode . '' . $FlightNumber,
'departuredate' => '', //$departuredate,
'InvoiceType' => 'flight',
);
}
}
// echo "<pre>";print_r($invoiceData);die;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
}
public function eTicketAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$Id = $this->getRequest()->getParam("id");
$versionId = ($this->getRequest()->getParam("version"));
$code = ($this->getRequest()->getParam("code"));
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$FlightFareBreakdown = $objFlight->getSelectedFlightFareDetails();
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
// echo "<pre>";
// print_r($arrCustomerInvoiceData);
// echo "</pre>";
$this->view->arrtravellerList = $arrtravellerList;
$this->view->FlightFareBreakdown = $FlightFareBreakdown;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$IsInternational = !empty($arrCustomerInvoiceData[0]['IsInternational']) ? $arrCustomerInvoiceData[0]['IsInternational'] : 0;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
$this->view->getSupportContact = $getSupportContact;
}
public function eTickettjAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$Id = $this->getRequest()->getParam("id");
$versionId = ($this->getRequest()->getParam("version"));
$code = ($this->getRequest()->getParam("code"));
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$IsInternational = !empty($arrCustomerInvoiceData[0]['IsInternational']) ? $arrCustomerInvoiceData[0]['IsInternational'] : 0;
if ($ICSourceSysId == 3) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
if ($TripType == '3') {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
}
}
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
$this->view->getSupportContact = $getSupportContact;
// echo "<pre>";
// print_r($intTPSysId);
// print_r($arrtravellerList);
// echo "</pre>";
// die;
}
public function eTicketNewAction() {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$Id = $this->getRequest()->getParam("id");
$code = ($this->getRequest()->getParam("code"));
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$IsInternational = !empty($arrCustomerInvoiceData[0]['IsInternational']) ? $arrCustomerInvoiceData[0]['IsInternational'] : 0;
if ($ICSourceSysId == 3) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
if ($TripType == '2' && $IsInternational == 0) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else if ($TripType == '3') {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
}
}
// echo "<pre>";
// print_r($arrCustomerInvoiceData);
// die;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
$this->view->getSupportContact = $getSupportContact;
// echo "<pre>";
// print_r($intTPSysId);
// print_r($arrtravellerList);
// echo "</pre>";
// die;
}
public function eTicketMailAction() {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$Id = $this->getRequest()->getParam("id");
$versionId = ($this->getRequest()->getParam("version"));
$code = $this->getRequest()->getParam("code");
$this->view->woq = $woq = $this->getRequest()->getParam("woq");
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['TPSysId' => $intTPSysId, 'IsApproved' => 0, 'version' => $versionId];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$this->view->CustomerDetails = $apiResponse['CustomerDetails'];
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$this->view->TCFlightTicket = $TCFlightTicket = isset($apiResponse['TCFlightTicket']) ? $apiResponse['TCFlightTicket'] : '';
$arrtraveller = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $valpax) {
$arrtraveller[$valpax['VersionId']][] = $valpax;
}
}
// echo "<pre>";
// print_r($apiResponse);
// print_r($arrtravellerList);
// die;
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
$this->view->arrtraveller = $arrtraveller;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
if ($this->getRequest()->isPost() && $this->getRequest()->isXmlHttpRequest()) {
$TripType = $bookingDataByAPI[0]['TripType'];
$SourceAirportCode = $bookingDataByAPI[0]['SourceAirportCode'];
$DestAirportCode = $bookingDataByAPI[0]['DestAirportCode'];
$AgencySysId = $bookingDataByAPI[0]['AgencySysId'];
$AgentSysId = $bookingDataByAPI[0]['AgentSysId'];
$intLoggedinUserEmailId = $bookingDataByAPI[0]['PrimaryEmail'];
$navarrow = ($TripType == 1) ? "→" : "⇄";
$withprice = ($this->getRequest()->getParam("withprice"));
$emailId = ($this->getRequest()->getParam("emailId"));
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$html->assign('type', 'mailToCustomer');
$html->assign('bookingDataByAPI', $bookingDataByAPI);
$html->assign('arrtraveller', $arrtraveller);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('CustomerDetails', $apiResponse['CustomerDetails']);
$html->assign('getSupportContact', $getSupportContact);
$html->assign('intTPSysId', $this->getRequest()->getParam("id"));
$html->assign('version', $versionId);
$html->assign('withprice', $withprice);
$html->assign('TCFlightTicket', $TCFlightTicket);
$html->assign('woq', $woq);
$bodyText = $html->render('e-ticket-mail.phtml');
$subject = "Flight Booking Itinerary From " . trim($SourceAirportCode) . " " . $navarrow . " " . trim($DestAirportCode);
$customerEmailId = $emailId;
$emailData = array('fromEmail' => trim($intLoggedinUserEmailId), 'fromName' => trim($bookingDataByAPI[0]['MasterDisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $intLoggedinUserEmailId), '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" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$sent = $this->mailSentByElastice($emailData, $arrEmailStatistics);
if ($sent) {
$response = array('success' => true, 'msg' => 'Email sent successfully.');
echo json_encode($response);
exit;
}
} catch (Exception $err) {
print_r($err, true);
}
}
}
public function eTicketMailDownloadAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$this->view->woq = $woq = $this->getRequest()->getParam("woq");
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['TPSysId' => $intTPSysId, 'IsApproved' => 0, 'version' => $versionId];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$CustomerDetails = $apiResponse['CustomerDetails'];
$bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$this->view->TCFlightTicket = $TCFlightTicket = isset($apiResponse['TCFlightTicket']) ? $apiResponse['TCFlightTicket'] : '';
$arrtraveller = [];
if ($arrtravellerList) {
foreach ($arrtravellerList as $valpax) {
$arrtraveller[$valpax['VersionId']][] = $valpax;
}
}
//$bookingDataByAPI = $objFlight->bookingDataByAPI($intTPSysId, $versionId);
$XRefBookingId = $bookingDataByAPI[0]['XRefBookingId'];
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
//$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
//$getSupportContact = $objAgency->getSupportContactForB2b('', $this->agencyDetails['SecurityKey']);
$this->view->arrtraveller = $arrtraveller;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$params = array(
'baseUrl' => $this->baseUrl,
'intTPSysId' => $intTPSysId,
'arrtraveller' => $arrtraveller,
'arrtravellerList' => $arrtravellerList,
'getSupportContact' => $getSupportContact,
'bookingDataByAPI' => $bookingDataByAPI,
'version' => $versionId,
'CustomerDetails' => $CustomerDetails,
'withprice' => 1,
'woq' => $woq,
'TCFlightTicket' => $TCFlightTicket,
);
// echo "<pre>";
// print_r($params);
// die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign($params);
$Body = $html->render('e-ticket-mail-download.phtml');
$html = <<<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
$Body
EOF;
// echo $html;
// exit;
Zend_Controller_Action_HelperBroker::getStaticHelper("DownloadPdf")->savedownloadpdf($html, $XRefBookingId);
exit();
}
public function invoiceNewAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$Id = $this->getRequest()->getParam("id");
$code = $this->getRequest()->getParam("code");
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$objFlight = new Travel_Model_TblFlight();
$objAgency = new Travel_Model_TblAgency();
$TblMiscellaneous = new Travel_Model_TblMiscellaneous();
$getProposalInvoiceData = $TblMiscellaneous->getProposalInvoiceData($intTPSysId,$this->intLoggedinAgencyId);
if(isset($getProposalInvoiceData['MasterMiscSysId']) && !empty($getProposalInvoiceData['MasterMiscSysId'])){
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($getProposalInvoiceData['MasterMiscSysId'])), 1);
$this->_redirect('finance/miscellaneous/printinvoice/id/' . base64_encode($getProposalInvoiceData['MasterMiscSysId']) . '/code/' . $secureCode);
}
$bookingDataByAPI = $objFlight->bookingDataByAPI($intTPSysId, $versionId);
// echo "<pre>";
// print_r($getProposalInvoiceData);
// die('ddd');
$IsInternational = $bookingDataByAPI[0]['IsInternational'];
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
//$getSupportContact = $objAgency->getSupportContactForB2b('', $this->agencyDetails['SecurityKey']);
$FareBreakdownarr = [];
$FlightNumber = [];
if ($bookingDataByAPI) {
foreach ($bookingDataByAPI as $value) {
if ($value['Segments']) {
foreach ($value['Segments'] as $flight) {
//$FlightNumber[] = $flight['FlightNumber'];
$FlightNumber[$flight['OriginAirportCode'] . '-' . $flight['DestAirportCode']] = $flight['FlightNumber'];
}
}
$AddTotalCost = isset($value['AddTotalCost']) ? ($value['AddTotalCost'] / count($value['FareBreakdown'])) : 0;
// echo "<pre>";
// print_r($value);
// echo "</pre>";
if ($value['FareBreakdown']) {
foreach ($value['FareBreakdown'] as $fare) {
$PassengerCount = $fare['PassengerCount'];
$FareBreakdownarr[$fare['PassengerType']]['PassengerCount'] = $fare['PassengerCount'];
$FareBreakdownarr[$fare['PassengerType']]['BaseFare'] += ($fare['BaseFare'] / $PassengerCount);
$FareBreakdownarr[$fare['PassengerType']]['Tax'] += $fare['Tax'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['YQTax'] += $fare['YQTax'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['CommissionEarned'] += $fare['CommissionEarned'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['OtherCharges'] += $fare['OtherCharges'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['FixedMarkUp'] += $fare['FixedMarkUp'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['GSTOnMarkUp'] += $fare['GSTOnMarkUp'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['Discount'] += $fare['Discount'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['TDSEarn'] += $fare['TDSEarn'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['MF'] += $fare['MF'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['AGST'] += $fare['AGST'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['MFT'] += $fare['MFT'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['YR'] += $fare['YR'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['couponVal'] += $fare['couponVal'] / $PassengerCount;
$FareBreakdownarr[$fare['PassengerType']]['AddTotalCost'] += $AddTotalCost / $PassengerCount;
}
}
}
}
$URL = GTX_API_URL . '/flight/v3/get-agency-term-and-condtions';
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['AgencySysId' => $this->intLoggedinAgencyId];
$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightInvoice = isset($TermsAndCondition['results']['FlightInvoice']) ? $TermsAndCondition['results']['FlightInvoice'] : '';
// echo "<pre>";
// print_r($FlightInvoice);
// die;
$this->view->TaxLabelId = $this->agencyDetails['TaxLabelId'];
$this->view->arrtravellerList = $arrtravellerList;
$this->view->FlightInvoice = $FlightInvoice;
$this->view->getSupportContact = $getSupportContact;
$this->view->bookingDataByAPI = $bookingDataByAPI;
$this->view->FareBreakdownarr = $FareBreakdownarr;
$this->view->FlightNumber = $FlightNumber;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $bookingDataByAPI[0]['CustomerSysId'];
}
public function downloadTicketNewAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$objFlight = new Travel_Model_TblFlight();
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
if ($ICSourceSysId == 3) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
}
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
// echo "<pre>";
// print_r($intTPSysId);
// print_r($arrtravellerList);
// echo "</pre>";
// die;
}
public function downloadTickettjAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$objFlight = new Travel_Model_TblFlight();
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$IsInternational = !empty($arrCustomerInvoiceData[0]['IsInternational']) ? $arrCustomerInvoiceData[0]['IsInternational'] : 0;
if ($ICSourceSysId == 3) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
if ($TripType == '2' && $IsInternational == 0) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
}
}
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->withprice = 1;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
}
public function customerInvoicetjAction() {
$this->_helper->layout->disableLayout();
// $intTPSysId = base64_decode($this->getRequest()->getParam("id")); old
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$code = $this->getRequest()->getParam("code");
$Id = $this->getRequest()->getParam("id");
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$bookingId = ($this->getRequest()->getParam("bkid"));
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$TblMiscellaneous = new Travel_Model_TblMiscellaneous();
$getProposalInvoiceData = $TblMiscellaneous->getProposalInvoiceData($intTPSysId,$this->intLoggedinAgencyId);
if(isset($getProposalInvoiceData['MasterMiscSysId']) && !empty($getProposalInvoiceData['MasterMiscSysId'])){
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($getProposalInvoiceData['MasterMiscSysId'])), 1);
$this->_redirect('finance/miscellaneous/printinvoice/id/' . base64_encode($getProposalInvoiceData['MasterMiscSysId']) . '/code/' . $secureCode);
}
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$AgencySysId = $arrCustomerInvoiceData[0]['AgencySysId'];
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
$arrAgencyDetail = [];
if ($IsB2BProposal == 1) {
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($B2BAgencySysId);
}
// echo "<pre>";
// print_r($arrCustomerInvoiceData);
// die;
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);arrAgencyDetail
$URL = GTX_API_URL . '/flight/v3/get-agency-term-and-condtions';
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['AgencySysId' => $this->intLoggedinAgencyId];
$TermsAndCondition = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightInvoice = isset($TermsAndCondition['results']['FlightInvoice']) ? $TermsAndCondition['results']['FlightInvoice'] : '';
$this->view->TaxLabelId = $this->agencyDetails['TaxLabelId'];
$this->view->FlightInvoice = $FlightInvoice;
$this->view->getCustomerDetails = $getCustomerDetails;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->arrAgencyDetail = $arrAgencyDetail;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign('type', 'mailToCustomer');
// $html->assign('arrtravellerList', $arrtravellerList);
// $html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
// $html->assign('arrTrevllerDetails', $arrTrevllerDetails);
// $html->assign('intTPSysId', $this->getRequest()->getParam("intTPSysId"));
// $html->assign('version', $versionId);
// $html->render('e-ticket-TJ.phtml');
}
public function downloadCustomerInvoicetjAction() {
$this->_helper->layout->disableLayout();
// $intTPSysId = base64_decode($this->getRequest()->getParam("id")); old
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$bookingId = ($this->getRequest()->getParam("bkid"));
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$AgencySysId = $arrCustomerInvoiceData[0]['AgencySysId'];
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
$arrAgencyDetail = [];
if ($IsB2BProposal == 1) {
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($B2BAgencySysId);
}
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
$this->view->getCustomerDetails = $getCustomerDetails;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$this->view->arrAgencyDetail = $arrAgencyDetail;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign('type', 'mailToCustomer');
// $html->assign('arrtravellerList', $arrtravellerList);
// $html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
// $html->assign('arrTrevllerDetails', $arrTrevllerDetails);
// $html->assign('intTPSysId', $this->getRequest()->getParam("intTPSysId"));
// $html->assign('version', $versionId);
// $html->render('e-ticket-TJ.phtml');
}
public function creditNoteAction() {
try {
$this->_helper->layout->disableLayout();
// $intTPSysId = base64_decode($this->getRequest()->getParam("id")); old
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$bookingId = ($this->getRequest()->getParam("bkid"));
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$amendmentId = $arrCustomerInvoiceData[0]['ChangeRequestId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
if ($IsInternational) {
$intCountryCode = 'INT';
} else {
$intCountryCode = 'IN';
}
$intMarkUp = $this->getCancelCharge($intCountryCode);
// echo '<pre>';
// print_r($getCustomerDetails);
if (!empty($amendmentId)) {
$ModificationData = $objFlight->CreditNoteModificationData($amendmentId);
}
$RequestData = json_decode($ModificationData['RequestData'], true);
//$RequestData = json_decode('{"bookingId":"TJS101400055720","amendmentId":"9500055723","amendmentStatus":"SUCCESS","refundableAmount":696,"trips":[{"src":"DEL","dest":"BOM","departureDate":"2021-06-11T05:30","flightNumbers":["5379"],"airlines":["6E"],"travellers":[{"fn":"Md","ln":"Sabir","amendmentCharges":2452.7,"refundableamount":348,"totalFare":2800.7},{"fn":"Aaliya","ln":"Khan","amendmentCharges":2452.7,"refundableamount":348,"totalFare":2800.7}]},{"src":"DEL","dest":"BOM","departureDate":"2021-06-11T05:30","flightNumbers":["5379"],"airlines":["6E"],"travellers":[{"fn":"Md","ln":"Sabir","amendmentCharges":2452.7,"refundableamount":348,"totalFare":2800.7},{"fn":"Aaliya","ln":"Khan","amendmentCharges":2452.7,"refundableamount":348,"totalFare":2800.7}]}],"status":{"success":true,"httpStatus":200},"metaInfo":[]}', true);
$travellersRefund = [];
if ($RequestData['trips']) {
foreach ($RequestData['trips'] as $value) {
foreach ($value['travellers'] as $k => $pax) {
$travellersRefund[$k]['amendmentCharges'] += $pax['amendmentCharges'];
$travellersRefund[$k]['refundableamount'] += $pax['refundableamount'];
$travellersRefund[$k]['totalFare'] += $pax['totalFare'];
$travellersRefund[$k]['intMarkUp'] += $intMarkUp;
}
}
}
$this->view->travellersRefund = $travellersRefund;
$this->view->RequestType = $ModificationData['RequestType'];
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('arrCustomerInvoiceData' => $arrCustomerInvoiceData, 'getCustomerDetails' => $getCustomerDetails, 'CreditInvoiceNo' => $ModificationData['ModificationId'], 'CreateDate' => (array) $ModificationData['CreateDate'], 'RequestType' => $ModificationData['RequestType'], 'arrtravellerList' => $arrtravellerList, 'arrTrevllerDetails' => $arrTrevllerDetails, 'travellersRefund' => $travellersRefund, 'intTPSysId' => $intTPSysId, 'UserType' => 'admin', 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
echo $htmlPage = $html->render('credit-note.phtml');
exit;
} catch (Exception $err) {
print_r($err->getMessage());
die;
}
}
public function sendeticketAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$intTPSysId = base64_decode($this->getRequest()->getParam("intTPSysId"));
$versionId = ($this->getRequest()->getParam("version"));
$emailId = ($this->getRequest()->getParam("emailId"));
$withprice = !empty($this->getRequest()->getParam("withprice")) ? $this->getRequest()->getParam("withprice") : 0;
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$FlightFareBreakdown = $objFlight->getSelectedFlightFareDetails();
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
if ($ICSourceSysId == 3) {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
} else {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
if ($TripType == '3') {
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId, 0);
}
}
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("intTPSysId");
$this->view->version = $versionId;
$this->view->withprice = $withprice;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
$IsInternational = !empty($arrCustomerInvoiceData[0]['IsInternational']) ? $arrCustomerInvoiceData[0]['IsInternational'] : 0;
if ($IsInternational == 1) {
$ItemSourceType = 2;
} else {
$ItemSourceType = 1;
}
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getSupportContact(1, 1, $ItemSourceType, '', $this->agencyDetails['SecurityKey']);
// $this->view->getSupportContact = $getSupportContact;
// echo "<pre>";
// print_r($getSupportContact);
// die;
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$SourceAirportCode = $arrCustomerInvoiceData[0]['SourceAirportCode'];
$DestAirportCode = $arrCustomerInvoiceData[0]['DestAirportCode'];
$AgencySysId = $arrCustomerInvoiceData[0]['AgencySysId'];
$AgentSysId = $arrCustomerInvoiceData[0]['AgentSysId'];
$intLoggedinUserEmailId = $arrCustomerInvoiceData[0]['PrimaryEmail'];
$navarrow = ($TripType == 1) ? "→" : "⇄";
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$html->assign('type', 'mailToCustomer');
$html->assign('getCustomerDetails', $getCustomerDetails);
$html->assign('FlightFareBreakdown', $FlightFareBreakdown);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$html->assign('arrTrevllerDetails', $arrTrevllerDetails);
$html->assign('getSupportContact', $getSupportContact);
$html->assign('intTPSysId', $this->getRequest()->getParam("intTPSysId"));
$html->assign('version', $versionId);
$html->assign('withprice', $withprice);
if ($ICSourceSysId == 7 || $ICSourceSysId == 8 || $ICSourceSysId == 9) {
$bodyText = $html->render('e-tickettj.phtml');
} else {
$bodyText = $html->render('e-ticket.phtml');
}
// echo "<pre>";
// print_r($bodyText);
// die;
$subject = "Flight Booking Itinerary From " . trim($SourceAirportCode) . " " . $navarrow . " " . trim($DestAirportCode);
//$customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId'])?$arrTrevllerDetails[0][0]['EmailId']:'';
$customerEmailId = $emailId;
$emailData = array('fromEmail' => trim($intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $intLoggedinUserEmailId), '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" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$sent = $this->mailSentByElastice($emailData, $arrEmailStatistics);
if ($sent) {
$response = array('success' => true, 'msg' => 'Email sent successfully.');
echo json_encode($response);
exit;
}
} catch (Exception $err) {
print_r($err, true);
}
}
}
public function sendinvoiceAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$param = $this->getRequest()->getParams();
$intTPSysId = base64_decode($this->getRequest()->getParam("intTPSysId"));
$versionId = ($this->getRequest()->getParam("version"));
$emailId = ($this->getRequest()->getParam("emailId"));
$objFlight = new Travel_Model_TblFlight();
$objTbltbbcuser = new Travel_Model_Tbltbbcuser();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrtravellerList = $objFlight->travellerListBySabir($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$TBQAirInvenSysId = $arrCustomerInvoiceData[0]['TBQAirInvenSysId'];
$objFlight->strCondition = " TBQAirInvenAPISysId IN ('" . $TBQAirInvenSysId . "') ";
$FlightFareBreakdown = $objFlight->getSelectedFlightFareDetails();
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
$arrAgentDetail = [];
if ($IsB2BProposal == 1) {
$arrAgentDetail = $crmcustomerObj->GetAgencyDetailById($B2BAgencySysId);
}
$getCustomerDetails = $objTbltbbcuser->getCustomerDetails($CustomerSysId, $this->intLoggedinUserAgencySysId);
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
//echo "<pre>";print_r($arrCustomerInvoiceData);echo "</pre>";die;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("intTPSysId");
$this->view->version = $versionId;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$SourceAirportCode = $arrCustomerInvoiceData[0]['SourceAirportCode'];
$DestAirportCode = $arrCustomerInvoiceData[0]['DestAirportCode'];
$AgencySysId = $arrCustomerInvoiceData[0]['AgencySysId'];
$AgentSysId = $arrCustomerInvoiceData[0]['AgentSysId'];
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$intLoggedinUserEmailId = $arrCustomerInvoiceData[0]['PrimaryEmail'];
$navarrow = ($TripType == 1) ? "→" : "⇄";
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrAgencyDetail = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$html->assign('type', 'mailToCustomer');
$html->assign('FlightFareBreakdown', $FlightFareBreakdown);
$html->assign('getCustomerDetails', $getCustomerDetails);
$html->assign('arrtravellerList', $arrtravellerList);
$html->assign('arrAgencyDetail', $arrAgentDetail);
$html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
$html->assign('arrTrevllerDetails', $arrTrevllerDetails);
$html->assign('intTPSysId', $this->getRequest()->getParam("intTPSysId"));
$html->assign('version', $versionId);
if ($ICSourceSysId == 3) {
$bodyText = $html->render('customer-invoice.phtml');
} else {
$bodyText = $html->render('customer-invoicetj.phtml');
}
$subject = "Flight Booking Itinerary From " . trim($SourceAirportCode) . " " . $navarrow . " " . trim($DestAirportCode);
//$customerEmailId = isset($arrTrevllerDetails[0][0]['EmailId'])?$arrTrevllerDetails[0][0]['EmailId']:'';
$customerEmailId = $emailId;
$emailData = array('fromEmail' => trim($intLoggedinUserEmailId), 'fromName' => trim($arrAgencyDetail['DisplayName']), 'subject' => $subject, 'to' => array($customerEmailId, $intLoggedinUserEmailId), '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" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers Emailing
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$sent = $this->mailSentByElastice($emailData, $arrEmailStatistics);
if ($sent) {
$response = array('success' => true, 'msg' => 'Email sent successfully.');
echo json_encode($response);
exit;
}
} catch (Exception $err) {
print_r($err, true);
}
}
}
public function cancelFlightBookingAction() {
if (!$this->getRequest()->isXmlHttpRequest()) {
$intTPSysId = $this->view->intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$version = $this->view->version = $this->getRequest()->getParam("version");
$objFlight = new Travel_Model_TblFlight();
$arrFlightBookingList = $objFlight->viewFlightBookingDetails($intTPSysId, $version);
//echo "<pre>";print_r($arrFlightBookingList);echo "</pre>";
$this->view->arrFlightBookingList = $arrFlightBookingList;
$intCustomerSysId = $arrFlightBookingList[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
}
// $arr1 = '{"Response":{"B2B2BStatus":false,"TicketCRInfo":[{"ChangeRequestId":208704,"TicketId":1631555,"Status":1,"Remarks":"Successful","ChangeRequestStatus":1}],"ResponseStatus":1,"TraceId":"3be76657-06ab-459f-b6db-aa69b16fb3f7"}}';
//$arr2 = "{\"Response\":{\"B2B2BStatus\":false,\"Error\":{\"ErrorCode\":0,\"ErrorMessage\":\"\"},\"ResponseStatus\":1,\"TraceId\":\"c1cf5c1e-9bd9-4aaf-b131-f132da6c5283\",\"Response\":{\"PNR\":\"P4PRPV\",\"BookingId\":1360325,\"SSRDenied\":false,\"SSRMessage\":null,\"Status\":1,\"IsPriceChanged\":false,\"IsTimeChanged\":false,\"FlightItinerary\":{\"IssuancePcc\":\"AGENTTEST\",\"TripIndicator\":1,\"BookingId\":1360325,\"IsManual\":false,\"PNR\":\"P4PRPV\",\"IsDomestic\":true,\"Source\":3,\"Origin\":\"PAT\",\"Destination\":\"DEL\",\"AirlineCode\":\"SG\",\"LastTicketDate\":\"2018-06-12T09:49:10\",\"ValidatingAirlineCode\":\"SG\",\"AirlineRemark\":\"\",\"IsLCC\":true,\"NonRefundable\":false,\"FareType\":\"PUB\",\"CreditNoteNo\":null,\"Fare\":{\"Currency\":\"INR\",\"BaseFare\":2908,\"Tax\":1076,\"TaxBreakup\":[{\"key\":\"K3\",\"value\":0},{\"key\":\"PSF\",\"value\":476.00},{\"key\":\"YR\",\"value\":100.00},{\"key\":\"OtherTaxes\",\"value\":450.00},{\"key\":\"TotalTax\",\"value\":1076.00}],\"YQTax\":0,\"AdditionalTxnFeeOfrd\":0,\"AdditionalTxnFeePub\":0,\"PGCharge\":0,\"OtherCharges\":3.54,\"ChargeBU\":[{\"key\":\"TBOMARKUP\",\"value\":0},{\"key\":\"OTHERCHARGE\",\"value\":3.54},{\"key\":\"CONVENIENCECHARGE\",\"value\":0}],\"Discount\":0.00,\"PublishedFare\":3987.54,\"CommissionEarned\":60.80,\"PLBEarned\":39.14,\"IncentiveEarned\":39.68,\"OfferedFare\":3847.92,\"TdsOnCommission\":18.24,\"TdsOnPLB\":11.74,\"TdsOnIncentive\":11.90,\"ServiceFee\":0,\"TotalBaggageCharges\":0,\"TotalMealCharges\":0,\"TotalSeatCharges\":0,\"TotalSpecialServiceCharges\":0},\"CreditNoteCreatedOn\":null,\"Passenger\":[{\"PaxId\":1852383,\"Title\":\"Mr\",\"FirstName\":\"Md\",\"LastName\":\"Sabir\",\"PaxType\":1,\"DateOfBirth\":\"1987-01-04T00:00:00\",\"Gender\":1,\"PassportNo\":\"\",\"AddressLine1\":\"H65 Ground Floor Jamia Nagar\",\"AddressLine2\":\"\",\"Fare\":{\"Currency\":\"INR\",\"BaseFare\":1454,\"Tax\":538,\"TaxBreakup\":[{\"key\":\"K3\",\"value\":0},{\"key\":\"PSF\",\"value\":238.00},{\"key\":\"YR\",\"value\":50.00},{\"key\":\"OtherTaxes\",\"value\":225.00},{\"key\":\"TotalTax\",\"value\":538.00}],\"YQTax\":0,\"AdditionalTxnFeeOfrd\":0,\"AdditionalTxnFeePub\":0,\"PGCharge\":0,\"OtherCharges\":1.77,\"ChargeBU\":[{\"key\":\"TBOMARKUP\",\"value\":0},{\"key\":\"OTHERCHARGE\",\"value\":1.77},{\"key\":\"CONVENIENCECHARGE\",\"value\":0}],\"Discount\":0.00,\"PublishedFare\":1993.77,\"CommissionEarned\":30.40,\"PLBEarned\":19.57,\"IncentiveEarned\":19.84,\"OfferedFare\":1923.96,\"TdsOnCommission\":9.12,\"TdsOnPLB\":5.87,\"TdsOnIncentive\":5.95,\"ServiceFee\":0,\"TotalBaggageCharges\":0,\"TotalMealCharges\":0,\"TotalSeatCharges\":0,\"TotalSpecialServiceCharges\":0},\"City\":\"Delhi\",\"CountryCode\":\"IN\",\"CountryName\":\"India\",\"Nationality\":\"IN\",\"ContactNo\":\"8447455883\",\"Email\":\"anshul@catpl.co.in\",\"IsLeadPax\":true,\"FFAirlineCode\":null,\"FFNumber\":\"\",\"Ticket\":{\"TicketId\":1632011,\"TicketNumber\":\"P4PRPV\",\"IssueDate\":\"2018-06-12T15:19:10\",\"ValidatingAirline\":\"324\",\"Remarks\":\"\",\"ServiceFeeDisplayType\":\"ShowInTax\",\"Status\":\"OK\"},\"SegmentAdditionalInfo\":[{\"FareBasis\":\"BSAVER\",\"NVA\":\"\",\"NVB\":\"\",\"Baggage\":\"10 Kg|0\",\"Meal\":\"0 Platter\",\"Seat\":\"\",\"SpecialService\":\"\"}]},{\"PaxId\":1852384,\"Title\":\"Mr\",\"FirstName\":\"pardeep\",\"LastName\":\"khan\",\"PaxType\":1,\"DateOfBirth\":\"1990-06-12T00:00:00\",\"Gender\":1,\"PassportNo\":\"\",\"Fare\":{\"Currency\":\"INR\",\"BaseFare\":1454,\"Tax\":538,\"TaxBreakup\":[{\"key\":\"K3\",\"value\":0},{\"key\":\"PSF\",\"value\":238.00},{\"key\":\"YR\",\"value\":50.00},{\"key\":\"OtherTaxes\",\"value\":225.00},{\"key\":\"TotalTax\",\"value\":538.00}],\"YQTax\":0,\"AdditionalTxnFeeOfrd\":0,\"AdditionalTxnFeePub\":0,\"PGCharge\":0,\"OtherCharges\":1.77,\"ChargeBU\":[{\"key\":\"TBOMARKUP\",\"value\":0},{\"key\":\"OTHERCHARGE\",\"value\":1.77},{\"key\":\"CONVENIENCECHARGE\",\"value\":0}],\"Discount\":0.00,\"PublishedFare\":1993.77,\"CommissionEarned\":30.40,\"PLBEarned\":19.57,\"IncentiveEarned\":19.84,\"OfferedFare\":1923.96,\"TdsOnCommission\":9.12,\"TdsOnPLB\":5.87,\"TdsOnIncentive\":5.95,\"ServiceFee\":0,\"TotalBaggageCharges\":0,\"TotalMealCharges\":0,\"TotalSeatCharges\":0,\"TotalSpecialServiceCharges\":0},\"CountryCode\":\"IN\",\"CountryName\":\"India\",\"Nationality\":\"IN\",\"IsLeadPax\":false,\"FFAirlineCode\":null,\"FFNumber\":\"\",\"Ticket\":{\"TicketId\":1632012,\"TicketNumber\":\"P4PRPV\",\"IssueDate\":\"2018-06-12T15:19:11\",\"ValidatingAirline\":\"324\",\"Remarks\":\"\",\"ServiceFeeDisplayType\":\"ShowInTax\",\"Status\":\"OK\"},\"SegmentAdditionalInfo\":[{\"FareBasis\":\"BSAVER\",\"NVA\":\"\",\"NVB\":\"\",\"Baggage\":\"10 Kg|0\",\"Meal\":\"0 Platter\",\"Seat\":\"\",\"SpecialService\":\"\"}]}],\"CancellationCharges\":null,\"Segments\":[{\"Baggage\":null,\"CabinBaggage\":null,\"TripIndicator\":1,\"SegmentIndicator\":1,\"Airline\":{\"AirlineCode\":\"SG\",\"AirlineName\":\"SpiceJet\",\"FlightNumber\":\"742\",\"FareClass\":\"B\",\"OperatingCarrier\":\"\"},\"AirlinePNR\":\"\",\"Origin\":{\"Airport\":{\"AirportCode\":\"PAT\",\"AirportName\":\"Patna\",\"Terminal\":\"\",\"CityCode\":\"PAT\",\"CityName\":\"Patna\",\"CountryCode\":\"IN\",\"CountryName\":\"India\"},\"DepTime\":\"2018-09-10T19:30:00\"},\"Destination\":{\"Airport\":{\"AirportCode\":\"DEL\",\"AirportName\":\"Indira Gandhi Airport\",\"Terminal\":\"1C\",\"CityCode\":\"DEL\",\"CityName\":\"Delhi\",\"CountryCode\":\"IN\",\"CountryName\":\"India\"},\"ArrTime\":\"2018-09-10T21:15:00\"},\"Duration\":105,\"GroundTime\":0,\"Mile\":0,\"StopOver\":false,\"StopPoint\":\"\",\"StopPointArrivalTime\":\"2018-09-10T21:15:00\",\"StopPointDepartureTime\":\"2018-09-10T19:30:00\",\"Craft\":\"737\",\"Remark\":null,\"IsETicketEligible\":false,\"FlightStatus\":\"Confirmed\",\"Status\":\"HK\"}],\"FareRules\":[{\"Origin\":\"PAT\",\"Destination\":\"DEL\",\"Airline\":\"SG\",\"FareBasisCode\":\"BSAVER\",\"FareRuleDetail\":\" \\u000d\\u000a You have booked a Saver Fare for # and # sector(s). Changes and cancellations are permitted as per applicable rules and charges. \\u000d <br\\\/> <br\\\/>\",\"FareRestriction\":null}],\"Status\":5,\"InvoiceAmount\":3890.00,\"InvoiceNo\":\"DW\\\/1819\\\/12076\",\"InvoiceStatus\":3,\"InvoiceCreatedOn\":\"2018-06-12T15:19:10\",\"Remarks\":\"\"},\"TicketStatus\":1}}}";
// $response1 = json_decode($arr1,true);
//$response2 = json_decode($arr2,true);
//echo "<pre>";print_r($response2);echo "</pre>";
// $data = array(
// "ChangeRequestId'=>$response1['Response']['TicketCRInfo'][0]['ChangeRequestId'],
// );
// //echo "<pre>";print_r($data);echo "</pre>";
// $GetChangeRequestStatus = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetChangeRequestStatus($response1['Response']['TicketCRInfo'][0]['ChangeRequestId']);
// echo "<pre>";print_r($GetChangeRequestStatus);echo "</pre>";
//exit;
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$request = $this->getRequest()->getParam("request");
if (!empty($request) && $request == "cancelBooking") {
$intPrimeryVersionId = $this->getRequest()->getParam("intPrimeryVersionId");
$TPSysId = $this->getRequest()->getParam("TPSysId");
$strCancelRemarks = trim($this->getRequest()->getParam("cRemarks"));
$strBookingId = $this->getRequest()->getParam("strBookingId");
$strTicketId = $this->getRequest()->getParam("strTicketId");
$strflightSource = $this->getRequest()->getParam("strflightSource");
$strflightOrigin = $this->getRequest()->getParam("flightOrigin");
$strflightDestination = $this->getRequest()->getParam("flightDestination");
$intIsLCC = $this->getRequest()->getParam("isLCC");
$intCancellationType = $this->getRequest()->getParam("cancellation_type");
$sectorsSelectors = $this->getRequest()->getParam("sectorsSelectors");
$PaxDetails = $this->getRequest()->getParam("PaxDetails");
$requestType = $this->getRequest()->getParam("requestType");
//echo "<pre>"; print_r($PaxDetails);
//echo "<pre>"; print_r($sectorsSelectors); exit;
$arrBookingId = explode("/", $strBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
$strBookingPNR = trim($arrBookingId[1]);
if (empty($strCancelRemarks)) {
$response = array('success' => false, 'msg' => 'Please enter cancellation remarks.');
echo json_encode($response);
exit;
}
if (!empty($strXRefBookingId)) {
$objFlight = new Travel_Model_TblFlight();
$sector = [];
if ($sectorsSelectors) {
foreach ($sectorsSelectors as $sec) {
$sectorEX = explode('-', $sec);
$sector[] = array('Origin' => $sectorEX[0], 'Destination' => $sectorEX[1]);
}
}
$data = array(
"booking_id" => $strXRefBookingId,
"ticket_id" => $strTicketId,
"source" => $strflightSource,
"flightOrigin" => $strflightOrigin,
"flightDestination" => $strflightDestination,
"remarks" => $strCancelRemarks,
"intIsLCC" => $intIsLCC,
"CancellationType" => $intCancellationType,
"sectorsSelectors" => $sector,
"TicketId" => $PaxDetails,
"requestType" => $requestType,
);
//echo "<pre>"; print_r($data); exit;
$cancellationResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->cancelFlightBooking($data);
//$cancellationResponse = '{"Response":{"B2B2BStatus":false,"TicketCRInfo":[{"ChangeRequestId":208639,"TicketId":1630087,"Status":1,"Remarks":"Successful","ChangeRequestStatus":1}],"ResponseStatus":1,"TraceId":"f9bee571-b6ad-461b-88a7-283707958349"}}';
//$cancellationResponse = '{"Response":{"B2B2BStatus":"","TicketCRInfo":[{"ChangeRequestId":"208701","TicketId":"1631507","Status":"1","Remarks":"Successful","ChangeRequestStatus":"1"},{"ChangeRequestId":"208702","TicketId":"1631508","Status":"1","Remarks":"Successful","ChangeRequestStatus":"1"},{"ChangeRequestId":"208703","TicketId":"1631509","Status":"1","Remarks":"Successful","ChangeRequestStatus":"1"}],"ResponseStatus":"1","TraceId":"9298ba12-4e41-40d3-ab48-6af41bf77871"}}';
//$GetChangeRequestStatus = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetChangeRequestStatus('208639');
//echo "<pre>"; print_r($GetChangeRequestStatus);
//$cancellationResponse = json_decode($cancellationResponse, true);
//echo "<pre>"; print_r($cancellationResponse); exit;
$intChangeRequestStatus = $cancellationResponse['Response']['ResponseStatus'];
if ($intIsLCC == 1 && $intChangeRequestStatus == 1) {
//$intChangeRequestId = $cancellationResponse['Response']['ChangeRequestId'];
$intErrorCode = isset($cancellationResponse['Response']['Error']['ErrorCode']) ? $cancellationResponse['Response']['Error']['ErrorCode'] : 0;
$strErrorMessage = isset($cancellationResponse['Response']['Error']['ErrorMessage']) ? $cancellationResponse['Response']['Error']['ErrorMessage'] : '';
$data = array(
//"XRefCancellationlId" => $intChangeRequestId,
"APICancellationRes" => json_encode($cancellationResponse)
);
$objFlight->updateBookingDetails($data, $intPrimeryVersionId); // FOR BOOKING CONFIRMED
} else {
//$intChangeRequestId = $cancellationResponse['Response']['ChangeRequestId'];
$intErrorCode = isset($cancellationResponse['Response']['Error']['ErrorCode']) ? $cancellationResponse['Response']['Error']['ErrorCode'] : 0;
$strErrorMessage = isset($cancellationResponse['Response']['Error']['ErrorMessage']) ? $cancellationResponse['Response']['Error']['ErrorMessage'] : '';
$data = array(
//"XRefCancellationlId" => $intChangeRequestId,
"APICancellationRes" => json_encode($cancellationResponse)
);
$objFlight->updateBookingDetails($data, $intPrimeryVersionId); // FOR BOOKING CONFIRMED
}
if ($requestType == 1) {
$status = 10; // full cancellation
} else {
$status = 71; // partial cancellation
}
if ($intChangeRequestStatus == 1) {
$data = array(
"StatusType" => $status
);
$objFlight->updateBookingStatusTravelPlan($data, $TPSysId);
$strMsg = ($intIsLCC == 1) ? "Your booking has been cancelled." : "Booking PNR has been released successfully.";
$redirect = true;
} else if ($intChangeRequestStatus == 2) {
$data = array(
"StatusType" => $status
);
$objFlight->updateBookingStatusTravelPlan($data, $TPSysId);
$strMsg = ($intIsLCC == 1) ? "Your booking cancellation is Inprocess" : $strErrorMessage;
$redirect = false;
} else {
$strMsg = "Oops! Your booking Can'nt be cancelled right now please try again latter, Please contact administrator for more details";
$redirect = false;
}
//echo "<pre>"; print_r($cancellationResponse); exit;
if ($intChangeRequestStatus == 1 && $intErrorCode == 0) {
$response = array('success' => true, 'msg' => $strMsg, 'apiResponse' => $cancellationResponse, 'redirect' => $redirect);
echo json_encode($response);
exit;
} else {
$response = array('success' => true, 'msg' => $strErrorMessage, 'apiResponse' => $cancellationResponse, 'redirect' => $redirect);
echo json_encode($response);
exit;
}
}
exit;
}
}
}
public function amendmentItineraryAction() {
//$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$objFlight = new Travel_Model_TblFlight();
// $arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
// $SeqId = isset($arrCustomerInvoiceData[0]['SeqId']) ? $arrCustomerInvoiceData[0]['SeqId'] : 0;
// $ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
// if ($ICSourceSysId == 3) {
// $arrtravellerList = $objFlight->travellerListForCancel($intTPSysId, $SeqId);
// } else {
// $arrtravellerList = $objFlight->travellerListForCancel($intTPSysId);
// }
// $arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
// echo "<pre>";
// print_r($arrtravellerList);
// echo "<pre>";
// print_r($FlightBookingData);
// echo "</pre>";
// die;
// $this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
// $intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
// $arrTrevllerDetails = array();
// if (!empty($intCustomerSysId)) {
// $arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
// }
// $this->view->arrTrevllerDetails = $arrTrevllerDetails;
// $strXRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
// $IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
//
// $APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
// $IsSeriesFareData = $APIBookingRes['value']['IsSeriesFareData'];
// $bookingId_TJ = $APIBookingRes['value']['bookingId_TJ'];
// if ($bookingId_TJ) {
// $bookingId_TJ = $bookingId_TJ;
// } else {
// $bookingId_TJ = $APIBookingRes['value']['bookingId'];
// }
//
// $arrBookingId = explode("/", $strXRefBookingId);
// $strXRefBookingId = trim($arrBookingId[0]);
$getData['SecurityKey'] = $this->agencyDetails['SecurityKey'];
$PostData = ['TPSysId' => $intTPSysId, 'version' => $versionId, 'IsApproved' => 0];
$URL = $this->baseUrl . "/gtxwebservices/flight-api/bookingdetails/";
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->apiHttpRequest($PostData, $getData, $URL);
$FlightBookingData = $bookingDataByAPI = isset($apiResponse['FlightBookingData']) ? $apiResponse['FlightBookingData'] : [];
$arrtravellerList = isset($apiResponse['customer']) ? $apiResponse['customer'] : [];
$CustomerDetails = isset($apiResponse['CustomerDetails']) ? $apiResponse['CustomerDetails'] : [];
// echo "<pre>";
// print_r($apiResponse);
// echo "</pre>";
// die;
$this->view->FlightBookingData = $FlightBookingData;
$this->view->arrtravellerList = $arrtravellerList;
$ICSourceSysId = $FlightBookingData[0]['ICSourceSysId'];
$strXRefBookingId = $FlightBookingData[0]['XRefBookingId'];
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$post = $this->getRequest()->getParams();
$sectorsSelectors = $post['sectorsSelectors'];
$PaxDetails = $post['PaxDetails'];
$PaxType = $post['PaxType'];
$TPPaxSysId = $post['TPPaxSysId'];
$requestType = $post['requestType'];
$ticketid = $post['ticketid'];
$cRemarks = $post['cRemarks'];
$bookingId_TJ = $strXRefBookingId;
$sectorsDates = ($post['sectorsDates']);
$requestTypeValue = $post['requestTypeValue'];
$trips = [];
if($ICSourceSysId == 9){
if ($requestTypeValue == 'FULL_CANCELLATION') {
$requestTypes = 1;
} elseif ($requestTypeValue == 'PARTIAL_CANCELATTION') {
$requestTypes = 2;
} else {
$requestTypes = 3;
}
$ChangeResponse = array(
'Response' => array(
'Currency' => $this->CurrencyTitle,
'CancellationCharge' => 0,
'RefundAmount' => $FlightBookingData[0]['resultTRX']['TrxPaidAmount'],
'ResponseStatus' => true,
'Error' => array('ErrorMessage' => ''),
)
);
}else if ($ICSourceSysId == 3) {
if ($requestTypeValue == 'FULL_CANCELLATION') {
$requestTypes = 1;
} elseif ($requestTypeValue == 'PARTIAL_CANCELATTION') {
$requestTypes = 2;
} else {
$requestTypes = 3;
}
$sector = [];
if ($sectorsSelectors) {
foreach ($sectorsSelectors as $sec) {
$sectorEX = explode('-', $sec);
$sector[] = array('Origin' => $sectorEX[0], 'Destination' => $sectorEX[1]);
}
}
$data = array(
"bookingId" => trim($strXRefBookingId),
"type" => $requestTypeValue,
"remarks" => $cRemarks,
"sectorsSelectors" => $sector,
"CancellationType" => 2,
"requestType" => $requestTypes,
"TicketId" => $ticketid,
"PaxType" => $PaxType,
"TPPaxSysId" => $TPPaxSysId,
"PaxDetails" => $PaxDetails,
);
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getCancellationCharges($data, $this->intLoggedinUserAgencySysId);
} else {
if (array_unique($sectorsSelectors)) {
foreach (array_unique($sectorsSelectors) as $key => $sec) {
$sectorEX = explode('-', $sec);
$dateEX = $sectorsDates[$key];
$paxArray = [];
$paxDetailArray = [];
if ($PaxDetails) {
foreach ($PaxDetails as $pax) {
$PaxDetailsEX = explode('-', $pax);
$paxArray[] = array(
'fn' => $PaxDetailsEX[0],
'ln' => $PaxDetailsEX[1]
);
$paxDetailArray[trim($PaxDetailsEX[0]) . '-' . trim($PaxDetailsEX[1])] = 1;
}
}
$trips[] = array(
'src' => $sectorEX[0],
'dest' => $sectorEX[1],
'departureDate' => $dateEX,
'travellers' => $paxArray,
//'nextTravelDate' => '2021-02-02',
);
}
}
$isCancelType = 0;
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
$travellerInfos = $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
$pt = array_column($travellerInfos, 'pt');
$ChangeRequestStatus = array_column($arrtravellerList, 'ChangeRequestStatus');
$totalcancelled = (!empty($ChangeRequestStatus)) ? array_sum($ChangeRequestStatus) : 0;
//echo "<pre>";print_r($cancel);die;
$passangerTypecount = array_count_values($pt);
$totalAdults = $passangerTypecount['ADULT'];
$selectedpassangerTypecount = array_count_values($PaxType);
$selectedtotalAdults = $selectedpassangerTypecount['ADULT'];
$isCancelType = ((array_sum($passangerTypecount)) > (array_sum($selectedpassangerTypecount) + $totalcancelled)) ? 2 : 1;
if ((array_sum($passangerTypecount) != array_sum($selectedpassangerTypecount)) && $totalAdults == $selectedtotalAdults) {
$response = array('success' => false, 'msg' => 'Can not select all adults.');
echo json_encode($response);
exit;
}
}
$data = array(
"bookingId" => trim($bookingId_TJ),
"type" => $requestTypeValue,
"remarks" => $cRemarks,
"trips" => $trips,
"PaxType" => $PaxType,
"TPPaxSysId" => $TPPaxSysId,
"PaxDetails" => $PaxDetails,
"isCancelType" => $isCancelType,
);
if ($requestTypeValue == 'CANCELLATION' || $requestTypeValue == 'PARTIAL_CANCELATTION') {
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentChargesSeriesFare($data, $arrCustomerInvoiceData, $this->intLoggedinUserAgencySysId);
} elseif ($requestTypeValue == 'CANCELLATION') {
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentCharges($data, $this->intLoggedinUserAgencySysId);
} else {
$ChangeResponse = [];
}
} else {
$ChangeResponse = [];
}
}
Zend_Session::namespaceUnset('AmendmentRequestData');
$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
$AmendmentRequestData->params = $data;
// echo "<pre>";
// print_r($data);
// echo "<pre>";
// print_r($ChangeResponse);
// die;
$intChangeRequestStatus = $ChangeResponse['status']['success'];
$trips = isset($ChangeResponse['trips']) ? $ChangeResponse['trips'] : '';
if ($IsInternational) {
$intCountryCode = 'INT';
} else {
$intCountryCode = 'IN';
}
if ((isset($IsSeriesFareData) && $IsSeriesFareData == 1) || $ICSourceSysId == 9) {
$intMarkUp = 0;
} else {
$intMarkUp = $this->getCancelCharge($intCountryCode);
}
// echo $ICSourceSysId."<pre>";print_r($PaxType);
// echo "<pre>";print_r($PaxDetails);
// echo "<pre>";print_r($intMarkUp);
// echo "<pre>";print_r($ChangeResponse);die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('PaxType' => $PaxType, 'PaxDetails' => $PaxDetails, 'ICSourceSysId' => $ICSourceSysId, 'intMarkUp' => $intMarkUp, 'ChangeResponse' => $ChangeResponse, 'baseUrl' => $this->baseUrl, 'CurrencyTitle' => $this->CurrencyTitle, 'CurrencyRate' => $this->CurrencyRate, 'IsSeriesFareData' => $IsSeriesFareData));
$bodyText = $html->render('getcancelcharge.phtml');
$response = array('success' => true, 'msg' => 'Done', 'html' => $bodyText);
echo json_encode($response);
exit;
}
}
public function submitAmendmentAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$param = $this->getRequest()->getParams();
//error_reporting(E_ALL);
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$bookingId = ($this->getRequest()->getParam("bkid"));
$objFlight = new Travel_Model_TblFlight();
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], 1);
$IsSeriesFareData = isset($APIBookingRes['value']['IsSeriesFareData']) ? $APIBookingRes['value']['IsSeriesFareData'] : 0;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
$EmailId = $arrTrevllerDetails[0][0]['EmailId'];
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$TPSysId = $arrCustomerInvoiceData[0]['TPSysId'];
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$strXRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$arrBookingId = explode("/", $strXRefBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
if ($IsInternational) {
$intCountryCode = 'INT';
} else {
$intCountryCode = 'IN';
}
$intMarkUp = $this->getCancelCharge($intCountryCode);
$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
$data = $AmendmentRequestData->params;
$bookingId_TJ = $strXRefBookingId;
$sectorsSelectors = $param['sectorsSelectors'];
$bookingId = $param['bookingId'];
$requestType = $param['requestType'];
$requestTypeValue = $param['requestTypeValue'];
$PaxDetails = $param['PaxDetails'];
$cRemarks = $param['cRemarks'];
$strUrlData = $param['strUrlData'];
$sectorsDates = ($param['sectorsDates']);
$TPPaxSysId = $param['TPPaxSysId'];
if (($requestTypeValue == 'CANCELLATION' || $requestTypeValue == 'FULL_CANCELLATION' || $requestTypeValue == 'PARTIAL_CANCELATTION' || $requestTypeValue == 'CHANGE_ITINERARY_REISSUE') && $ICSourceSysId != 9) {
if (isset($IsSeriesFareData) && $IsSeriesFareData == 1) {
$bookingId_TJ = $bookingId;
$this->GetSubmitAmendmentSeriesFare($param, $arrCustomerInvoiceData, $arrtravellerList);
} elseif ($ICSourceSysId == 7) {
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSubmitAmendment($data, $this->intLoggedinUserAgencySysId);
$intChangeRequestStatus = $ChangeResponse['status']['success'];
$strErrorMessage = $ChangeResponse['errors'][0]['message'];
} else {
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->cancelFlightBooking($data, $this->intLoggedinUserAgencySysId);
// $SubmitAmendment = new Zend_Session_Namespace('SubmitAmendment');
// $ChangeResponse = $SubmitAmendment->params;
// echo '<pre>';
// print_r($ChangeResponse);
$intChangeRequestStatus = isset($ChangeResponse['Response']['ResponseStatus']) ? $ChangeResponse['Response']['ResponseStatus'] : '';
$TicketCRInfo = isset($ChangeResponse['Response']['TicketCRInfo']) ? $ChangeResponse['Response']['TicketCRInfo'] : '';
$intErrorCode = isset($ChangeResponse['Response']['Error']['ErrorCode']) ? $ChangeResponse['Response']['Error']['ErrorCode'] : 0;
$strErrorMessage = isset($ChangeResponse['Response']['Error']['ErrorMessage']) ? $ChangeResponse['Response']['Error']['ErrorMessage'] : '';
$amendmentId = [];
if ($TicketCRInfo) {
foreach ($TicketCRInfo as $key => $value) {
$amendmentId[] = $value['ChangeRequestId'];
}
}
if (count($amendmentId) > 1) {
$ChangeResponse['amendmentId'] = implode(',', $amendmentId);
} else {
$ChangeResponse['amendmentId'] = $amendmentId[0];
}
}
if ($intChangeRequestStatus == 1) {
try {
if (isset($arrtravellerList) && !empty($arrtravellerList)) {
$dataModification = array(
"ChangeRequestId" => $ChangeResponse['amendmentId'],
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $bookingId_TJ,
"RequestType" => $requestTypeValue,
"Remarks" => $cRemarks,
"RequestData" => json_encode($data),
"APIResponseData" => json_encode($ChangeResponse),
"servicefee" => ($intMarkUp),
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"CreateDate" => date('Y-m-d H:i:s'),
"UpdateDate" => date('Y-m-d H:i:s')
);
// echo '<pre>';
// print_r($dataModification);
// echo '</pre>';
// die;
$objFlight->insertFlightModification($dataModification);
$updateTP['StatusType'] = '120';
$updateTP['ChangeRequestId'] = $ChangeResponse['amendmentId'];
$updateTP['ChangeRequestStatus'] = 1;
$objFlight->updateBookingStatusTravelPlan($updateTP, $TPSysId, $MasterTPSysId);
foreach ($arrtravellerList as $key => $value) {
if (isset($PaxDetails[$key]) && !empty($PaxDetails[$key])) {
$data = array(
"ChangeRequestId" => $ChangeResponse['amendmentId'],
"ChangeRequestStatus" => 1,
"ChangeRequestRes" => json_encode($ChangeResponse)
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
}
$getAgencyData = array(
'Title' => $arrCustomerInvoiceData[0]['CompanyName'],
'Address' => $arrCustomerInvoiceData[0]['CompanyAddress'],
'PinCode' => $arrCustomerInvoiceData[0]['Pincode'],
'Contacts' => $arrCustomerInvoiceData[0]['PrimaryContactNo'],
'countrycode' => $arrCustomerInvoiceData[0]['countrycode'],
'AgencyUserEmailId' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
);
if (!empty($arrCustomerInvoiceData)) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('FlightBooking' => $arrCustomerInvoiceData, 'requestTypeValue' => $requestTypeValue, 'amendmentId' => $ChangeResponse['amendmentId'], 'arrTrevllerDetails' => $arrTrevllerDetails, 'param' => $param, 'bookingId' => $strXRefBookingId, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
$bodyText = $html->render('cancelmailer.phtml');
$subject = 'Cancellation request received - ' . $strXRefBookingId;
$Caption = 'Cancellation request received - ' . $strXRefBookingId;
$configs = [
'to' => array(trim($EmailId)),
'fromName' => $arrCustomerInvoiceData[0]['CompanyName'],
'fromEmail' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
'subject' => $subject,
'bodyHtml' => $bodyText,
];
$configs_cc = [
'to' => array(trim($arrCustomerInvoiceData[0]['PrimaryEmail'])),
'fromName' => $arrCustomerInvoiceData[0]['CompanyName'],
'fromEmail' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
'subject' => $subject,
'bodyHtml' => $bodyText,
];
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$emailResponse = json_decode($this->mailSentByElastice($configs, $arrEmailStatistics), true);
$this->mailSentByElastice($configs_cc, $arrEmailStatistics);
$Mailsuccess = $emailResponse['success'];
if ($Mailsuccess) {
$strMsg = "success. Your booking cancellation is Inprocess";
$redirect = true;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
} else {
$strMsg = "success. Your booking cancellation is Inprocess. but unable to send mail.";
$redirect = true;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
}
}
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
} else {
$strMsg = "Oops! Your booking Can'nt be cancel right now please try again latter, Please contact administrator for more details";
$redirect = false;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
}
} else {
try {
if (isset($arrtravellerList) && !empty($arrtravellerList)) {
$trips = [];
if (array_unique($sectorsSelectors)) {
foreach (array_unique($sectorsSelectors) as $key => $sec) {
$sectorEX = explode('-', $sec);
$dateEX = $sectorsDates[$key];
$paxArray = [];
if ($PaxDetails) {
foreach ($PaxDetails as $pax) {
$PaxDetailsEX = explode('-', $pax);
$paxArray[] = array(
'fn' => $PaxDetailsEX[0],
'ln' => $PaxDetailsEX[1]
);
}
}
$trips[] = array(
'src' => $sectorEX[0],
'dest' => $sectorEX[1],
'departureDate' => $dateEX,
'travellers' => $paxArray,
//'nextTravelDate' => '2021-02-02',
);
}
}
$data = array(
"bookingId" => trim($bookingId_TJ),
"type" => $requestTypeValue,
"remarks" => $cRemarks,
"trips" => $trips,
);
$ChangeResponse = [];
$dataModification = array(
"ChangeRequestId" => 0,
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $bookingId_TJ,
"RequestType" => $requestTypeValue,
"Remarks" => $cRemarks,
"RequestData" => json_encode($data),
"APIResponseData" => json_encode($ChangeResponse),
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"CreateDate" => date('Y-m-d H:i:s'),
"UpdateDate" => date('Y-m-d H:i:s')
);
// echo '<pre>';
// print_r($dataModification);
// die;
$amendmentId = $objFlight->insertFlightModification($dataModification);
$updateTPMOD['ChangeRequestId'] = $amendmentId;
$objFlight->updateModification($updateTPMOD, $amendmentId);
$updateTP['StatusType'] = '120';
$updateTP['ChangeRequestId'] = $amendmentId;
$updateTP['ChangeRequestStatus'] = 1;
$objFlight->updateBookingStatusTravelPlan($updateTP, $TPSysId, $MasterTPSysId);
foreach ($arrtravellerList as $key => $value) {
if (isset($PaxDetails[$key]) && !empty($PaxDetails[$key])) {
$data = array(
"ChangeRequestId" => $amendmentId,
"ChangeRequestStatus" => 1,
"ChangeRequestRes" => json_encode($ChangeResponse)
);
$objFlight->updateTravelPlanPax($data, $value['TPPaxSysId']);
}
}
}
$getAgencyData = array(
'Title' => $arrCustomerInvoiceData[0]['CompanyName'],
'Address' => $arrCustomerInvoiceData[0]['CompanyAddress'],
'PinCode' => $arrCustomerInvoiceData[0]['Pincode'],
'Contacts' => $arrCustomerInvoiceData[0]['PrimaryContactNo'],
'countrycode' => $arrCustomerInvoiceData[0]['countrycode'],
'AgencyUserEmailId' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
);
if (!empty($arrCustomerInvoiceData)) {
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign(array('FlightBooking' => $arrCustomerInvoiceData, 'requestTypeValue' => $requestTypeValue, 'amendmentId' => $amendmentId, 'arrTrevllerDetails' => $arrTrevllerDetails, 'param' => $param, 'bookingId' => $strXRefBookingId, 'getAgencyData' => $getAgencyData, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
//
// $bodyText = $html->render('cancelmailer.phtml');
//
// $subject = 'Modification request received - ' . $strXRefBookingId;
// $Caption = 'Modification request received - ' . $strXRefBookingId;
// $configs = [
// 'to' => array(trim($EmailId)),
// 'fromName' => $arrCustomerInvoiceData[0]['CompanyName'],
// 'fromEmail' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
// 'subject' => $subject,
// 'bodyHtml' => $bodyText,
// ];
// $configs_cc = [
// 'to' => array(trim($arrCustomerInvoiceData[0]['PrimaryEmail'])),
// 'fromName' => $arrCustomerInvoiceData[0]['CompanyName'],
// 'fromEmail' => $arrCustomerInvoiceData[0]['PrimaryEmail'],
// 'subject' => $subject,
// 'bodyHtml' => $bodyText,
// ];
//
// $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
// $arrEmailStatistics = array(
// "TPSysId" => 0,
// "TypeSysId" => 1, // 1 For Email 2 For SMS
// "AgencySysId" => $this->intLoggedinUserAgencySysId,
// "AgentSysId" => $this->intLoggedinUserId,
// "Title" => $bodyText,
// "Source" => $arrEmailStatisticsType[1], // 1 For Vouchers
// "Status" => 0,
// "RefSysId" => "",
// "RefSysStatus" => "",
// "CreateDate" => date('Y-m-d H:i:s')
// );
// $emailResponse = json_decode($this->mailSentByElastice($configs, $arrEmailStatistics), true);
// $this->mailSentByElastice($configs_cc, $arrEmailStatistics);
// $Mailsuccess = $emailResponse['success'];
$Mailsuccess = 1;
if ($Mailsuccess) {
$strMsg = "success. Your modification request has been submitted";
$redirect = true;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
} else {
$strMsg = "success. Your modification request has been submitted. but unable to send mail.";
$redirect = true;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
}
}
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
}
}
}
public function amendmentDetailsAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$param = $this->getRequest()->getParams();
$refundSubmit = isset($param['refundSubmit']) ? $param['refundSubmit'] : 0;
try {
if ($refundSubmit == 1) {
$objFlight = new Travel_Model_TblFlight();
$intTPSysId = isset($param['intTPSysId']) ? $param['intTPSysId'] : 0;
$Status = isset($param['Status']) ? $param['Status'] : 0;
$CancelMarkUp = isset($param['CancelMarkUp']) ? $param['CancelMarkUp'] : 0;
$RefundMode = isset($param['RefundMode']) ? $param['RefundMode'] : '';
$refundremarks = isset($param['refundremarks']) ? $param['refundremarks'] : '';
$amendmentId = isset($param['amendmentId']) ? $param['amendmentId'] : '';
$refundedamount = isset($param['refundedamount']) ? $param['refundedamount'] : '';
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$strXRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$GeModificationData = $objFlight->GeModificationData($amendmentId);
$GetAmendmentDetails = new Zend_Session_Namespace('GetAmendmentDetails');
$AmendmentDetails = $GetAmendmentDetails->params;
$ModificationId = $GeModificationData[0]['ModificationId'];
$amendmentcharges = 0;
if (!empty($AmendmentDetails['trips'])) {
foreach ($AmendmentDetails['trips'] as $amend) {
if ($amend['travellers']) {
foreach ($amend['travellers'] as $charge) {
$amendmentcharges += $charge['amendmentCharges'];
}
}
}
}
if ($refundedamount >= 0) {
$updateTP['StatusType'] = $Status;
$objFlight->updateBookingStatusTravelPlan($updateTP, $intTPSysId, $MasterTPSysId);
$ModifiUpdate = array(
"status" => 1,
);
$objFlight->updateModification($ModifiUpdate, $ModificationId);
$dataModification = array(
"ChangeRequestId" => $amendmentId,
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $GeModificationData[0]['BookingId'],
"RequestType" => $GeModificationData[0]['RequestType'],
"Remarks" => $refundremarks,
"RequestData" => json_encode($AmendmentDetails),
"APIResponseData" => ($GeModificationData[0]['APIResponseData']),
"RefundMode" => $RefundMode,
"status" => $Status,
"refundedamount" => $refundedamount,
"amendmentcharges" => $amendmentcharges,
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"CreateDate" => date('Y-m-d H:i:s'),
"UpdateDate" => date('Y-m-d H:i:s')
);
$amendmentId = $objFlight->insertFlightModification($dataModification);
$IsB2bSite = $this->agencyDetails['IsB2bSite'];
$IsB2bSiteURL = $this->agencyDetails['IsB2bSiteURL'];
$dataModification['CancelMarkUp'] = $CancelMarkUp;
$url = trim($IsB2bSiteURL) . "gtxwebservices/index/updatecancelrefund";
//$url = "http://local.cheapmyflight.com/gtxwebservices/updatecancelrefund"; saveOnlineRequest
$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_POSTFIELDS, $dataModification);
$output = curl_exec($ch);
$UpdateRes = json_decode($output, true);
if ($amendmentId) {
$response = array('success' => true, 'refundid' => $amendmentId, 'message' => 'Refund submit successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to submit refund. please try again.');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'message' => 'Negative amount not allowed.');
echo json_encode($response);
exit;
}
// $trips = isset($ChangeResponse['trips']) ? $ChangeResponse['trips'] : '';
// $refundableamount = 0;
// $TotalSeg = 0;
// foreach ($trips as $value) {
// foreach ($value['travellers'] as $pax) {
// $refundableamount += (int)$pax['refundableamount'];
// $TotalSeg++;
// }
// }
} else {
$this->view->traceId = $param['amendmentId'];
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
$GeModificationData = $objFlight->GeModificationData($param['amendmentId']);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$strXRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$arrBookingId = explode("/", $strXRefBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
if ($IsInternational) {
$intCountryCode = 'INT';
} else {
$intCountryCode = 'IN';
}
$data = array(
"amendmentId" => $param['amendmentId'],
);
if ($GeModificationData[0]['RequestType'] == 'CANCELLATION') {
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetAmendmentDetails($data, $this->intLoggedinUserAgencySysId);
Zend_Session::namespaceUnset('GetAmendmentDetails');
$GetAmendmentDetails = new Zend_Session_Namespace('GetAmendmentDetails');
$GetAmendmentDetails->params = $ChangeResponse;
} else {
if ($GeModificationData[0]['status'] == '0') {
$ChangeResponse = [
'amendmentStatus' => 'REQUESTED',
'status' => ['success' => false],
];
} else {
$ChangeResponse = [
'amendmentStatus' => 'SUCCESS',
'status' => ['success' => true],
];
}
}
// echo '<pre>';
// print_r($ChangeResponse);
// die;
//$str = file_get_contents($this->baseUrl . '/public/logs/flight/Amendment/Amendment_Details.json');
//$ChangeResponse = json_decode($str, true);
$this->view->ChangeResponse = $ChangeResponse;
$intMarkUp = $this->getCancelCharge($intCountryCode);
$this->view->amendmentId = $param['amendmentId'];
$this->view->CancelMarkUp = $intMarkUp;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('ChangeResponse' => $ChangeResponse, 'intTPSysId' => $intTPSysId, 'amendmentId' => $param['amendmentId'], 'CancelMarkUp' => $intMarkUp, 'param' => $param, 'UserType' => 'admin', 'bookingId' => $strXRefBookingId, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
$htmlPage = $html->render('amendment-details.phtml');
$response = array('success' => true, 'htmlPage' => $htmlPage);
echo json_encode($response);
exit;
}
// die;
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
} else {
die();
}
}
public function modificationDataAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$param = $this->getRequest()->getParams();
try {
$this->view->traceId = $param['amendmentId'];
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
$GeModificationData = $objFlight->GeModificationDataRequest($param['amendmentId']);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$strXRefBookingId = $arrCustomerInvoiceData[0]['XRefBookingId'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$arrBookingId = explode("/", $strXRefBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
if ($IsInternational) {
$intCountryCode = 'INT';
} else {
$intCountryCode = 'IN';
}
$data = array(
"amendmentId" => $param['amendmentId'],
);
// echo '<pre>';
// print_r($GeModificationData);
// die;
$intMarkUp = $this->getCancelCharge($intCountryCode);
$this->view->amendmentId = $param['amendmentId'];
$this->view->CancelMarkUp = $intMarkUp;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('GeModificationData' => $GeModificationData, 'amendmentId' => $param['amendmentId'], 'CancelMarkUp' => $intMarkUp, 'param' => $param, 'UserType' => 'admin', 'bookingId' => $strXRefBookingId, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
$htmlPage = $html->render('modification-data.phtml');
$response = array('success' => true, 'htmlPage' => $htmlPage);
echo json_encode($response);
exit;
// die;
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
} else {
die();
}
}
public function modificationDataApiAction() {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$param = $this->getRequest()->getParams();
try {
$this->view->traceId = $param['amendmentId'];
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$objFlight = new Travel_Model_TblFlight();
$GeModificationData = $objFlight->GeModificationDataRequest($param['amendmentId']);
//$bookingDataByAPI = $objFlight->bookingDataByAPI($intTPSysId);
// echo '<pre>';
// print_r($GeModificationData);
// die;
$this->view->amendmentId = $param['amendmentId'];
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('GeModificationData' => $GeModificationData, 'amendmentId' => $param['amendmentId'], 'param' => $param, 'UserType' => 'admin', 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle, 'baseUrl' => $this->baseUrl));
$htmlPage = $html->render('modification-data-api.phtml');
$response = array('success' => true, 'htmlPage' => $htmlPage);
echo json_encode($response);
exit;
// die;
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
} else {
die();
}
}
public function getCancelCharge($intCountryCode) {
if ($intCountryCode) {
try {
$getMarkup = $this->getMarkup($intCountryCode);
$intMarkUp = 0;
if ($getMarkup['status'] == 1) {
if ($getMarkup['arrAgencyMarkupsCancellation']) {
foreach ($getMarkup['arrAgencyMarkupsCancellation'] as $value) {
if ($value['SupplierType'] == 2 && $value['ServiceType'] == 1 && $value['MPType'] == 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;
} catch (Exception $err) {
print_r($err->getMessage());
die;
}
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
public function getMarkup($intCountryCode) {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$AgencySysId = $this->intLoggedinUserAgencySysId;
$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 offlineFlightBookAction() {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$param = $this->getRequest()->getParams();
$paramArray = $this->getRequest()->getParams();
$fareRules = isset($paramArray['fareRules']) ? $paramArray['fareRules'] : '';
$isquery = isset($param['isquery']) ? $param['isquery'] : '';
$ispackage = isset($param['ispackage']) ? $param['ispackage'] : '';
$cancellationPolicy = isset($paramArray['cancellationPolicy']) ? $paramArray['cancellationPolicy'] : '';
$internalRemarks = isset($paramArray['internalRemarks']) ? $paramArray['internalRemarks'] : '';
if (isset($paramArray["data"])) {
parse_str(urldecode(base64_decode($paramArray["data"])), $param);
}
$objFlight = new Travel_Model_TblFlight();
$crmcustomerObj = new Travel_Model_CRM_Customer();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$index = ($this->getRequest()->getParam("index")) ? $this->getRequest()->getParam("index") : '';
$keySector = ($this->getRequest()->getParam("keySector")) ? json_decode($this->getRequest()->getParam("keySector"), 1) : '';
$indexround = ($this->getRequest()->getParam("indexround")) ? $this->getRequest()->getParam("indexround") : '';
$versionId = ($this->getRequest()->getParam("version"));
$objFlight = new Travel_Model_TblFlight();
$arrSelectedPax = $objFlight->GetAgencyCustomerDetailsForBooking(null, $intTPSysId);
if ($isquery == 1) {
$arrCustomerInvoiceData = $objFlight->GetAgencyCustomerDetailsForBookingQuery($intTPSysId);
$LocalFromTime = (array) $arrCustomerInvoiceData[0]['StartDate'];
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2bAgent'];
} else {
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
$LocalFromTime = (array) $arrCustomerInvoiceData[0]['LocalFromTime'];
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
}
$viewFlightBookingDetails = $objFlight->viewFlightBookingDetails($intTPSysId);
if (empty($viewFlightBookingDetails)) {
$viewFlightBookingDetails = $objFlight->viewFlightBookingDetailsPro($intTPSysId);
}
// echo "<pre>";print_r($viewFlightBookingDetails);die;
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$TPSysId = $arrCustomerInvoiceData[0]['TPSysId'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$CustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
if ($CustomerSysId > 0) {
$getCustomerDetail = $crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
} else {
$getCustomerDetail = array();
}
$encodedata = '';
if($viewFlightBookingDetails[0]['EconomyMask'] == 7 && $viewFlightBookingDetails[0]['PackSpecType'] == 4){
$encodedata = !empty($viewFlightBookingDetails[0]['encodedata']) ? ($viewFlightBookingDetails[0]['encodedata']) : '';
}
$PaxFareDetaials = !empty($viewFlightBookingDetails[0]['APIBookingRes']) ? json_decode($viewFlightBookingDetails[0]['APIBookingRes'], true) : [];
$sessionFlightSearchParams = $PaxFareDetaials[0]['sessionFlightSearchParams'];
if (isset($PaxFareDetaials[0]['flightData'])) {
$flightData = $PaxFareDetaials[0]['flightData'];
$postData = $flightData[0];
if (isset($flightData[1]) && $flightData[1]) {
$postDataInward = $flightData[1];
}
}
// echo "<pre>";
// print_r($IsB2BProposal);ChooseMoreOptions
// echo "</pre>";
// die('qqqqq');
$this->view->encodedata = $encodedata;
$this->view->B2BType = $IsB2BProposal;
$this->view->fareRules = $fareRules;
$this->view->cancellationPolicy = $cancellationPolicy;
$this->view->internalRemarks = $internalRemarks;
$this->view->ispackage = $ispackage;
$this->view->param = $param;
$this->view->ids = $this->getRequest()->getParam("id");
$this->view->index = $index;
$this->view->keySectorSelected = $keySector;
$this->view->indexround = $indexround;
$this->view->getCustomerDetail = $getCustomerDetail;
$this->view->PaxFareDetaials = $PaxFareDetaials;
$this->view->supplier_name = isset($PaxFareDetaials[0]['supplier_name']) ? $PaxFareDetaials[0]['supplier_name'] : '';
$this->view->supplier_id = isset($PaxFareDetaials[0]['supplier_id']) ? $PaxFareDetaials[0]['supplier_id'] : 0;
$this->view->sourceCityAirportCode = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['sourceCityAirportCode']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['sourceCityAirportCode'] : '';
$this->view->destinationCityAirportCode = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['destinationCityAirportCode']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['destinationCityAirportCode'] : '';
$this->view->route = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['route']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['route'] : '';
$this->view->arrSelectedPax = $arrSelectedPax;
$this->view->LocalFromTime = $departureDates = date('d/m/Y', strtotime($LocalFromTime['date']));
$this->view->LocalFromTimeUTC = date('Y-d-m', strtotime($LocalFromTime['date']));
$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->TPSysId = ($TPSysId);
$this->view->MasterTPSysId = ($MasterTPSysId);
if ($IsB2BProposal == 1) {
$this->view->AgencySysId = $B2BAgencySysId;
} else {
$this->view->AgencySysId = ($this->intLoggedinUserAgencySysId);
}
// echo "<pre>";
// print_r($keySector);
// echo "</pre>";
$TblCurrency = new Travel_Model_TblCurrency();
$this->view->Currency = $Currency = $TblCurrency->getCurrencyTypes();
$this->view->TrxCurrency = $TrxCurrency = $this->agencyDetails['TrxCurrency'];
$markupMdl = new Markup_Model_Markup();
$getTaxSettingDetail = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinUserAgencySysId, 0, 0, 1);
if (empty($getTaxSettingDetail)) {
$this->view->getTaxSettingDetail = $tttt = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinUserAgencySysId, 0, 0, 5);
} else {
$this->view->getTaxSettingDetail = $tttt = $markupMdl->getTaxSettingDetail("TB_Master_Agency_Tax_Settings", $this->intLoggedinUserAgencySysId, 0, 0, 1);
}
$PaxFareDetaialsArr = [];
$FlightTempData = $objFlight->GetFlightTempDataByTPSysId($intTPSysId);
// echo "<pre>";
// print_r($FlightTempData);
// echo "</pre>";
// die;
if (!empty($FlightTempData)) {
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$postDataItem = isset($arrUrlData['postData']['item']) ? $arrUrlData['postData']['item'] : '';
$ForCustomerSession = isset($arrUrlData['ForCustomerSession']) ? $arrUrlData['ForCustomerSession'] : [];
$intOutBoundId = isset($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : [];
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$bookingAllowed = isset($sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : 0;
$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$sourceCityId = isset($sessionFlightSearchParams['sourceCityId']) ? $sessionFlightSearchParams['sourceCityId'] : 0;
$destinationCityId = isset($sessionFlightSearchParams['destinationCityId']) ? $sessionFlightSearchParams['destinationCityId'] : 0;
$sourceCityAirportCode = $sourceCityAirportCode_ = isset($sessionFlightSearchParams['sourceCityAirportCode']) ? $sessionFlightSearchParams['sourceCityAirportCode'] : '';
$destinationCityAirportCode = isset($sessionFlightSearchParams['destinationCityAirportCode']) ? $sessionFlightSearchParams['destinationCityAirportCode'] : '';
$InboundIndex = $intOutBoundId[0]['FlightNumber'] . '_' . $intOutBoundId[0]['FareClass'];
if (isset($intOutBoundId[1]['FlightNumber']) && !empty($intOutBoundId[1]['FlightNumber'])) {
$OutboundIndex = $intOutBoundId[1]['FlightNumber'] . '_' . $intOutBoundId[1]['FareClass'];
} else {
$OutboundIndex = '';
}
if (empty($index) && !empty($ForCustomerSession) && $bookingAllowed == 2 && $route == 1 && empty($keySector)) {
$this->_redirect('booking-flight/offline-flight-book/id/' . base64_encode($intTPSysId) . '/index/' . $InboundIndex);
} elseif (empty($indexround) && !empty($ForCustomerSession) && $bookingAllowed == 2 && $route == 2 && empty($keySector)) {
$this->_redirect('booking-flight/offline-flight-book/id/' . base64_encode($intTPSysId) . '/index/' . $InboundIndex . '/indexround/' . $OutboundIndex);
}
$ChooseMoreOptions = $ChooseMoreOptionsNew = [];
if ($route == 2) {
$ChooseMoreOptions[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
$ChooseMoreOptions[$destinationCityAirportCode . '-' . $sourceCityAirportCode] = '';
$sourceCityAirportCode = [$sourceCityAirportCode, $destinationCityAirportCode];
$destinationCityAirportCode = [$destinationCityAirportCode, $sourceCityAirportCode_];
} elseif ($route == 1) {
//$ChooseMoreOptions[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
$ChooseMoreOptionsNew[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
$sourceCityAirportCode = [$sourceCityAirportCode];
$destinationCityAirportCode = [$destinationCityAirportCode];
}
if (isset($postDataItem) && !empty($postDataItem)) {
$postDataItem = $postDataItem;
} else {
$postDataItem = isset($arrUrlData['intOutBoundId']) ? $arrUrlData['intOutBoundId'] : '';
}
// echo "<pre>";
// print_r($sessionFlightSearchParams);
// echo "</pre>";
// die;
$postDataItemNewArr = [];
$ChooseMoreArr = [];
$ChooseMoreArrInb = [];
$postData = '';
$postDataInward = '';
if ($postDataItem) {
$ChooseMoreOptions = $ChooseMoreOptionsNew = [];
//echo "<pre>";print_r($postDataItem);die;
foreach ($postDataItem as $keys => $value) {
$SourceAirportCode = $value['SourceAirportCode'];
$DestAirportCode = $value['DestAirportCode'];
$SourcePlaceName = $value['SourcePlaceName'];
$DestPlaceName = $value['DestPlaceName'];
$secIndex = $SourceAirportCode . '-' . $DestAirportCode;
$secIndexNew = $SourcePlaceName . '-' . $DestPlaceName;
$matchIndex = $value['FlightNumber'] . '_' . $value['FareClass'];
$DepartureTime = $value['DepartureTime'];
$JourneyType = $value['JourneyType'];
$AirlineName = $value['AirlineName'];
$fareIdentifier = (isset($value['FairRules'][0]['fareIdentifier']) && !empty($value['FairRules'][0]['fareIdentifier'])) ? $value['FairRules'][0]['fareIdentifier'] : $value['FairRules']['fareIdentifier'];
if ($matchIndex == $index) {
$postData = $value;
}
if ($matchIndex == $indexround) {
$postDataInward = $value;
}
if ($interNationalSearch == 1 && $route == 2) {
$secIndex2 = $DestAirportCode . '-' . $SourceAirportCode;
$matchIndex = $value['origin']['OrFlightNumber'] . '_' . $value['origin']['FareClass'];
$DepartureTime = $value['origin']['DepartureTime'];
$JourneyType = $value['origin']['JourneyType'];
$AirlineName = $value['origin']['AirlineName'];
$fareIdentifier = isset($value['FairRules'][0]['fareIdentifier']) ? $value['FairRules'][0]['fareIdentifier'] : '';
$matchIndexInt = $matchIndex;
$matchIndex_ = $value['destination']['DeFlightNumber'] . '_' . $value['destination']['FareClass'];
$DepartureTime_ = $value['destination']['DepartureTime'];
$JourneyType_ = $value['destination']['JourneyType'];
$AirlineName_ = $value['destination']['AirlineName'];
$matchIndexInt1 = $matchIndex_;
$Segmentsarr = [];
$Segmentsarrreturn = [];
if ($value['Segments']) {
foreach ($value['Segments'] as $key => $Segments) {
$isReturnSegment = !empty($Segments['isReturnSegment']) ? $Segments['isReturnSegment'] : 0;
// if ($matchIndexInt == $index && $isReturnSegment == 0) {
// $Segmentsarr[] = $Segments;
// }
// if ($matchIndexInt1 == $indexround && $isReturnSegment == 1) {
// $Segmentsarrreturn[] = $Segments;
// }
if ($isReturnSegment == 0) {
$Segmentsarr[] = $Segments;
}
if ($isReturnSegment == 1) {
$Segmentsarrreturn[] = $Segments;
}
}
}
$value['Segments'] = $Segmentsarr;
if ($matchIndexInt == $index) {
$postData = $value;
}
$ChooseMoreArr[] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName];
$ChooseMoreArrInb[] = ['index' => $matchIndex_, 'DT' => $DepartureTime_, 'FT' => $fareIdentifier, 'AN' => $AirlineName_];
$ChooseMoreOptions[$secIndex][] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName];
$ChooseMoreOptions[$secIndex2][] = ['index' => $matchIndex_, 'DT' => $DepartureTime_, 'FT' => $fareIdentifier, 'AN' => $AirlineName_];
$value['Segments'] = $Segmentsarrreturn;
if ($matchIndexInt1 == $indexround) {
$postDataInward = $value;
}
$postDataItemNewArr[$secIndex][$keys] = $value;
$postDataItemNewArr[$secIndex][$keys]['Segments'] = $Segmentsarr;
$postDataItemNewArr[$secIndex2][$keys] = $value;
$postDataItemNewArr[$secIndex2][$keys]['Segments'] = $Segmentsarrreturn;
} else {
//$postDataItemNewArr[$secIndex][] = $value;
//$ChooseMoreOptions[$secIndex][] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName, 'secIndex' => $secIndex];
$postDataItemNewArrNew[$secIndexNew][] = $value;
$ChooseMoreOptionsNew[$secIndexNew][] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName, 'secIndex' => $secIndex];
if ($JourneyType == '1') {
$ChooseMoreArr[] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName];
} else {
$ChooseMoreArrInb[] = ['index' => $matchIndex, 'DT' => $DepartureTime, 'FT' => $fareIdentifier, 'AN' => $AirlineName];
}
}
}
} else {
$postData = isset($arrUrlData['intOutBoundId'][0]) ? $arrUrlData['intOutBoundId'][0] : '';
if ($route == 2) {
$postDataInward = isset($arrUrlData['intOutBoundId'][1]) ? $arrUrlData['intOutBoundId'][1] : '';
}
}
// $postData = isset($arrUrlData['postData']['item'][$index]) ? $arrUrlData['postData']['item'][$index] : '';
$ExtraMarkupOnGST2 = isset($postDataInward['ExtraMarkupOnGST']) ? $postDataInward['ExtraMarkupOnGST'] : 0;
$ExtraMarkup2 = isset($postDataInward['ExtraMarkup']) ? $postDataInward['ExtraMarkup'] : 0;
$DiscountValue2 = isset($postDataInward['DiscountValue']) ? $postDataInward['DiscountValue'] : 0;
$ExtraMarkupOnGST = isset($postData['ExtraMarkupOnGST']) ? $postData['ExtraMarkupOnGST'] : 0;
$ExtraMarkup = isset($postData['ExtraMarkup']) ? $postData['ExtraMarkup'] : 0;
$DiscountValue = isset($postData['DiscountValue']) ? $postData['DiscountValue'] : 0;
$ICSourceSysId = isset($postData['ICSourceSysId']) ? $postData['ICSourceSysId'] : '';
$bookingId = isset($postData['bookingId']) ? $postData['bookingId'] : '';
$IsRefundable = isset($postData['IsRefundable']) ? $postData['IsRefundable'] : '';
$IsRefundableInb = isset($postDataInward['IsRefundable']) ? $postDataInward['IsRefundable'] : '';
$FareBreakdown = isset($postData['FairRules'][0]['FareBreakdown']) ? $postData['FairRules'][0]['FareBreakdown'] : isset($postData['FairRules']['FareBreakdown']);
$FareBreakdownIn = isset($postDataInward['FairRules'][0]['FareBreakdown']) ? $postDataInward['FairRules'][0]['FareBreakdown'] : isset($postDataInward['FairRules']['FareBreakdown']);
// echo"<pre>";print_r($routeType);die('pp');
$ExtraMarkup = !empty($FareBreakdown) ? ($ExtraMarkup / count($FareBreakdown)) : $ExtraMarkup;
$DiscountValue = !empty($FareBreakdown) ? ($DiscountValue / count($FareBreakdown)) : $DiscountValue;
$ExtraMarkup2 = !empty($FareBreakdownIn) ? ($ExtraMarkup2 / count($FareBreakdownIn)) : $ExtraMarkup2;
$DiscountValue2 = !empty($FareBreakdownIn) ? ($DiscountValue2 / count($FareBreakdownIn)) : $DiscountValue2;
$ExtraMarkupOnGST = !empty($FareBreakdown) ? ($ExtraMarkupOnGST / count($FareBreakdown)) : $ExtraMarkupOnGST;
$ExtraMarkupOnGST2 = !empty($FareBreakdownIn) ? ($ExtraMarkupOnGST2 / count($FareBreakdownIn)) : $ExtraMarkupOnGST2;
$TotalDiscount = ($DiscountValue + $DiscountValue2);
$PassengerCount = isset($FareBreakdown[0]['PassengerCount']) ? $FareBreakdown[0]['PassengerCount'] : 1;
$calculatePrice = $this->calculatePrice([$FareBreakdown[0]]);
$calculateSum = $this->calculateSum($calculatePrice, $ExtraMarkup, $ExtraMarkupOnGST);
if ($route == 2) {
$calculatePriceIn = $this->calculatePrice([$FareBreakdownIn[0]]);
$calculateSumIn = $this->calculateSum($calculatePriceIn, $ExtraMarkup2, $ExtraMarkupOnGST2);
}
$routeType = 1;
if ($interNationalSearch == 1 && $route == 2) {
$routeType = 2;
}
// echo"<pre>";print_r($PassengerCount);die('pp');
$PaxFareDetaialsArr[0]['PaxType'] = 1;
$PaxFareDetaialsArr[0]['PaxType'] = 1;
$PaxFareDetaialsArr[0]['PaxCount'] = $sessionFlightSearchParams['adults'];
$PaxFareDetaialsArr[0]['basefare'] = isset($calculateSum['basefare']) ? (($calculateSum['basefare'] + $calculateSumIn['basefare']) / $PassengerCount) / $routeType : 0;
$PaxFareDetaialsArr[0]['markup'] = isset($calculateSum['markup']) ? number_format((($calculateSum['markup'] + $calculateSumIn['markup']) / $PassengerCount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[0]['total'] = isset($calculateSum['total']) ? number_format(($calculateSum['total'] + $calculateSumIn['total'] - $TotalDiscount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[0]['GstType'] = 18;
$PaxFareDetaialsArr[0]['TotalGST'] = isset($calculateSum['GSTOnMarkUp']) ? ($calculateSum['GSTOnMarkUp'] + $calculateSumIn['GSTOnMarkUp']) / $routeType : 0;
$PaxFareDetaialsArr[0]['supplier_name'] = '';
$PaxFareDetaialsArr[0]['supplier_id'] = 0;
$PaxFareDetaialsArr[0]['ExtraMarkup'] = number_format(($ExtraMarkup + $ExtraMarkup2) / $routeType, 2, '.', '');
$PaxFareDetaialsArr[0]['DiscountValue'] = number_format(($DiscountValue + $DiscountValue2) / $routeType, 2, '.', '');
$PaxFareDetaialsArr[0]['sessionFlightSearchParams'] = $sessionFlightSearchParams;
if ($sessionFlightSearchParams['child'] > 0 && $sessionFlightSearchParams['child'] > 0) {
$calculatePrice = $this->calculatePrice([$FareBreakdown[1]]);
$calculateSum = $this->calculateSum($calculatePrice, $ExtraMarkup, $ExtraMarkupOnGST);
if ($route == 2) {
$calculatePriceIn = $this->calculatePrice([$FareBreakdownIn[1]]);
$calculateSumIn = $this->calculateSum($calculatePriceIn, $ExtraMarkup2, $ExtraMarkupOnGST2);
}
$PaxFareDetaialsArr[1]['PaxType'] = 2;
$PaxFareDetaialsArr[1]['PaxCount'] = $sessionFlightSearchParams['child'];
$PaxFareDetaialsArr[1]['basefare'] = isset($calculateSum['basefare']) ? (($calculateSum['basefare'] + $calculateSumIn['basefare']) / $PassengerCount) / $routeType : 0;
$PaxFareDetaialsArr[1]['markup'] = isset($calculateSum['markup']) ? number_format((($calculateSum['markup'] + $calculateSumIn['markup']) / $PassengerCount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[1]['total'] = isset($calculateSum['total']) ? number_format(($calculateSum['total'] + $calculateSumIn['total'] - $TotalDiscount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[1]['GstType'] = 18;
$PaxFareDetaialsArr[1]['TotalGST'] = isset($calculateSum['GSTOnMarkUp']) ? ($calculateSum['GSTOnMarkUp'] + $calculateSumIn['GSTOnMarkUp']) / $routeType : 0;
$PaxFareDetaialsArr[1]['supplier_name'] = '';
$PaxFareDetaialsArr[1]['supplier_id'] = 0;
$PaxFareDetaialsArr[1]['ExtraMarkup'] = number_format(($ExtraMarkup + $ExtraMarkup2) / $routeType, 2, '.', '');
$PaxFareDetaialsArr[1]['DiscountValue'] = number_format(($DiscountValue + $DiscountValue2) / $routeType, 2, '.', '');
}
if ($sessionFlightSearchParams['infant'] > 0 && $sessionFlightSearchParams['infant'] > 0) {
$calculatePrice = $this->calculatePrice([$FareBreakdown[2]]);
$calculateSum = $this->calculateSum($calculatePrice, $ExtraMarkup, $ExtraMarkupOnGST);
if ($route == 2) {
$calculatePriceIn = $this->calculatePrice([$FareBreakdownIn[2]]);
$calculateSumIn = $this->calculateSum($calculatePriceIn, $ExtraMarkup2, $ExtraMarkupOnGST2);
}
$PaxFareDetaialsArr[2]['PaxType'] = 3;
$PaxFareDetaialsArr[2]['PaxCount'] = $sessionFlightSearchParams['infant'];
$PaxFareDetaialsArr[2]['basefare'] = isset($calculateSum['basefare']) ? ($calculateSum['basefare'] + $calculateSumIn['basefare']) / $routeType : 0;
$PaxFareDetaialsArr[2]['markup'] = isset($calculateSum['markup']) ? number_format(($calculateSum['markup'] + $calculateSumIn['markup']) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[2]['total'] = isset($calculateSum['total']) ? number_format(($calculateSum['total'] + $calculateSumIn['total'] - $TotalDiscount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[2]['GstType'] = 18;
$PaxFareDetaialsArr[2]['TotalGST'] = isset($calculateSum['GSTOnMarkUp']) ? ($calculateSum['GSTOnMarkUp'] + $calculateSumIn['GSTOnMarkUp']) / $routeType : 0;
$PaxFareDetaialsArr[2]['supplier_name'] = '';
$PaxFareDetaialsArr[2]['supplier_id'] = 0;
$PaxFareDetaialsArr[2]['ExtraMarkup'] = number_format($ExtraMarkup + $ExtraMarkup2, 2, '.', '');
$PaxFareDetaialsArr[2]['DiscountValue'] = number_format($DiscountValue + $DiscountValue2, 2, '.', '');
}
$PaxFareDetaials = $PaxFareDetaialsArr;
} else {
$interNationalSearch = isset($sessionFlightSearchParams['interNationalSearch']) ? $sessionFlightSearchParams['interNationalSearch'] : 0;
$route = isset($sessionFlightSearchParams['route']) ? $sessionFlightSearchParams['route'] : 0;
$sourceCityAirportCode = $sourceCityAirportCode_ = isset($sessionFlightSearchParams['sourceCityAirportCode']) ? $sessionFlightSearchParams['sourceCityAirportCode'] : '';
$destinationCityAirportCode = isset($sessionFlightSearchParams['destinationCityAirportCode']) ? $sessionFlightSearchParams['destinationCityAirportCode'] : '';
$ChooseMoreOptions = [];
if ($route == 2) {
$ChooseMoreOptions[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
$ChooseMoreOptions[$destinationCityAirportCode . '-' . $sourceCityAirportCode] = '';
$sourceCityAirportCode = [$sourceCityAirportCode, $destinationCityAirportCode];
$destinationCityAirportCode = [$destinationCityAirportCode, $sourceCityAirportCode_];
} elseif ($route == 1) {
$ChooseMoreOptions[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
$sourceCityAirportCode = [$sourceCityAirportCode];
$destinationCityAirportCode = [$destinationCityAirportCode];
}else{
foreach($sessionFlightSearchParams['from'] as $fKey => $fValue){
$sourceCityAirportCode_ = $sourceCityAirportCode = $fValue;
$destinationCityAirportCode = isset($sessionFlightSearchParams['to'][$fKey]) ? $sessionFlightSearchParams['to'][$fKey] : '';
$ChooseMoreOptions[$sourceCityAirportCode . '-' . $destinationCityAirportCode] = '';
}
$sourceCityAirportCode = [$sourceCityAirportCode, $destinationCityAirportCode];
$destinationCityAirportCode = [$destinationCityAirportCode, $sourceCityAirportCode_];
}
$PaxFareDetaials = $PaxFareDetaials; //$PaxFareDetaials;
}
$SLItem = [];
$ItemIndexes = 0;
if ($keySector) {
$PaxFareDetaialsArr = [];
foreach ($keySector as $sc => $vl) {
$PT = (isset($postDataItemNewArrNew[$sc])) ? $postDataItemNewArrNew[$sc] : $postDataItemNewArr[$sc];
// echo "<pre>";print_r($keySector);
// echo "<pre>";print_r($postDataItemNewArrNew);die;
$postData___ = '';
if ($PT) {
foreach ($PT as $sck => $value) {
if ($interNationalSearch == 1 && $route == 2) {
if ($ItemIndexes == 0) {
$matchIndex = $value['origin']['OrFlightNumber'] . '_' . $value['origin']['FareClass'];
} else {
$matchIndex = $value['destination']['DeFlightNumber'] . '_' . $value['destination']['FareClass'];
}
} else {
$matchIndex = $value['FlightNumber'] . '_' . $value['FareClass'];
}
if ($matchIndex == $vl) {
$postData___ = $value;
}
}
}
$ExtraMarkupOnGST = isset($postData___['ExtraMarkupOnGST']) ? $postData___['ExtraMarkupOnGST'] : 0;
$ExtraMarkup = isset($postData___['ExtraMarkup']) ? $postData___['ExtraMarkup'] : 0;
$DiscountValue = isset($postData___['DiscountValue']) ? $postData___['DiscountValue'] : 0;
$FareBreakdown = isset($postData___['FairRules'][0]['FareBreakdown']) ? $postData___['FairRules'][0]['FareBreakdown'] : $postData___['FairRules']['FareBreakdown'];
$ExtraMarkup = ($ExtraMarkup / count($FareBreakdown));
$DiscountValue = ($DiscountValue / count($FareBreakdown));
$ExtraMarkupOnGST = ($ExtraMarkupOnGST / count($FareBreakdown));
if ($FareBreakdown) {
foreach ($FareBreakdown as $key => $value) {
$PassengerCount = isset($value['PassengerCount']) ? $value['PassengerCount'] : 0;
$PassengerType = isset($value['PassengerType']) ? $value['PassengerType'] : 0;
$calculatePrice = $this->calculatePrice([$value]);
$calculateSum = $this->calculateSum($calculatePrice, $ExtraMarkup, $ExtraMarkupOnGST);
$PaxFareDetaialsArr[$key]['PaxType'] = $PassengerType;
$PaxFareDetaialsArr[$key]['PaxCount'] = $PassengerCount;
$PaxFareDetaialsArr[$key]['basefare'] += isset($calculateSum['basefare']) ? (($calculateSum['basefare'] + $calculateSumIn['basefare']) / $PassengerCount) / $routeType : 0;
$PaxFareDetaialsArr[$key]['markup'] += isset($calculateSum['markup']) ? number_format((($calculateSum['markup'] + $calculateSumIn['markup']) / $PassengerCount) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[$key]['total'] += isset($calculateSum['total']) ? number_format(($calculateSum['total'] + $calculateSumIn['total'] - $DiscountValue) / $routeType, 2, '.', '') : 0;
$PaxFareDetaialsArr[$key]['GstType'] = 18;
$PaxFareDetaialsArr[$key]['TotalGST'] += isset($calculateSum['GSTOnMarkUp']) ? ($calculateSum['GSTOnMarkUp'] + $calculateSumIn['GSTOnMarkUp']) / $routeType : 0;
$PaxFareDetaialsArr[$key]['supplier_name'] = '';
$PaxFareDetaialsArr[$key]['supplier_id'] = 0;
$PaxFareDetaialsArr[$key]['ExtraMarkup'] += number_format(($ExtraMarkup) / $routeType, 2, '.', '');
$PaxFareDetaialsArr[$key]['DiscountValue'] += number_format(($DiscountValue) / $routeType, 2, '.', '');
if ($key == 0) {
$PaxFareDetaialsArr[$key]['sessionFlightSearchParams'] = $sessionFlightSearchParams;
}
}
}
$SLItem[$sc] = $postData___;
$ItemIndexes++;
}
$PaxFareDetaials = $PaxFareDetaialsArr;
}
// echo "<pre>";print_r($sessionFlightSearchParams);die;
if (is_array($sessionFlightSearchParams['departure_dates'])) {
$departure_dates = explode("/", $sessionFlightSearchParams['departure_dates'][0]);
} else {
$departure_dates = explode("/", $sessionFlightSearchParams['departure_dates']);
}
$departureDates = $departure_dates[2] . "/" . $departure_dates[1] . "/" . ($departure_dates[0]);
$defaultSef = array(
'originDepTime' => $departureDates,
'destinationArrTime' => $departureDates
);
if ($route == 2) {
$return_dates = explode("/", $sessionFlightSearchParams['return_dates']);
$return_datesDates = $return_dates[2] . "/" . $return_dates[1] . "/" . ($return_dates[0]);
$defaultSefRe = array(
'originDepTime' => $return_datesDates,
'destinationArrTime' => $return_datesDates
);
}
// if ($this->_request->isXmlHttpRequest()) {
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign(array(
// 'PaxFareDetaials' => $PaxFareDetaials,
// 'Segments' => $Segments,
// 'interNationalSearch' => $interNationalSearch,
// 'ChooseMoreOptions' => $ChooseMoreOptions,
// ));
// $bodyText = $html->render('selectedoptionAjax.phtml');
// $response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
// echo json_encode($response);
// exit;
// }
// echo "<pre>";
// print_r(($defaultSef));
// print_r($postDataInward);
// echo "</pre>";
// die;
$this->view->B2BType = $IsB2BProposal;
$this->view->ChooseMoreOptions = (isset($ChooseMoreOptionsNew) && !empty($ChooseMoreOptionsNew)) ? $ChooseMoreOptionsNew : $ChooseMoreOptions;
$this->view->SLItem = $SLItem;
$this->view->defaultSef = $defaultSef;
$this->view->ChooseMoreArr = $ChooseMoreArr;
$this->view->ChooseMoreArrInb = $ChooseMoreArrInb;
$this->view->bookingId = $bookingId;
$this->view->IsRefundable = $IsRefundable;
$this->view->IsRefundableInb = $IsRefundableInb;
$this->view->PaxFareDetaials = $PaxFareDetaials;
$this->view->interNationalSearch = $interNationalSearch;
$this->view->Segments = $Segments = isset($postData['Segments']) ? $postData['Segments'] : [$defaultSef];
$this->view->SegmentsInward = isset($postDataInward['Segments']) ? $postDataInward['Segments'] : [$defaultSefRe];
$this->view->sourceCityAirportCode = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['sourceCityAirportCode']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['sourceCityAirportCode'] : '';
$this->view->destinationCityAirportCode = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['destinationCityAirportCode']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['destinationCityAirportCode'] : '';
$this->view->route = isset($PaxFareDetaials[0]['sessionFlightSearchParams']['route']) ? $PaxFareDetaials[0]['sessionFlightSearchParams']['route'] : '';
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
}
public function saveFlightInventoryDataAction() {
$this->_helper->layout->disableLayout();
$objPackage = new Travel_Model_TblPackage();
$objAirport = new Travel_Model_TblAirport();
$objFlight = new Travel_Model_TblFlight();
$this->paymentMdl = new Payment_Model_Payment();
if ($this->getRequest()->isPost()) {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$param = $this->getRequest()->getParams();
$fareRules = $param['fareRules'];
$cancellationPolicy = $param['cancellationPolicy'];
$internalRemarks = $param['internalRemarks'];
$currencytype = $param['currencytype'];
$paramArray = $this->getRequest()->getParams();
parse_str(urldecode(base64_decode($paramArray["data"])), $param);
$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
$param['fareRules'] = $fareRules;
$param['cancellationPolicy'] = $cancellationPolicy;
$param['internalRemarks'] = $internalRemarks;
$TPSysId = $param['TPSysId'];
if ((int) $param['MasterTPSysId'] > 0) {
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($TPSysId, null);
} else {
$arrCustomerInvoiceData = $objFlight->GetAgencyCustomerDetailsForBookingQuery($TPSysId);
}
$ispackage = isset($param['ispackage']) ? $param['ispackage'] : 0;
$IsB2BProposal = $arrCustomerInvoiceData[0]['IsB2BProposal'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$AgentSysId = $arrCustomerInvoiceData[0]['AgentSysId'];
// echo '<pre>';
// print_r($param);
// die;
$ai = 0;
$airlineinventories = [];
$arrFlightData = [];
if (isset($param['airlinename']) && !empty($param['airlinename'])) {
$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;
$currency = $param['currency'];
$currencytype = $param['currencytype'];
$flightType = $param['flightType'];
$checkInLuggage = $param['checkInLuggage'];
$cabainluggage = $param['cabainluggage'];
$IsLcc = $param['IsLcc'];
$TPSysId = $param['TPSysId'];
$editLeadId = $param['MasterTPSysId'];
$Refundable = $param['Refundable'];
$fareRules = $param['fareRules'];
$cancellationPolicy = $param['cancellationPolicy'];
$cabinclass = $param['cabinclass'];
$internalRemarks = $param['internalRemarks'];
$intCustomerSysId = trim($param['customerId']);
$gdspnrnumber = $param['gdspnrnumber'];
$pnrnumber = $param['pnrnumber'];
$bookingId = $param['bookingId'];
$adultCount = (int) $param['paxAdTx'];
$childCount = (int) $param['paxChTx'];
$infantCount = (int) $param['paxInTx'];
$totalPassengers = $adultCount + $childCount + $infantCount;
$arrtravellerList = $objFlight->travellerListForProposal($TPSysId);
$RoomInfoJson = $arrCustomerInvoiceData[0]['RoomInfoJson'];
$APIBookingRes = isset($arrCustomerInvoiceData[0]['APIBookingRes']) ? json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true) : array();
$sessionFlightSearchParams = isset($APIBookingRes[0]['sessionFlightSearchParams']) ? $APIBookingRes[0]['sessionFlightSearchParams'] : '';
if (!$sessionFlightSearchParams || empty($sessionFlightSearchParams)) {
$FlightTempData = $objFlight->GetFlightTempDataByTPSysId($TPSysId);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
$TempTrxId = isset($arrUrlData['post']['TrxId']) ? $arrUrlData['post']['TrxId'] : 0;
$bookingAllowed = (isset($arrUrlData['postData']['bookingAllowed']) && !empty($arrUrlData['postData']['bookingAllowed'])) ? $arrUrlData['postData']['bookingAllowed'] : 0;
}
$interNational = $sessionFlightSearchParams['interNationalSearch'];
$route = $sessionFlightSearchParams['route'];
// if ($interNational == 1 && $route == 2) {
// $route__ = 1;
// } else {
// $route__ = $sessionFlightSearchParams['route'];
// }
$route__ = $sessionFlightSearchParams['route'];
if ($route__ == 3) {
$route__ = (isset($sessionFlightSearchParams['departure_dates']) && !empty($sessionFlightSearchParams['departure_dates'])) ? count($sessionFlightSearchParams['departure_dates']) : 1;
}
$route = (int) $flightType;
// echo '<pre>';
// print_r($sessionFlightSearchParams);
// die;
if ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Non-Refundable';
}
$PaxFareDetaials = [];
$PaxFareDetaials[0]['PaxType'] = 1;
$PaxFareDetaials[0]['PaxCount'] = $param['paxAdTx'];
$PaxFareDetaials[0]['basefare'] = ($param['costAdTx'] / $route__);
$PaxFareDetaials[0]['markup'] = ($param['markupAdTx'] / $route__);
$PaxFareDetaials[0]['markupgst'] = ($param['hidden_gst_textbased_1'] / $route__);
$PaxFareDetaials[0]['total'] = ($param['totalAdTx'] / $route__);
$PaxFareDetaials[0]['GstType'] = $param['AdtextBased'];
$PaxFareDetaials[0]['DiscountValue'] = ($param['discAdTx'] / $route__);
if ($param['paxChTx'] > 0) {
$PaxFareDetaials[1]['PaxType'] = 2;
$PaxFareDetaials[1]['PaxCount'] = $param['paxChTx'];
$PaxFareDetaials[1]['basefare'] = ($param['costChTx'] / $route__);
$PaxFareDetaials[1]['markup'] = ($param['markupChTx'] / $route__);
$PaxFareDetaials[1]['markupgst'] = ($param['hidden_gst_textbased_2'] / $route__);
$PaxFareDetaials[1]['total'] = ($param['totalChTx'] / $route__);
$PaxFareDetaials[1]['GstType'] = $param['ChtextBased'];
$PaxFareDetaials[1]['DiscountValue'] = ($param['discChTx'] / $route__);
}
if ($param['paxInTx'] > 0) {
$PaxFareDetaials[2]['PaxType'] = 3;
$PaxFareDetaials[2]['PaxCount'] = $param['paxInTx'];
$PaxFareDetaials[2]['basefare'] = ($param['costInTx'] / $route__);
$PaxFareDetaials[2]['markup'] = ($param['markupInTx'] / $route__);
$PaxFareDetaials[2]['markupgst'] = ($param['hidden_gst_textbased_3'] / $route__);
$PaxFareDetaials[2]['total'] = ($param['totalInTx'] / $route__);
$PaxFareDetaials[2]['GstType'] = $param['IntextBased'];
$PaxFareDetaials[2]['DiscountValue'] = ($param['discInTx'] / $route__);
}
$FareBreakdown = [];
$BaseFareTotal = 0;
$MarkupTotal = 0;
$GSTTotal = 0;
$CostToAgentCustomerTotal = 0;
$TotalDiscountValue = 0;
if ($PaxFareDetaials) {
foreach ($PaxFareDetaials as $key => $price) {
$PaxCount = (int) $price['PaxCount'];
$PaxType = (int) $price['PaxType'];
$basefares = ((float) $price['basefare'] * $PaxCount);
$markup = ((float) $price['markup'] * $PaxCount);
$markupgst = ((float) $price['markupgst'] * $PaxCount);
$DiscountValue = ((float) $price['DiscountValue']);
$GstType = (int) $price['GstType'];
if ($PaxCount) {
if ($basefares <= 0) {
$response = array('succes' => false, 'msg' => 'Please enter cost.', 'index' => 'cost_textbased_' . ($key + 1) . '');
echo json_encode($response);
exit;
}
if ($markup < 0) {
$response = array('succes' => false, 'msg' => 'Please enter valid markup.', 'index' => 'cost_textbased_' . ($key + 1) . '');
echo json_encode($response);
exit;
}
}
$calculateServiceTax = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateServiceTax($markup, $GstType);
if ($route == 2 && $interNational == 1) {
$serviceTaxAmount = $calculateServiceTax['serviceTaxAmount'];
} else {
$serviceTaxAmount = $markupgst; //$calculateServiceTax['serviceTaxAmount'];
}
$BasePriceWithSTax = $calculateServiceTax['BasePriceWithSTax'];
$CostToAgentCustomer = ($basefares + $markup + $markupgst);
$CostToAgentCustomerTotal += $CostToAgentCustomer;
$BaseFareTotal += $basefares;
$MarkupTotal += $markup;
$GSTTotal += $serviceTaxAmount;
$TotalDiscountValue += $DiscountValue;
$FareBreakdown[] = array(
"Currency" => $currency,
"PassengerType" => $PaxType,
"PassengerCount" => $PaxCount,
"TaxIN" => 0,
"TotalBaseFare" => 0,
"BaseFareCal" => $basefares,
"BaseFare" => $basefares,
"CommissionEarned" => 0,
"TDS" => 0,
"MF" => 0,
"YQ" => 0,
"AGST" => 0,
"MFT" => 0,
"OT" => 0,
"MU" => 0,
"YR" => 0,
"intTotalGST" => $serviceTaxAmount,
"apiMarkup" => 0,
"IntCommission" => 0,
"apiTaxOnMarkup" => 0,
"FixedMarkUp" => $markup,
"GSTOnMarkUp" => $serviceTaxAmount,
"DiscountValue" => $DiscountValue,
"DiscountCoupon" => ($DiscountValue > 0) ? 1 : 0,
"CommEarned" => 0,
"GSTonComm" => 0,
"intGTXMarkUp" => 0,
"GTXMarkUpGST" => 0,
"AgentMarkUp" => 0,
"GSTOnAgentMarkUp" => 0,
"Agencycommission" => 0,
"TotalCommssionVal_ag" => 0,
"AdminComminAmount_ag" => 0,
"AgentB2CEarning" => 0,
"CostToAgentCustomer" => $CostToAgentCustomer - $DiscountValue,
"CostToAgent" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"PGCharge" => 0,
"Baggage" => $checkInLuggage,
"CabinBaggage" => $cabainluggage
);
}
}
$FairRules = array(
"Currency" => $currency,
"CurrencyRate" => 1,
"currencySysId" => $currencytype,
"BaseFare" => $BaseFareTotal,
"Tax" => "",
"YQTax" => "",
"OtherCharges" => 0,
"Discount" => 0,
"ServiceFee" => 0,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => ($BaseFareTotal + $MarkupTotal + $GSTTotal - $TotalDiscountValue),
"PublishedFare" => ($BaseFareTotal + $MarkupTotal + $GSTTotal - $TotalDiscountValue),
"PublishedFareAgent" => ($BaseFareTotal + $MarkupTotal + $GSTTotal - $TotalDiscountValue),
"OfferedFareAgent" => ($BaseFareTotal + $MarkupTotal + $GSTTotal - $TotalDiscountValue),
"OfferedFare" => $BaseFareTotal,
"PLBEarned" => 0,
"IncentiveEarned" => 0,
"TdsOnPLB" => 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"OnwardAutoTicket" => true,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $TraceId,
"ApiResultIndex" => "NA",
"IsGSTRequired" => 0,
"fareIdentifier" => "Special Deal",
"SeatAvailable" => "0",
"classOfBooking" => 0,
"FareClass" => $param['cabinclass'],
"intTotalGST" => 0,
"apiMarkup" => 0,
"IntCommission" => 0,
"apiTaxOnMarkup" => 0,
"FixedMarkUp" => $MarkupTotal,
"GSTOnMarkUp" => $GSTTotal,
"DiscountValue" => $TotalDiscountValue,
"DiscountCoupon" => ($TotalDiscountValue > 0) ? 1 : 0,
"CommEarned" => 0,
"CommEarnedAgent" => 0,
"GSTonComm" => 0,
"intGTXMarkUp" => 0,
"GTXMarkUpGST" => 0,
"AgentMarkUp" => 0,
"GSTOnAgentMarkUp" => 0,
"Agencycommission" => 0,
"TotalCommssionVal_ag" => 0,
"AdminComminAmount_ag" => 0,
"AgentB2CEarning" => 0,
"CostToAgentCustomer" => ($BaseFareTotal + $MarkupTotal + $GSTTotal - $TotalDiscountValue),
"CostToAgent" => 0,
"FareBreakdown" => $FareBreakdown,
);
// echo "<pre>";
// print_r($FairRules);
// die;
$TotalMealPrice = 0;
$TotalSeatPrice = 0;
$TotalBaggPrice = 0;
foreach ($param['airlinename'] as $aKey => $aVal) {
// $aKey <=
if ($param['flightType']) {
$SegmentsArray = [];
$SegmentsArray_intround = [];
foreach ($aVal as $aaKey => $aaVal) {
if (trim($param['airlinename_id'][$aKey][$aaKey]) != '') {
$isReturnSegment = (isset($param['isReturnSegment'][$aKey][$aaKey]) && !empty($param['isReturnSegment'][$aKey][$aaKey])) ? $param['isReturnSegment'][$aKey][$aaKey] : 0;
$DepartureTime = isset($param['departuretime'][$aKey][$aaKey]) ? $param['departuretime'][$aKey][$aaKey] : 0;
$arrivaltime = isset($param['arrivaltime'][$aKey][$aaKey]) ? $param['arrivaltime'][$aKey][$aaKey] : 0;
$EstimateHours = isset($param['EstimateHours'][$aKey][$aaKey]) ? $param['EstimateHours'][$aKey][$aaKey] : 0;
//$EstimateHours = strtotime($arrivaltime) - strtotime($DepartureTime);
$DEPEX = explode(' ', $DepartureTime);
$ARREX = explode(' ', $arrivaltime);
$DEPEXDATE = explode('/', $DEPEX[0]);
$DepartureDate = $DEPEXDATE[2] . "-" . $DEPEXDATE[1] . "-" . $DEPEXDATE[0];
$DEPEXTIME = $DEPEX[1];
$ARREXDATE = explode('/', $ARREX[0]);
$ArrivalDate = $ARREXDATE[2] . "-" . $ARREXDATE[1] . "-" . $ARREXDATE[0];
$ARREXTIME = $ARREX[1];
$LocalFromTime = $DepartureDate . ' ' . $DEPEXTIME;
$FromUTCTime = $DepartureDate . 'T' . $DEPEXTIME;
$LocalToTime = $ArrivalDate . ' ' . $ARREXTIME;
$ToUTCTime = $ArrivalDate . 'T' . $ARREXTIME;
$strDuration = $EstimateHours; //Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($LocalFromTime, $LocalToTime);
if ($ai == 0) {
$OnwardFromAirportCode = isset($param['fromAirportCode'][1][$aaKey]) ? $param['fromAirportCode'][1][$aaKey] : '';
$InwardFromAirportCode = isset($param['fromAirportCode'][2][$aaKey]) ? $param['fromAirportCode'][2][$aaKey] : '';
}
$OnwardToAirportCode = isset($param['toAirportCode'][1][$aaKey]) ? $param['toAirportCode'][1][$aaKey] : '';
$InwardToAirportCode = isset($param['toAirportCode'][2][$aaKey]) ? $param['toAirportCode'][2][$aaKey] : '';
$airlineinventories_id = (isset($param['airlineinventories_id'][$aKey][$aaKey]) && trim($param['airlineinventories_id'][$aKey][$aaKey]) != '') ? $param['airlineinventories_id'][$aKey][$aaKey] : '';
if (isset($airlineinventories_id) && $airlineinventories_id != '') {
$airlineinventories1[$ai] = [
'id' => $airlineinventories_id
];
} else {
$airlineinventories1[$ai] = [];
}
$mealdetails = isset($param['mealdetails'][$aKey][$aaKey]) ? $param['mealdetails'][$aKey][$aaKey] : '';
$baggagedetails = isset($param['baggagedetails'][$aKey][$aaKey]) ? $param['baggagedetails'][$aKey][$aaKey] : '';
$seatnumber = isset($param['seatnumber'][$aKey][$aaKey]) ? $param['seatnumber'][$aKey][$aaKey] : '';
$mealprice = isset($param['mealprice'][$aKey][$aaKey]) ? $param['mealprice'][$aKey][$aaKey] : '';
$baggageprice = isset($param['baggageprice'][$aKey][$aaKey]) ? $param['baggageprice'][$aKey][$aaKey] : '';
$seatprice = isset($param['seatprice'][$aKey][$aaKey]) ? $param['seatprice'][$aKey][$aaKey] : '';
$flightnumber = isset($param['flightnumber'][$aKey][$aaKey]) ? $param['flightnumber'][$aKey][$aaKey] : '';
$flightnumberEX = explode('-', $flightnumber);
$from = isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '';
$to = isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '';
$objAirport->strAirportCode = $from;
$arrSourceCityId = $objAirport->getAirportList();
$objAirport->strAirportCode = $to;
$arrdestinationCityId = $objAirport->getAirportList();
$intDestinationCountryCode = '';
if (!empty($arrSourceCityId)) {
$intSourceCityId = $arrSourceCityId[0]['CityId'];
$intCountryCode = trim($arrSourceCityId[0]['CountryCode']);
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
} else {
$intSourceCityId = "";
$intCountryCode = "";
}
if (!empty($arrdestinationCityId) > 0) {
$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';
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$interNationalSearch = true;
} else if ($intDestinaionCountryCode != "IN" || empty($intDestinaionCountryCode)) {
$interNationalSearch = true;
} else {
$interNationalSearch = false;
}
$filePath = $this->getflightlogo($flightnumberEX[0]);
$StopCount = isset($aVal) ? (count($aVal) - 1) : 0;
$trvDate = explode("/", $param['TravelDate']);
$TravelDate = $trvDate[2] . "-" . $trvDate[1] . "-" . ($trvDate[0]);
//echo $aaKey;
$airlineinventories2[$ai] = [
'FlightType' => $aKey,
'AirlineName' => $aaVal,
'gdspnrnumber' => $param['gdspnrnumber'][$aKey - 1],
'pnrnumber' => $param['pnrnumber'][$aKey - 1],
'bookingId' => $param['bookingId'][$aKey - 1],
'AirlineCode' => $flightnumberEX[0],
'FlightNumber' => $flightnumber,
'SourceAirportCode' => isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '',
'FromTerminal' => isset($param['fromAirportTerminal'][$aKey][$aaKey]) ? $param['fromAirportTerminal'][$aKey][$aaKey] : '',
'DestAirportCode' => isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '',
'ToTerminal' => isset($param['toAirportTerminal'][$aKey][$aaKey]) ? $param['toAirportTerminal'][$aKey][$aaKey] : '',
'Stops' => isset($aVal) ? (count($aVal) - 1) : 0,
'StopCount' => ($StopCount == 0) ? 'Non-Stop' : $StopCount . ' Stop',
'DepartureTime' => $DEPEXTIME,
'EstimateHours' => $EstimateHours,
'ArrivalTime' => $ARREXTIME,
'TotalFlightMembers' => $param['total_pax_textBased'],
'CurrencyType' => isset($param['currencytype']) ? $param['currencytype'] : 1,
'JourneyType' => 1,
'TripType' => $param['flightType'],
'IsInternational' => $interNationalSearch,
'SourcePlaceSysId' => $intSourceCityId,
'DestPlaceSysId' => $intdestinationCityId,
'TravelDate' => $TravelDate,
'LocalFromTime' => $LocalFromTime,
'FromUTCTime' => $FromUTCTime,
'LocalToTime' => $LocalToTime,
'ToUTCTime' => $ToUTCTime,
'SourcePlaceName' => trim($arrSourceCityId[0]['CityName']),
'DestPlaceName' => trim($arrdestinationCityId[0]['CityName']),
'FareClass' => '',
'LAYOVERCity' => '',
'GroundTime' => 0,
'LAYOVERDuration' => 0,
'FlyingMinutes' => 0,
'FlightDuration' => $strDuration,
'PublishedFare' => $param['grand_total_textBased'],
'logo' => $filePath,
];
$MealArrNew = [];
$SeatArrNew = [];
$BaggageArrNew = [];
if ($mealdetails) {
foreach ($mealdetails as $m => $meals) {
$TotalMealPrice += (isset($mealprice[$m]) && $mealprice[$m] > 0) ? $mealprice[$m] : 0;
$MealArrNew[$m - 1]['Currency'] = $currency;
$MealArrNew[$m - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$MealArrNew[$m - 1]['Code'] = '';
$MealArrNew[$m - 1]['Price'] = isset($mealprice[$m]) ? $mealprice[$m] : 0;
$MealArrNew[$m - 1]['Description'] = $meals;
$MealArrNew[$m - 1]['sector'] = $from . '-' . $to;
}
}
if ($seatnumber) {
foreach ($seatnumber as $m => $seat) {
$TotalSeatPrice += (isset($seatprice[$m]) && $seatprice[$m] > 0) ? $seatprice[$m] : 0;
$SeatArrNew[$m - 1]['Currency'] = $currency;
$SeatArrNew[$m - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$SeatArrNew[$m - 1]['Code'] = $seat;
$SeatArrNew[$m - 1]['Price'] = isset($seatprice[$m]) ? $seatprice[$m] : 0;
$SeatArrNew[$m - 1]['SeatNo'] = $seat;
$SeatArrNew[$m - 1]['sector'] = $from . '-' . $to;
}
}
if ($baggagedetails) {
foreach ($baggagedetails as $b => $bag) {
$TotalBaggPrice += (isset($baggageprice[$b]) && $baggageprice[$b] > 0) ? $baggageprice[$b] : 0;
$Weight = str_replace('Excess Baggage - ', '', $bag);
$BaggageArrNew[$b - 1]['Currency'] = $currency;
$BaggageArrNew[$b - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$BaggageArrNew[$b - 1]['Code'] = '';
$BaggageArrNew[$b - 1]['Price'] = isset($baggageprice[$b]) ? $baggageprice[$b] : 0;
$BaggageArrNew[$b - 1]['Weight'] = $Weight;
$BaggageArrNew[$b - 1]['sector'] = $from . '-' . $to;
}
}
//if ($isReturnSegment == 0) {
$SegmentsArray[$aaKey] = [
'isReturnSegment' => $isReturnSegment,
'segmentid' => $flightnumberEX[1] . '' . $aaKey,
'originAirportName' => trim($arrSourceCityId[0]['AirportTitle']),
'destinationAirportName' => trim($arrdestinationCityId[0]['AirportTitle']),
'originCityName' => trim($arrSourceCityId[0]['CityName']),
'originCountryName' => trim($arrSourceCityId[0]['CountryName']),
'destinationCityName' => trim($arrdestinationCityId[0]['CityName']),
'destinationCountryName' => trim($arrdestinationCityId[0]['CountryName']),
'destinationAirportCode' => isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '',
'destinationArrTime' => $ToUTCTime,
'SegFlightNumber' => $flightnumber,
'AirlineCode' => $flightnumberEX[0],
'AirlineName' => $aaVal,
'FareClass' => $cabinclass,
'originAirportCode' => isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '',
'originDepTime' => $FromUTCTime,
'TripIndicator' => '',
'Baggage' => $checkInLuggage,
'CabinBaggage' => $cabainluggage,
'IsBaggage' => true,
'IsMealIncludes' => false,
'Duration' => 130,
'GroundTime' => 0,
'NoOfSeatAvailable' => 9,
'strDepartureDtTime' => $DEPEXTIME,
'strArrivalDtTime' => $ARREXTIME,
'FlightDuration' => $strDuration,
'LAYOVERDuration' => null,
'LAYOVERCity' => '',
'DepTerminal' => isset($param['fromAirportTerminal'][$aKey][$aaKey]) ? $param['fromAirportTerminal'][$aKey][$aaKey] : '',
'ArrTerminal' => isset($param['toAirportTerminal'][$aKey][$aaKey]) ? $param['toAirportTerminal'][$aKey][$aaKey] : '',
'filePath' => $filePath,
"BAGGAGEARRAY" => $BaggageArrNew,
"MEALARRAY" => $MealArrNew,
"SEATARRAY" => $SeatArrNew,
];
// } else {
// $SegmentsArray_intround[$aaKey] = [
// 'isReturnSegment' => $isReturnSegment,
// 'segmentid' => $flightnumberEX[1] . '' . $aaKey,
// 'originAirportName' => trim($arrSourceCityId[0]['AirportTitle']),
// 'destinationAirportName' => trim($arrdestinationCityId[0]['AirportTitle']),
// 'originCityName' => trim($arrSourceCityId[0]['CityName']),
// 'originCountryName' => trim($arrSourceCityId[0]['CountryName']),
// 'destinationCityName' => trim($arrdestinationCityId[0]['CityName']),
// 'destinationCountryName' => trim($arrdestinationCityId[0]['CountryName']),
// 'destinationAirportCode' => isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '',
// 'destinationArrTime' => $ToUTCTime,
// 'SegFlightNumber' => $flightnumber,
// 'AirlineCode' => $flightnumberEX[0],
// 'AirlineName' => $aaVal,
// 'FareClass' => '',
// 'originAirportCode' => isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '',
// 'originDepTime' => $FromUTCTime,
// 'TripIndicator' => '',
// 'Baggage' => $checkInLuggage,
// 'CabinBaggage' => $cabainluggage,
// 'IsBaggage' => true,
// 'IsMealIncludes' => false,
// 'Duration' => 130,
// 'GroundTime' => 0,
// 'NoOfSeatAvailable' => 9,
// 'strDepartureDtTime' => $DEPEXTIME,
// 'strArrivalDtTime' => $ARREXTIME,
// 'FlightDuration' => $strDuration,
// 'LAYOVERDuration' => null,
// 'LAYOVERCity' => '',
// 'DepTerminal' => isset($param['fromAirportTerminal'][$aKey][$aaKey]) ? $param['fromAirportTerminal'][$aKey][$aaKey] : '',
// 'ArrTerminal' => isset($param['toAirportTerminal'][$aKey][$aaKey]) ? $param['toAirportTerminal'][$aKey][$aaKey] : '',
// 'filePath' => $filePath,
// ];
// }
$airlineinventories[$ai] = array_merge($airlineinventories1[$ai], $airlineinventories2[$ai]);
$ai++;
}
}
// echo '<pre>';
// print_r($airlineinventories);
// echo '<pre>';
// die;
$OriginSegments = current($airlineinventories);
$DestinationSegments = end($airlineinventories);
$ArrSegments = current(array_values($SegmentsArray));
$DepSegments = end(array_values($SegmentsArray));
//$SegmentsArray_intround = (array_values($SegmentsArray_intround));
// print_r($DestinationSegments['LocalFromTime']);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($OriginSegments['ToUTCTime'], $DestinationSegments['LocalFromTime']);
$Duration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateOnlyMinutes($OriginSegments['ToUTCTime'], $DestinationSegments['LocalFromTime']);
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$AirlineCode = $OriginSegments['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$Indexes = ($aKey - 1);
$gdspnrnumberstr = isset($gdspnrnumber[$Indexes]) ? $gdspnrnumber[$Indexes] : '';
$pnrnumberstr = isset($pnrnumber[$Indexes]) ? $pnrnumber[$Indexes] : '';
$bookingIdstr = isset($bookingId[$Indexes]) ? $bookingId[$Indexes] : '';
$arrFlightData[$Indexes]['Currency'] = $currency;
$arrFlightData[$Indexes]['CurrencyRate'] = 1;
$arrFlightData[$Indexes]['currencySysId'] = $currencytype;
$arrFlightData[$Indexes]['bookingId'] = $bookingIdstr;
$arrFlightData[$Indexes]['OnwardGroupPNR'] = $pnrnumberstr;
$arrFlightData[$Indexes]['gdspnrnumber'] = $gdspnrnumberstr;
$arrFlightData[$Indexes]['FlightNumber'] = $OriginSegments['FlightNumber'];
$arrFlightData[$Indexes]['AirlineName'] = $OriginSegments['AirlineName'];
$arrFlightData[$Indexes]['AirlineCode'] = $OriginSegments['AirlineCode'];
$arrFlightData[$Indexes]['AirInvenSysId'] = '';
$arrFlightData[$Indexes]['GroundTime'] = $Duration;
$arrFlightData[$Indexes]['LAYOVERDuration'] = $LAYOVERDuration;
$arrFlightData[$Indexes]['IsLCC'] = $IsLcc;
$arrFlightData[$Indexes]['IsRefundable'] = $Refundable;
$arrFlightData[$Indexes]['interNationalSearch'] = $interNational;
$arrFlightData[$Indexes]['OnwardAutoTicket'] = true;
$arrFlightData[$Indexes]['IsRefundableTxt'] = $IsRefundableTxt;
$arrFlightData[$Indexes]['SearchTraceId'] = $TraceId;
$arrFlightData[$Indexes]['apiTraceId'] = $TraceId;
$arrFlightData[$Indexes]['AirlineSysId'] = $airlineSysId;
$arrFlightData[$Indexes]['DepartureTime'] = $OriginSegments['DepartureTime'];
$arrFlightData[$Indexes]['ArrivalTime'] = $OriginSegments['ArrivalTime'];
$arrFlightData[$Indexes]['TravelDate'] = $OriginSegments['TravelDate'];
$arrFlightData[$Indexes]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['LocalFromTime']));
$arrFlightData[$Indexes]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['LocalToTime']));
$arrFlightData[$Indexes]['LocalFromTime'] = $OriginSegments['LocalFromTime'];
$arrFlightData[$Indexes]['FromUTCTime'] = $OriginSegments['FromUTCTime'];
$arrFlightData[$Indexes]['LocalToTime'] = $DestinationSegments['LocalToTime'];
$arrFlightData[$Indexes]['ToUTCTime'] = $DestinationSegments['ToUTCTime'];
$arrFlightData[$Indexes]['FlightDuration'] = $OriginSegments['FlightDuration'];
$arrFlightData[$Indexes]['SourcePlaceSysId'] = $OriginSegments['SourcePlaceSysId'];
$arrFlightData[$Indexes]['DestPlaceSysId'] = $DestinationSegments['DestPlaceSysId'];
$arrFlightData[$Indexes]['SourceAirportCode'] = $OriginSegments['SourceAirportCode'];
$arrFlightData[$Indexes]['DestAirportCode'] = $DestinationSegments['DestAirportCode'];
$arrFlightData[$Indexes]['SourcePlaceName'] = $OriginSegments['SourcePlaceName'];
$arrFlightData[$Indexes]['DestPlaceName'] = $DestinationSegments['DestPlaceName'];
if ($Indexes == 1) {
$arrFlightData[$Indexes]['FlightNumber'] = $DestinationSegments['FlightNumber'];
$arrFlightData[$Indexes]['AirlineName'] = $DestinationSegments['AirlineName'];
$arrFlightData[$Indexes]['AirlineCode'] = $DestinationSegments['AirlineCode'];
$arrFlightData[$Indexes]['DepartureTime'] = $DestinationSegments['DepartureTime'];
$arrFlightData[$Indexes]['ArrivalTime'] = $DestinationSegments['ArrivalTime'];
$arrFlightData[$Indexes]['TravelDate'] = $DestinationSegments['TravelDate'];
$arrFlightData[$Indexes]['DepartureDateTxt'] = date('D, d M', strtotime($DestinationSegments['LocalFromTime']));
$arrFlightData[$Indexes]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['LocalToTime']));
$arrFlightData[$Indexes]['LocalFromTime'] = str_replace('T', ' ', $ArrSegments['destinationArrTime']);
$arrFlightData[$Indexes]['FromUTCTime'] = $ArrSegments['destinationArrTime'];
$arrFlightData[$Indexes]['LocalToTime'] = str_replace('T', ' ', $DepSegments['originDepTime']);
$arrFlightData[$Indexes]['ToUTCTime'] = $DepSegments['originDepTime'];
$arrFlightData[$Indexes]['FlightDuration'] = $DestinationSegments['FlightDuration'];
}
$arrFlightData[$Indexes]['IsDirect'] = '0';
$arrFlightData[$Indexes]['FareClass'] = '';
$arrFlightData[$Indexes]['StopCount'] = $OriginSegments['StopCount'];
$arrFlightData[$Indexes]['StopCountShow'] = $OriginSegments['StopCount'];
$arrFlightData[$Indexes]['Stops'] = $OriginSegments['Stops'];
$arrFlightData[$Indexes]['TotalFlightMembers'] = $OriginSegments['TotalFlightMembers'];
$arrFlightData[$Indexes]['CurrencyType'] = $currencytype;
$arrFlightData[$Indexes]['PublishedFare'] = $CostToAgentCustomerTotal;
$arrFlightData[$Indexes]['PublishedFareTxt'] = number_format($CostToAgentCustomerTotal, 2);
$arrFlightData[$Indexes]['ApiResultIndex'] = '';
$arrFlightData[$Indexes]['JourneyType'] = $OriginSegments['JourneyType'];
$arrFlightData[$Indexes]['TripType'] = $OriginSegments['TripType'];
$arrFlightData[$Indexes]['IsInternational'] = $OriginSegments['IsInternational'];
$arrFlightData[$Indexes]['logo'] = $OriginSegments['logo'];
$arrFlightData[$Indexes]['IsSeriesFareData'] = false;
$arrFlightData[$Indexes]['IsTJFlightAPI'] = false;
$arrFlightData[$Indexes]['ICSourceSysId'] = 9;
$arrFlightData[$Indexes]['supplier'] = $param['supplier'];
$arrFlightData[$Indexes]['SupplierSysId'] = $param['supplier_id'];
$arrFlightData[$Indexes]['FareRules'] = $fareRules;
$arrFlightData[$Indexes]['CancellationPolicy'] = $cancellationPolicy;
$arrFlightData[$Indexes]['InternalRemarks'] = $internalRemarks;
$arrFlightData[$Indexes]['isAdobrMandatory'] = false;
$arrFlightData[$Indexes]['isCdobrMandatory'] = false;
$arrFlightData[$Indexes]['isIdobrMandatory'] = false;
$arrFlightData[$Indexes]['IsPassMandatory'] = ($OriginSegments['IsInternational'] == 1) ? false : false;
$arrFlightData[$Indexes]['IsPassExpiry'] = ($OriginSegments['IsInternational'] == 1) ? false : false;
$arrFlightData[$Indexes]['IsPassIssue'] = ($OriginSegments['IsInternational'] == 1) ? false : false;
$arrFlightData[$Indexes]['FairRules'] = ($FairRules);
$arrFlightData[$Indexes]['Segments'] = array_values($SegmentsArray);
if ($route == 2 && $interNational == 1) {
$arrFlightData[$Indexes]['SegmentsArray_intround'] = array_values($SegmentsArray_intround);
}
}
}
}
// print_r($interNational);
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$arrFlightDataInset = [];
if ($arrFlightData) {
foreach ($arrFlightData as $key => $val) {
$arrFlightDataInset[$key] = $val;
$SegmentsArray = $val['Segments'];
$SegmentsArray_intround = isset($val['SegmentsArray_intround']) ? $val['SegmentsArray_intround'] : [];
$newarr = [];
if ($SegmentsArray) {
foreach ($SegmentsArray as $keyyy => $value) {
$start = ($SegmentsArray[$keyyy]['destinationArrTime']);
$LAYOVERCity = ($SegmentsArray[$keyyy]['destinationCityName']);
if (isset($SegmentsArray[$keyyy + 1]['originDepTime'])) {
$end = ($SegmentsArray[$keyyy + 1]['originDepTime']);
} else {
$end = 0;
}
$LayoverDuration = null;
$GroundTime = 0;
if ($end > 0) {
$LayoverDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($start, $end);
$timeFirst = strtotime($start);
$timeSecond = strtotime($end);
$GroundTime = (($timeSecond - $timeFirst) / 60);
}
$SegmentsArray[$keyyy]['LAYOVERDuration'] = $LayoverDuration;
$SegmentsArray[$keyyy]['LAYOVERCity'] = $LAYOVERCity;
$SegmentsArray[$keyyy]['GroundTime'] = $GroundTime;
//$newarr[] = ['start' => $start, 'end' => $end, 'LayoverDuration' => $LayoverDuration, 'GroundTime' => $GroundTime];
}
}
$ArrSegments = current(($SegmentsArray));
$DepSegments = end(($SegmentsArray));
$destinationArrTime = $ArrSegments['destinationArrTime'];
$originDepTime = $ArrSegments['originDepTime'];
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($val['LocalFromTime'], $val['LocalToTime']);
$arrFlightDataInset[$key]['FlightDuration'] = $strDuration;
$arrFlightDataInset[$key]['ArrivalTime'] = $DepSegments['strArrivalDtTime'];
$arrFlightDataInset[$key]['Segments'] = $SegmentsArray;
$arrFlightDataInset[$key]['SegmentsArray_intround'] = [];
if ($key == 1) {
$arrFlightDataInset[$key]['FlightNumber'] = $ArrSegments['SegFlightNumber'];
$arrFlightDataInset[$key]['AirlineName'] = $ArrSegments['AirlineName'];
$arrFlightDataInset[$key]['AirlineCode'] = $ArrSegments['AirlineCode'];
$arrFlightDataInset[$key]['DepartureTime'] = $ArrSegments['strDepartureDtTime'];
$arrFlightDataInset[$key]['ArrivalTime'] = $DepSegments['strArrivalDtTime'];
// $arrFlightDataInset[$key]['TravelDate'] = $DestinationSegments['TravelDate'];
$arrFlightDataInset[$key]['DepartureDateTxt'] = date('D, d M', strtotime($ArrSegments['originDepTime']));
$arrFlightDataInset[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DepSegments['destinationArrTime']));
$arrFlightDataInset[$key]['LocalFromTime'] = str_replace('T', ' ', $ArrSegments['originDepTime']);
$arrFlightDataInset[$key]['FromUTCTime'] = $ArrSegments['originDepTime'];
$arrFlightDataInset[$key]['LocalToTime'] = str_replace('T', ' ', $DepSegments['destinationArrTime']);
$arrFlightDataInset[$key]['ToUTCTime'] = $DepSegments['destinationArrTime'];
$strDuration1 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes(str_replace('T', ' ', $ArrSegments['originDepTime']), str_replace('T', ' ', $DepSegments['destinationArrTime']));
$arrFlightDataInset[$key]['FlightDuration'] = $strDuration1;
$objAirport->strAirportCode = $ArrSegments['originAirportCode'];
$arrSourceCityId = $objAirport->getAirportList();
$objAirport->strAirportCode = $DepSegments['destinationAirportCode'];
$arrdestinationCityId = $objAirport->getAirportList();
$intDestinationCountryCode = '';
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 = "";
}
$arrFlightDataInset[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrFlightDataInset[$key]['DestPlaceSysId'] = $intdestinationCityId;
$arrFlightDataInset[$key]['SourceAirportCode'] = $ArrSegments['originAirportCode'];
$arrFlightDataInset[$key]['DestAirportCode'] = $DepSegments['destinationAirportCode'];
$arrFlightDataInset[$key]['SourcePlaceName'] = $ArrSegments['originCityName'];
$arrFlightDataInset[$key]['DestPlaceName'] = $DepSegments['destinationCityName'];
}
}
}
$bookingAllowed = (isset($sessionFlightSearchParams['bookingAllowed']) && $sessionFlightSearchParams['bookingAllowed']) ? $sessionFlightSearchParams['bookingAllowed'] : $bookingAllowed;
$sessionFlightSearchParams['bookingAllowed'] = $bookingAllowed;
$versionSysidArr = [];
$AirInvenSysIdArray = [];
if ($bookingAllowed == 2 || !empty($arrUrlData['arrIntTpAirId']) || !empty($arrUrlData['AirInvenSysIdArr'])) {
$versionSysidArr = $arrUrlData['arrIntTpAirId'];
$AirInvenSysIdArray = $arrUrlData['AirInvenSysIdArr'];
$objFlight->deleteTravelPlanPax($TPSysId);
}
// echo "<pre>";
// print_r($versionSysidArr);
// print_r($AirInvenSysIdArray);
// die;
// arrIntTpAirId AirInvenSysIdArr
$BookingData = $intOutBoundId = $arrFlightDataInset;
$arrCustomer = array();
$arrCustomerMembers = array();
$ForCustomerSession = array();
$key = 0;
$post = $param;
$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'];
$fromAirportCode = $BookingData[0]['SourceAirportCode'];
$toAirportCode = $BookingData[0]['DestAirportCode'];
$bookingId = $BookingData[0]['bookingId'];
$IsSeriesFareData = isset($BookingData[0]['IsSeriesFareData']) ? $BookingData[0]['IsSeriesFareData'] : 0;
$ICSourceSysId = isset($BookingData[0]['ICSourceSysId']) ? $BookingData[0]['ICSourceSysId'] : 0;
$route = $post['flightType'];
$interNationalSearch = $BookingData[0]['IsInternational'];
$arrSelectedFlightDetails = [$BookingData[0]];
$departure_dates_string = $post['TravelDate'];
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$return_dates_string = $post['return_dates'];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($post['return_dates']) && !empty($post['return_dates'])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
if ($post['flightType'] == "2") {
$departureDatesValid = $return_dates;
} else {
$departureDatesValid = $departure_dates;
}
if ($post['flightType'] == 1) {
$sectorTitle = $fromAirportCode . '-' . $toAirportCode;
} else {
$sectorTitle = $fromAirportCode[0] . '-' . $toAirportCode . '-' . $fromAirportCode;
}
$isgstapply = (trim($this->getRequest()->getParam('isgstapply'))) ? trim($this->getRequest()->getParam('isgstapply')) : 0;
$gstnnumber = (trim($this->getRequest()->getParam('gstnnumber'))) ? trim($this->getRequest()->getParam('gstnnumber')) : '';
$companyname = (trim($this->getRequest()->getParam('companyname'))) ? trim($this->getRequest()->getParam('companyname')) : '';
$gstemail = (trim($this->getRequest()->getParam('gstemail'))) ? trim($this->getRequest()->getParam('gstemail')) : '';
$gstphone = (trim($this->getRequest()->getParam('gstphone'))) ? trim($this->getRequest()->getParam('gstphone')) : '';
$gstaddress = (trim($this->getRequest()->getParam('gstaddress'))) ? trim($this->getRequest()->getParam('gstaddress')) : '';
$gststate = (trim($this->getRequest()->getParam('gststate'))) ? trim($this->getRequest()->getParam('gststate')) : '';
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['mobile_number'];
$airline_email = $post['email_id'];
$passengerDob = $post['passenger-dob-' . $i];
$AdultpassengerpassengerDob = isset($post['passenger-dob-' . $i]) ? $post['passenger-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] : '';
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'] : 0;
$passengerAddress = ($post['passenger-address-1']) ? $post['passenger-address-1'] : 0;
$AdultageCalculator = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->ageCalculator($departure_dates, $AdultpassengerpassengerDob);
if (empty($airline_number)) {
$response = array('succes' => false, 'msg' => 'Please enter mobile number.', 'index' => 'airline_number');
echo json_encode($response);
exit;
}
if (strlen($airline_number) != 10 && strlen($airline_number) != 11 && strlen($airline_number) != 8 && strlen($airline_number) != 9) {
$response = array('succes' => false, 'msg' => 'Please enter a valid mobile 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 && strlen($mobileNumber) != 8 && strlen($mobileNumber) != 9) {
$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 (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) {
$departureDates = $post['TravelDate'];
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 = $post['TravelDate'];
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 = $post['TravelDate'];
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;
$AgencySysId = $this->intLoggedinAgencyId;
if ($IsB2BProposal == 1) {
$AgencySysId__ = $B2BAgencySysId;
} else {
$AgencySysId__ = $this->intLoggedinAgencyId;
}
if ($IsB2BProposal == 1 && $i == 1 && $relation == 0) {
$relation = 9;
}
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 {
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($arrCustomer);
// echo "<pre>";
// print_r($arrCustomerMembers);
// die; TB_IC_Trans_API_Air
if (empty($intCustomerSysId)) {
throw new Exception('Customer Id not found.');
}
$arrCustomerMembersIds = array();
if (!empty($arrCustomerMembers)) {
$arrCustomerMembersIds = $objFlight->createAgencyCustomerMembers($arrCustomerMembers, $AgencySysId__, $intCustomerSysId);
}
$createDate = date('Y-m-d H:i:s');
$currentDate = date('Y-m-d H:i:s');
if (empty($editLeadId)) {
} else {
$TPSysId = $TPSysId;
}
$MealFare = $TotalMealPrice;
$BaggFare = $TotalBaggPrice;
$SeatPrice = $TotalSeatPrice;
$PublishedFare = 0;
$BaseAmount = 0;
$AgentCommisionEarned = 0;
$AgentCommisionEarnedGST = 0;
$AgencyMarkUp = 0;
$AgencyMarkUpGST = 0;
$GTXMarkUp = 0;
$GTXMarkUpGST = 0;
$TotalExtraCharge = 0;
$AgentServiceTaxAmount = 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) - $customerDiscount); //$GrandTotalBaseFare;
$AgentServiceTaxAmount += $intTotalGST;
$AgentCommisionEarned += $FixedMarkUp;
}
}
$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);
$BaseAmount_TRX = $BaseAmount;
$PublishedFare_TRX = $PublishedFare;
// die;
if (!empty($intCustomerSysId)) {
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($intCustomerSysId);
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
//$PlanBookingId = "Q/" . date('y');
//$arrTravelPlan['PlanBookingId'] = $PlanBookingId; AirInvenSysId
//$arrTravelPlan['MasterTPSysId'] = $editLeadId; //$TPSysId;
$arrTravelPlan['Price'] = $intOfferedFare;
$arrTravelPlan['TotalCost'] = $totalCost;
$arrTravelPlan['NetPrice'] = $totalCost;
$arrTravelPlan['DiscountVal'] = ($TotalDiscountValue);
$arrTravelPlan['AgencyMarkUp'] = ($AgentCommisionEarned + $TotalExtraMarkup);
$arrTravelPlan['AgentServiceTaxAmount'] = ($AgentServiceTaxAmount + $TotalExtraMarkupOnGST);
$arrTravelPlan['VersionId'] = 1;
$arrTravelPlan['AgencySysId'] = $this->intLoggedinAgencyId;
$arrTravelPlan['AgentSysId'] = ($IsB2BProposal == 1) ? $AgentSysId : $this->intLoggedinUserId;
$arrTravelPlan['CreatorSysId'] = $this->intLoggedinUserId;
$arrTravelPlan['PlanType'] = '1'; // For Flight
$arrTravelPlan['SupplierSysId'] = $param['supplier_id'];
$arrTravelPlan['StatusType'] = 4;
$arrTravelPlan['InventoryType'] = 1;
$arrTravelPlan['RoomInfoJson'] = $RoomInfoJson;
$arrTravelPlan['CustomerSysId'] = $intCustomerSysId;
$arrTravelPlan['CurrencyType'] = $currencytype; //!empty($BookingData[0]['currencySysId']) ? $BookingData[0]['currencySysId'] : $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'] = $BookingData[0]['SourceAirportCode'] . "-" . $BookingData[0]['DestAirportCode'];
$arrTravelPlan['IsHotelFromApi'] = 1;
$arrTravelPlan['ProposalEmailTo'] = !empty($email_id) ? trim($email_id) : 0;
$arrTravelPlan['StartDate'] = $departure_dates;
$arrTravelPlan['ValidTill'] = $return_dates;
$arrTravelPlan['IsMarkForDel'] = 0;
$arrTravelPlan['IsActive'] = 1;
$arrTravelPlan['IsAprooved'] = 1;
$arrTravelPlan['LeadSourceSysId'] = $leadsource;
$arrTravelPlan['B2BAgencySysId'] = $AgencySysId__;
$arrTravelPlan['IsB2BProposal'] = $IsB2BCustomer;
$arrTravelPlan['Title'] = !empty($sectorTitle) ? $sectorTitle : 'NA';
if (empty($editLeadId)) {
$arrTravelPlan['CreateDate'] = $currentDate;
$arrTravelPlan['UpdateDate'] = $currentDate;
$arrTravelPlan['ApproveDate'] = $currentDate;
$PlanBookingId = "QS/" . date('y');
$arrTravelPlan['PlanBookingId'] = $PlanBookingId;
$arrTravelPlan['MasterTPSysId'] = $TPSysId;
$editLeadId = $TPSysId;
$TPSysId = $objFlight->insertTravelPlan($arrTravelPlan);
} else {
$objFlight->updateBookingStatusTravelPlanOnly($arrTravelPlan, $TPSysId, $editLeadId);
}
//
$arrPaxData = array();
foreach ($arrSelectedFlightDetails as $ks => $flightRounds) {
$arrtraveller = isset($arrtravellerList[$ks]) ? $arrtravellerList[$ks] : '';
$TPPaxSysId = !empty($arrtraveller['TPPaxSysId']) ? $arrtraveller['TPPaxSysId'] : 0;
if (!empty($TPSysId)) {
if (!empty($arrCustomer)) {
$arrPaxData['TPSysId'] = $TPSysId;
$arrPaxData['VersionId'] = '1';
$arrPaxData['CustomerSysId'] = $intCustomerSysId;
$arrPaxData['MemberSysId'] = 0;
$arrPaxData['IsLeadPax'] = 1;
$arrPaxData['UpdateDate'] = date('Y-m-d H:i:s');
$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['GstNumber'] = $gstnnumber;
$arrPaxData['GstCompany'] = $companyname;
$arrPaxData['GstEmail'] = $gstemail;
$arrPaxData['GstPhone'] = $gstphone;
$arrPaxData['GstAddress'] = $gstaddress;
$arrPaxData['GstState'] = $gststate;
$arrPaxData['isgstapply'] = $isgstapply;
//if ($TPPaxSysId == 0) { IsLeadPax
$objFlight->insertTravelPlanPax($arrPaxData);
// } else {
// $objFlight->updateTravelPlanPax($arrPaxData, $TPPaxSysId);
// }
//
}
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'] = date('Y-m-d H:i:s');
$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['GstNumber'] = $gstnnumber;
$arrPaxData['GstCompany'] = $companyname;
$arrPaxData['GstEmail'] = $gstemail;
$arrPaxData['GstPhone'] = $gstphone;
$arrPaxData['GstAddress'] = $gstaddress;
$arrPaxData['GstState'] = $gststate;
$arrPaxData['isgstapply'] = $isgstapply;
//if ($TPPaxSysId == 0) {
$objFlight->insertTravelPlanPax($arrPaxData);
// } else {
// $objFlight->updateTravelPlanPax($arrPaxData, $TPPaxSysId);
// }
$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;
$objFlight->DeleteTravelPlanItenary($TPSysId);
$TPIntSysId = $objFlight->insertTravelPlanItenary($arrPlanItenary);
$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 = date('Y-m-d H:i:s');
$CreateDate = date('Y-m-d H:i:s');
$ApproveBy = $this->intLoggedinAgencyId;
$ApprovalDate = date('Y-m-d H:i:s');
$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_Old = (isset($AirInvenSysIdArray[$keys]) && !empty($AirInvenSysIdArray[$keys])) ? $AirInvenSysIdArray[$keys] : 0;
$versionSysid = isset($versionSysidArr[$keys]) ? $versionSysidArr[$keys] : 0;
if ($interNationalSearch == "1" && $route == "2") {
$Segments = $flightRounds['Segments'];
} else {
$Segments = $flightRounds['Segments'];
}
$SeatPriceSeg = $TotalSeatPrice;
$MealPriceSeg = $TotalMealPrice;
$BagPriceSeg = $TotalBaggPrice;
$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)));
}
$AirlineCode = $flightRounds['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
//$airlineSysId = $flightRounds['AirlineSysId'];
$FlyingMinutes = $FlyingMinutes;
if (count($flightRounds['Segments']) > 1) {
$SegmentsCount = count($flightRounds['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 = $flightRounds['IsRefundable'];
$strFareClass = $flightRounds['FareClass'];
$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'] = $IsRefundable;
$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'] = $currencytype; //$currencySysId;
$arrInsertFlightData['PublishedFare'] = $OfferedFare; // As Discussed with GG Discount
$arrInsertFlightData['CommissionEarned'] = $CommissionEarned;
$arrInsertFlightData['ApiResultIndex'] = $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;
// if ($bookingAllowed != 2 && $AirInvenSysId_Old == 0) {
if ($AirInvenSysId_Old == 0) {
try {
$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
$arrSegments['AirInvenAPISysId'] = $AirInvenSysId;
$objFlight->addFlightSegmentsDetails($arrSegments);
} catch (Exception $e) {
echo $e->getMessage();
die('addflightfairrules');
}
} else {
$AirInvenSysId = $AirInvenSysIdArr[] = $AirInvenSysId_Old;
}
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
$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" => $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,
);
$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'];
$strArrivalTime = $flightRounds['LocalToTime'];
$strDepartureTime = $flightRounds['LocalFromTime'];
$intAdultsCT = $adultCount;
$intChildsCT = $childCount;
$intInfantsCT = $infantCount;
$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;
if ($flightRounds['FairRules']['FareBreakdown']) {
foreach ($flightRounds['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_) - $customerDiscount_); //$GrandTotalBaseFare;
$AgentServiceTaxAmount += $intTotalGST_;
}
}
$TotalExtraCharge = ($ExtraMarkup + $ExtraMarkupOnGST);
$intOfferedFare = ($BaseAmount + $BagPriceSeg + $MealPriceSeg + $SeatPriceSeg);
$totalCost = ($intPublishedFare + $TotalExtraCharge);
$AgencyMarkUp += ($intAgencyFixMarkUp + $apiMarkup);
$GTXMarkUp += ($GTXMarkUpGST);
$AgentCommisionEarned += ($intCommissionEarned);
$BaseAmount += ($intOfferedFare);
$PublishedFare += ($intPublishedFare);
$TotalDiscountValue += ($DiscountValue);
$arrPlanAir['SeqId'] = $intRounds;
$arrPlanAir['TPIntSysId'] = $TPIntSysId;
$arrPlanAir['SourceAirportCode'] = $strGoingFlightFrom;
$arrPlanAir['DestAirportCode'] = $strGoingFlightTo;
$arrPlanAir['LocalFromTime'] = $strDepartureTime;
$arrPlanAir['LocalToTime'] = $strArrivalTime;
$arrPlanAir['FromUTCTime'] = $strDepartureTime;
$arrPlanAir['ToUTCTime'] = $strArrivalTime;
$arrPlanAir['SupplierSysId'] = 3;
$arrPlanAir['IsActive'] = 1;
$arrPlanAir['IsMarkForDel'] = 0;
$arrPlanAir['FlightNumber'] = $FlightNumber;
$arrPlanAir['Cost'] = ($intOfferedFare);
$arrPlanAir['TotalCost'] = $totalCost; //($intPublishedFare + $ExtraMarkup + $ExtraMarkupOnGST);
$arrPlanAir['XServiceTaxAmount'] = 0; //$intSTaxOnBasePrice;
$arrPlanAir['GTXServiceTaxAmount'] = $GTXMarkUpGST; //$intSTaxOnGTXMarkUp;
$arrPlanAir['AgentServiceTaxAmount'] = $intTotalGST; //$intTotalGSTAgencyEarnings; ICSourceSysId
$arrPlanAir['AgentsCustomServiceTaxAmount'] = 0;
$arrPlanAir['MarkUp'] = 0;
$arrPlanAir['AgencyMarkUp'] = ($intAgencyFixMarkUp + $apiMarkup);
$arrPlanAir['GTXMarkup'] = $intGTXMarkUp;
$arrPlanAir['GTXCommission'] = 0;
$arrPlanAir['AgencyCommission'] = $intCommissionEarned;
$arrPlanAir['ExtraMarkup'] = $ExtraMarkup;
$arrPlanAir['ExtraMarkupOnGST'] = $ExtraMarkupOnGST;
$arrPlanAir['Discount'] = $DiscountValue;
$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'] = date('Y-m-d H:i:s');
$arrPlanAir['UpdateDate'] = date('Y-m-d H:i:s');
$arrPlanAir['AgencySysId'] = $this->intLoggedinAgencyId;
// if ($bookingAllowed != 2 && $versionSysid == 0) {
if ($versionSysid == 0) {
$intTpAirId = $objFlight->insertTravelPlanIAir($arrPlanAir);
$intRounds++;
$arrIntTpAirId[] = $intTpAirId;
} else {
$objFlight->updatePNR($arrPlanAir, $versionSysid);
$intRounds++;
$arrIntTpAirId[] = $versionSysid;
}
}
}
//print_r($arrIntTpAirId);
// 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'];
$checkPaymentStatus = $this->paymentMdl->checkPaymentStatus($this->intLoggedinAgencyId, $TPSysId);
// print_r($checkPaymentStatus);
// print_r($TPSysId);
// die;
$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' => $currencytype,
'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 ($bookingAllowed == 2) {
$addData_Trx['AgencyMarkUp'] = 0;
$addData_Trx['GTXMarkup'] = 0;
$addData_Trx['Commission'] = 0;
$addData_Trx['TotalDiscount'] = 0;
$addData_Trx['Amount'] = 0;
$addData_Trx['PaidAmount'] = 0;
$addData_Trx['NetAmount'] = 0;
$addData_Trx['TrxStatus'] = false;
}
if ($checkPaymentStatus == 0) {
$TrxSysId = $this->paymentMdl->insertTable("TB_Trx", $addData_Trx);
} else {
$TrxSysId = $TempTrxId;
}
$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' => $currencytype,
'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 ($bookingAllowed == 2) {
$addDataAgency_Customer_Trx['AgencyMarkUp'] = 0;
$addDataAgency_Customer_Trx['GTXMarkup'] = 0;
$addDataAgency_Customer_Trx['Commission'] = 0;
$addDataAgency_Customer_Trx['TotalDiscount'] = 0;
$addDataAgency_Customer_Trx['Amount'] = 0;
$addDataAgency_Customer_Trx['PaidAmount'] = 0;
$addDataAgency_Customer_Trx['NetAmount'] = 0;
$addDataAgency_Customer_Trx['TrxStatus'] = false;
}
if ($checkPaymentStatus == 0) {
$dddd = $this->paymentMdl->insertTable("TB_Agency_Customer_Trx", $addDataAgency_Customer_Trx); /// by sabir
}
//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" => [],
"intCustomerSysId" => $intCustomerSysId,
"intTPSysId" => $TPSysId,
"TrxSysId" => $TrxSysId,
"arrIntTpAirId" => $arrIntTpAirId,
"AirInvenSysIdArr" => $AirInvenSysIdArr,
"ForCustomerSession" => $ForCustomerSession,
"sessionFlightSearchParams" => $sessionFlightSearchParams,
"SelectedBaggSessionNew" => null,
"SelectedMealSessionNew" => null,
"selectedSeatSession" => null,
"sessionLogin_user" => $_SESSION['sessionLogin_user'],
"post" => $post,
"IsTripjack" => true,
);
$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, 'ispackage' => $ispackage);
echo json_encode($response);
exit;
}
}
}
public function previewTicketAction() {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL); arrCustomerInvoiceData
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$fareRules = $param['fareRules'];
$cancellationPolicy = $param['cancellationPolicy'];
$internalRemarks = $param['internalRemarks'];
$paramArray = $this->getRequest()->getParams();
parse_str(urldecode(base64_decode($paramArray["data"])), $param);
$TraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
$param['fareRules'] = $fareRules;
$param['cancellationPolicy'] = $cancellationPolicy;
$param['internalRemarks'] = $internalRemarks;
$objAirport = new Travel_Model_TblAirport();
$objFlight = new Travel_Model_TblFlight();
$ai = 0;
$airlineinventories = [];
$arrFlightData = [];
if (isset($param['airlinename']) && !empty($param['airlinename'])) {
$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;
$currency = $param['currency'];
$flightType = $param['flightType'];
$checkInLuggage = $param['checkInLuggage'];
$cabainluggage = $param['cabainluggage'];
$IsLcc = $param['IsLcc'];
$TPSysId = $param['TPSysId'];
$editLeadId = $param['MasterTPSysId'];
$Refundable = $param['Refundable'];
$fareRules = $param['fareRules'];
$cancellationPolicy = $param['cancellationPolicy'];
$internalRemarks = $param['internalRemarks'];
$intCustomerSysId = trim($param['customerId']);
$pnrnumber = $param['pnrnumber'];
$bookingId = $param['bookingId'];
$mealdetails = $param['mealdetails'];
$baggagedetails = $param['baggagedetails'];
$seatnumber = $param['seatnumber'];
$seatprice = $param['seatprice'];
$baggageprice = $param['baggageprice'];
$mealprice = $param['mealprice'];
$adultCount = (int) $param['paxAdTx'];
$childCount = (int) $param['paxChTx'];
$infantCount = (int) $param['paxInTx'];
$totalPassengers = $adultCount + $childCount + $infantCount;
$arrtravellerList = $objFlight->travellerListForProposal($TPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($TPSysId, null);
$RoomInfoJson = $arrCustomerInvoiceData[0]['RoomInfoJson'];
$APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
$sessionFlightSearchParams = $APIBookingRes[0]['sessionFlightSearchParams'];
if (!$sessionFlightSearchParams || empty($sessionFlightSearchParams)) {
$FlightTempData = $objFlight->GetFlightTempDataByTPSysId($TPSysId);
$arrUrlData = json_decode($FlightTempData['APIBookingData'], true);
$sessionFlightSearchParams = $arrUrlData['sessionFlightSearchParams'];
}
$interNational = $sessionFlightSearchParams['interNationalSearch'];
$route__ = $sessionFlightSearchParams['route'];
$route = (int) $flightType;
if ($route__ == 3 && $interNational == 1) {
$route__ = 1;
}
if ($Refundable == 1) {
$IsRefundableTxt = 'Refundable';
} else {
$IsRefundableTxt = 'Non-Refundable';
}
$PaxFareDetaials = [];
$PaxFareDetaials[0]['PaxType'] = 1;
$PaxFareDetaials[0]['PaxCount'] = $param['paxAdTx'];
$PaxFareDetaials[0]['basefare'] = ($param['costAdTx'] / $route__);
$PaxFareDetaials[0]['markup'] = ($param['markupAdTx'] / $route__);
$PaxFareDetaials[0]['markupgst'] = ($param['hidden_gst_textbased_1'] / $route__);
$PaxFareDetaials[0]['total'] = ($param['totalAdTx'] / $route__);
$PaxFareDetaials[0]['GstType'] = $param['AdtextBased'];
$PaxFareDetaials[0]['DiscountValue'] = $param['discAdTx'] / $route__;
if ($param['paxChTx'] > 0) {
$PaxFareDetaials[1]['PaxType'] = 2;
$PaxFareDetaials[1]['PaxCount'] = $param['paxChTx'];
$PaxFareDetaials[1]['basefare'] = ($param['costChTx'] / $route__);
$PaxFareDetaials[1]['markup'] = ($param['markupChTx'] / $route__);
$PaxFareDetaials[1]['markupgst'] = ($param['hidden_gst_textbased_2'] / $route__);
$PaxFareDetaials[1]['total'] = ($param['totalChTx'] / $route__);
$PaxFareDetaials[1]['GstType'] = $param['ChtextBased'];
$PaxFareDetaials[1]['DiscountValue'] = $param['discChTx'] / $route__;
}
if ($param['paxInTx'] > 0) {
$PaxFareDetaials[2]['PaxType'] = 3;
$PaxFareDetaials[2]['PaxCount'] = $param['paxInTx'];
$PaxFareDetaials[2]['basefare'] = ($param['costInTx'] / $route__);
$PaxFareDetaials[2]['markup'] = ($param['markupInTx'] / $route__);
$PaxFareDetaials[2]['markupgst'] = ($param['hidden_gst_textbased_3'] / $route__);
$PaxFareDetaials[2]['total'] = ($param['totalInTx'] / $route__);
$PaxFareDetaials[2]['GstType'] = $param['IntextBased'];
$PaxFareDetaials[2]['DiscountValue'] = $param['discInTx'] / $route__;
}
// echo "<pre>";
// print_r($PaxFareDetaials);
// echo "</pre>";
$FareBreakdown = [];
$BaseFareTotal = 0;
$MarkupTotal = 0;
$GSTTotal = 0;
$CostToAgentCustomerTotal = 0;
$TotalDiscountValue = 0;
if ($PaxFareDetaials) {
foreach ($PaxFareDetaials as $key => $price) {
$DiscountValue = (float) $price['DiscountValue'];
$PaxCount = (int) $price['PaxCount'];
$PaxType = (int) $price['PaxType'];
$basefares = ((float) $price['basefare'] * $PaxCount);
$markup = ((float) $price['markup'] * $PaxCount);
if ($markup >= $DiscountValue) {
$markup = ($markup - $DiscountValue);
}
$markupgst = ((float) $price['markupgst'] * $PaxCount);
$GstType = (int) $price['GstType'];
if ($PaxCount) {
if ($basefares <= 0) {
$response = array('succes' => false, 'msg' => 'Please enter cost.', 'index' => 'cost_textbased_' . ($key + 1) . '');
echo json_encode($response);
exit;
}
if ($markup < 0) {
$response = array('succes' => false, 'msg' => 'Please enter valid markup.', 'index' => 'cost_textbased_' . ($key + 1) . '');
echo json_encode($response);
exit;
}
}
$calculateServiceTax = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->calculateServiceTax(($markup), $GstType);
$serviceTaxAmount = (isset($calculateServiceTax['serviceTaxAmount']) && $calculateServiceTax['serviceTaxAmount'] > 0) ? $calculateServiceTax['serviceTaxAmount'] : 0;
$BasePriceWithSTax = (isset($calculateServiceTax['BasePriceWithSTax']) && $calculateServiceTax['BasePriceWithSTax'] > 0) ? $calculateServiceTax['BasePriceWithSTax'] : 0;
$CostToAgentCustomer = ($basefares + $BasePriceWithSTax);
$CostToAgentCustomerTotal += $CostToAgentCustomer;
$BaseFareTotal += $basefares;
$MarkupTotal += $markup;
$GSTTotal += $serviceTaxAmount;
// $GSTTotal += $markupgst;
// echo "<pre>";
// print_r($calculateServiceTax);
// echo "</pre>";
$TotalDiscountValue += $DiscountValue;
$FareBreakdown[] = array(
"Currency" => $currency,
"PassengerType" => $PaxType,
"PassengerCount" => $PaxCount,
"TaxIN" => 0,
"TotalBaseFare" => 0,
"BaseFareCal" => $basefares,
"BaseFare" => $basefares,
"CommissionEarned" => 0,
"TDS" => 0,
"MF" => 0,
"YQ" => 0,
"AGST" => 0,
"MFT" => 0,
"OT" => 0,
"MU" => 0,
"YR" => 0,
"intTotalGST" => $serviceTaxAmount,
"apiMarkup" => 0,
"IntCommission" => 0,
"apiTaxOnMarkup" => 0,
"FixedMarkUp" => $markup,
"GSTOnMarkUp" => $serviceTaxAmount,
"DiscountValue" => $DiscountValue,
"CommEarned" => 0,
"GSTonComm" => 0,
"intGTXMarkUp" => 0,
"GTXMarkUpGST" => 0,
"AgentMarkUp" => 0,
"GSTOnAgentMarkUp" => 0,
"Agencycommission" => 0,
"TotalCommssionVal_ag" => 0,
"AdminComminAmount_ag" => 0,
"AgentB2CEarning" => 0,
"CostToAgentCustomer" => $CostToAgentCustomer,
"CostToAgent" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"PGCharge" => 0,
"Baggage" => $checkInLuggage,
"CabinBaggage" => $cabainluggage
);
// echo "<pre>";
// print_r($FareBreakdown);addFlightDetails
}
}
$FairRules = array(
"Currency" => $currency,
"CurrencyRate" => 1,
"currencySysId" => 1,
"BaseFare" => $BaseFareTotal,
"Tax" => "",
"YQTax" => "",
"OtherCharges" => 0,
"Discount" => 0,
"ServiceFee" => 0,
"ManagementFeeTax" => 0,
"AirlineGSTComponent" => 0,
"CarrierMiscFee" => 0,
"MUFee" => 0,
"intPublishedFare" => ($BaseFareTotal + $MarkupTotal + $GSTTotal),
"PublishedFare" => ($BaseFareTotal + $MarkupTotal + $GSTTotal),
"PublishedFareAgent" => ($BaseFareTotal + $MarkupTotal + $GSTTotal),
"OfferedFareAgent" => ($BaseFareTotal + $MarkupTotal + $GSTTotal),
"OfferedFare" => $BaseFareTotal,
"PLBEarned" => 0,
"IncentiveEarned" => 0,
"TdsOnPLB" => 0,
"TdsOnIncentive" => 0,
"AdditionalTxnFeeOfrd" => 0,
"AdditionalTxnFeePub" => 0,
"OnwardAutoTicket" => true,
"Refundable" => $Refundable,
"IsRefundableTxt" => $IsRefundableTxt,
"PriceID" => $TraceId,
"ApiResultIndex" => "NA",
"IsGSTRequired" => 0,
"fareIdentifier" => "Special Deal",
"SeatAvailable" => "0",
"classOfBooking" => 0,
"FareClass" => $param['cabinclass'],
"intTotalGST" => 0,
"apiMarkup" => 0,
"IntCommission" => 0,
"apiTaxOnMarkup" => 0,
"FixedMarkUp" => $MarkupTotal,
"GSTOnMarkUp" => $GSTTotal,
"DiscountValue" => $TotalDiscountValue,
"CommEarned" => 0,
"CommEarnedAgent" => 0,
"GSTonComm" => 0,
"intGTXMarkUp" => 0,
"GTXMarkUpGST" => 0,
"AgentMarkUp" => 0,
"GSTOnAgentMarkUp" => 0,
"Agencycommission" => 0,
"TotalCommssionVal_ag" => 0,
"AdminComminAmount_ag" => 0,
"AgentB2CEarning" => 0,
"CostToAgentCustomer" => ($BaseFareTotal + $MarkupTotal + $GSTTotal),
"CostToAgent" => 0,
"FareBreakdown" => $FareBreakdown,
);
// die;
foreach ($param['airlinename'] as $aKey => $aVal) {
if ($param['flightType']) {
$SegmentsArray = [];
foreach ($aVal as $aaKey => $aaVal) {
if (trim($param['airlinename_id'][$aKey][$aaKey]) != '') {
$DepartureTime = isset($param['departuretime'][$aKey][$aaKey]) ? $param['departuretime'][$aKey][$aaKey] : 0;
$arrivaltime = isset($param['arrivaltime'][$aKey][$aaKey]) ? $param['arrivaltime'][$aKey][$aaKey] : 0;
$EstimateHours = isset($param['EstimateHours'][$aKey][$aaKey]) ? $param['EstimateHours'][$aKey][$aaKey] : 0;
//$EstimateHours = strtotime($arrivaltime) - strtotime($DepartureTime);
$DEPEX = explode(' ', $DepartureTime);
$ARREX = explode(' ', $arrivaltime);
$DEPEXDATE = explode('/', $DEPEX[0]);
$DepartureDate = $DEPEXDATE[2] . "-" . $DEPEXDATE[1] . "-" . $DEPEXDATE[0];
$DEPEXTIME = $DEPEX[1];
$ARREXDATE = explode('/', $ARREX[0]);
$ArrivalDate = $ARREXDATE[2] . "-" . $ARREXDATE[1] . "-" . $ARREXDATE[0];
$ARREXTIME = $ARREX[1];
$LocalFromTime = $DepartureDate . ' ' . $DEPEXTIME;
$FromUTCTime = $DepartureDate . 'T' . $DEPEXTIME;
$LocalToTime = $ArrivalDate . ' ' . $ARREXTIME;
$ToUTCTime = $ArrivalDate . 'T' . $ARREXTIME;
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($LocalFromTime, $LocalToTime);
if ($ai == 0) {
$OnwardFromAirportCode = isset($param['fromAirportCode'][1][$aaKey]) ? $param['fromAirportCode'][1][$aaKey] : '';
$InwardFromAirportCode = isset($param['fromAirportCode'][2][$aaKey]) ? $param['fromAirportCode'][2][$aaKey] : '';
}
$OnwardToAirportCode = isset($param['toAirportCode'][1][$aaKey]) ? $param['toAirportCode'][1][$aaKey] : '';
$InwardToAirportCode = isset($param['toAirportCode'][2][$aaKey]) ? $param['toAirportCode'][2][$aaKey] : '';
$airlineinventories_id = (isset($param['airlineinventories_id'][$aKey][$aaKey]) && trim($param['airlineinventories_id'][$aKey][$aaKey]) != '') ? $param['airlineinventories_id'][$aKey][$aaKey] : '';
if (isset($airlineinventories_id) && $airlineinventories_id != '') {
$airlineinventories1[$ai] = [
'id' => $airlineinventories_id
];
} else {
$airlineinventories1[$ai] = [];
}
$mealdetails = isset($param['mealdetails'][$aKey][$aaKey]) ? $param['mealdetails'][$aKey][$aaKey] : '';
$mealprice = isset($param['mealprice'][$aKey][$aaKey]) ? $param['mealprice'][$aKey][$aaKey] : '';
$baggagedetails = isset($param['baggagedetails'][$aKey][$aaKey]) ? $param['baggagedetails'][$aKey][$aaKey] : '';
$baggageprice = isset($param['baggageprice'][$aKey][$aaKey]) ? $param['baggageprice'][$aKey][$aaKey] : '';
$seatnumber = isset($param['seatnumber'][$aKey][$aaKey]) ? $param['seatnumber'][$aKey][$aaKey] : '';
$seatprice = isset($param['seatprice'][$aKey][$aaKey]) ? $param['seatprice'][$aKey][$aaKey] : '';
$flightnumber = isset($param['flightnumber'][$aKey][$aaKey]) ? $param['flightnumber'][$aKey][$aaKey] : '';
$flightnumberEX = explode('-', $flightnumber);
$from = isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '';
$to = isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '';
$objAirport->strAirportCode = $from;
$arrSourceCityId = $objAirport->getAirportList();
$objAirport->strAirportCode = $to;
$arrdestinationCityId = $objAirport->getAirportList();
$intDestinationCountryCode = '';
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';
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$interNationalSearch = true;
} else if ($intDestinaionCountryCode != "IN" || empty($intDestinaionCountryCode)) {
$interNationalSearch = true;
} else {
$interNationalSearch = false;
}
$filePath = $this->getflightlogo($flightnumberEX[0]);
$StopCount = isset($aVal) ? (count($aVal) - 1) : 0;
$trvDate = explode("/", $param['TravelDate']);
$TravelDate = $trvDate[2] . "-" . $trvDate[1] . "-" . ($trvDate[0]);
$airlineinventories2[$ai] = [
'FlightType' => $aKey,
'AirlineName' => $aaVal,
'pnrnumber' => $param['pnrnumber'],
'bookingId' => $param['bookingId'],
'AirlineCode' => $flightnumberEX[0],
'FlightNumber' => $flightnumber,
'SourceAirportCode' => isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '',
'FromTerminal' => isset($param['fromAirportTerminal'][$aKey][$aaKey]) ? $param['fromAirportTerminal'][$aKey][$aaKey] : '',
'DestAirportCode' => isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '',
'ToTerminal' => isset($param['toAirportTerminal'][$aKey][$aaKey]) ? $param['toAirportTerminal'][$aKey][$aaKey] : '',
'Stops' => isset($aVal) ? (count($aVal) - 1) : 0,
'StopCount' => ($StopCount == 0) ? 'Non-Stop' : $StopCount . ' Stop',
'DepartureTime' => $DEPEXTIME,
'EstimateHours' => $EstimateHours,
'ArrivalTime' => $ARREXTIME,
'TotalFlightMembers' => $param['total_pax_textBased'],
'CurrencyType' => $param['Currency'],
'JourneyType' => 1,
'TripType' => $param['flightType'],
'IsInternational' => $interNationalSearch,
'SourcePlaceSysId' => $intSourceCityId,
'DestPlaceSysId' => $intdestinationCityId,
'TravelDate' => $TravelDate,
'LocalFromTime' => $LocalFromTime,
'FromUTCTime' => $FromUTCTime,
'LocalToTime' => $LocalToTime,
'ToUTCTime' => $ToUTCTime,
'SourcePlaceName' => trim($arrSourceCityId[0]['CityName']),
'DestPlaceName' => trim($arrdestinationCityId[0]['CityName']),
'FareClass' => '',
'LAYOVERCity' => '',
'GroundTime' => 0,
'LAYOVERDuration' => 0,
'FlyingMinutes' => 0,
'FlightDuration' => $strDuration,
'PublishedFare' => $param['grand_total_textBased'],
'logo' => $filePath,
];
$MealArrNew = [];
$SeatArrNew = [];
$BaggageArrNew = [];
if ($mealdetails) {
foreach ($mealdetails as $m => $meals) {
$MealArrNew[$m - 1]['Currency'] = $currency;
$MealArrNew[$m - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$MealArrNew[$m - 1]['Code'] = '';
$MealArrNew[$m - 1]['Price'] = isset($mealprice[$m]) ? $mealprice[$m] : 0;
$MealArrNew[$m - 1]['Description'] = $meals;
$MealArrNew[$m - 1]['sector'] = $from . '-' . $to;
}
}
if ($seatnumber) {
foreach ($seatnumber as $m => $seat) {
$SeatArrNew[$m - 1]['Currency'] = $currency;
$SeatArrNew[$m - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$SeatArrNew[$m - 1]['Code'] = $seat;
$SeatArrNew[$m - 1]['Price'] = isset($seatprice[$m]) ? $seatprice[$m] : 0;
$SeatArrNew[$m - 1]['SeatNo'] = $seat;
$SeatArrNew[$m - 1]['sector'] = $from . '-' . $to;
}
}
if ($baggagedetails) {
foreach ($baggagedetails as $b => $bag) {
$Weight = str_replace('Excess Baggage - ', '', $bag);
$BaggageArrNew[$b - 1]['Currency'] = $currency;
$BaggageArrNew[$b - 1]['key'] = $flightnumberEX[1] . '' . $aaKey;
$BaggageArrNew[$b - 1]['Code'] = '';
$BaggageArrNew[$b - 1]['Price'] = isset($baggageprice[$b]) ? $baggageprice[$b] : 0;
$BaggageArrNew[$b - 1]['Weight'] = $Weight;
$BaggageArrNew[$b - 1]['sector'] = $from . '-' . $to;
}
}
$SegmentsArray[$aaKey] = [
'segmentid' => $flightnumberEX[1] . '' . $aaKey,
'originAirportName' => trim($arrSourceCityId[0]['AirportTitle']),
'destinationAirportName' => trim($arrdestinationCityId[0]['AirportTitle']),
'originCityName' => trim($arrSourceCityId[0]['CityName']),
'originCountryName' => trim($arrSourceCityId[0]['CountryName']),
'destinationCityName' => trim($arrdestinationCityId[0]['CityName']),
'destinationCountryName' => trim($arrdestinationCityId[0]['CountryName']),
'destinationAirportCode' => isset($param['toAirportCode'][$aKey][$aaKey]) ? $param['toAirportCode'][$aKey][$aaKey] : '',
'destinationArrTime' => $ToUTCTime,
'SegFlightNumber' => $flightnumber,
'AirlineCode' => $flightnumberEX[0],
'AirlineName' => $aaVal,
'FareClass' => '',
'originAirportCode' => isset($param['fromAirportCode'][$aKey][$aaKey]) ? $param['fromAirportCode'][$aKey][$aaKey] : '',
'originDepTime' => $FromUTCTime,
'TripIndicator' => '',
'Baggage' => $checkInLuggage,
'CabinBaggage' => $cabainluggage,
'IsBaggage' => true,
'IsMealIncludes' => false,
'Duration' => 130,
'GroundTime' => 0,
'NoOfSeatAvailable' => 9,
'strDepartureDtTime' => $DEPEXTIME,
'strArrivalDtTime' => $ARREXTIME,
'FlightDuration' => $strDuration,
'LAYOVERDuration' => null,
'LAYOVERCity' => '',
'DepTerminal' => isset($param['fromAirportTerminal'][$aKey][$aaKey]) ? $param['fromAirportTerminal'][$aKey][$aaKey] : '',
'ArrTerminal' => isset($param['toAirportTerminal'][$aKey][$aaKey]) ? $param['toAirportTerminal'][$aKey][$aaKey] : '',
'filePath' => $filePath,
"BAGGAGEARRAY" => $BaggageArrNew,
"MEALARRAY" => $MealArrNew,
"SEATARRAY" => $SeatArrNew,
];
$airlineinventories[$ai] = array_merge($airlineinventories1[$ai], $airlineinventories2[$ai]);
$ai++;
}
}
$OriginSegments = current($airlineinventories);
$DestinationSegments = end($airlineinventories);
// echo '<pre>';
// print_r($SegmentsArray);
// echo '<pre>';
// print_r($DestinationSegments['LocalFromTime']);
$LAYOVERDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($OriginSegments['ToUTCTime'], $DestinationSegments['LocalFromTime']);
$Duration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateOnlyMinutes($OriginSegments['ToUTCTime'], $DestinationSegments['LocalFromTime']);
$objAirline = new Travel_Model_TblAirline();
$arrAirlineList = $objAirline->getAirlineIdsAndCodeList();
$AirlineCode = $OriginSegments['AirlineCode'];
$airlineSysId = !empty($arrAirlineList[$AirlineCode]) ? $arrAirlineList[$AirlineCode] : '0';
$Indexes = ($aKey - 1);
$pnrnumberstr = isset($pnrnumber[$Indexes]) ? $pnrnumber[$Indexes] : '';
$bookingIdstr = isset($bookingId[$Indexes]) ? $bookingId[$Indexes] : '';
$arrFlightData[$Indexes]['Currency'] = $currency;
$arrFlightData[$Indexes]['CurrencyRate'] = 1;
$arrFlightData[$Indexes]['currencySysId'] = 1;
$arrFlightData[$Indexes]['bookingId'] = $bookingIdstr;
$arrFlightData[$Indexes]['OnwardGroupPNR'] = $pnrnumberstr;
$arrFlightData[$Indexes]['FlightNumber'] = $OriginSegments['FlightNumber'];
$arrFlightData[$Indexes]['AirlineName'] = $OriginSegments['AirlineName'];
$arrFlightData[$Indexes]['AirlineCode'] = $OriginSegments['AirlineCode'];
$arrFlightData[$Indexes]['AirInvenSysId'] = '';
$arrFlightData[$Indexes]['GroundTime'] = $Duration;
$arrFlightData[$Indexes]['LAYOVERDuration'] = $LAYOVERDuration;
$arrFlightData[$Indexes]['IsLCC'] = $IsLcc;
$arrFlightData[$Indexes]['IsRefundable'] = $Refundable;
$arrFlightData[$Indexes]['OnwardAutoTicket'] = true;
$arrFlightData[$Indexes]['IsRefundableTxt'] = $IsRefundableTxt;
$arrFlightData[$Indexes]['SearchTraceId'] = $TraceId;
$arrFlightData[$Indexes]['apiTraceId'] = $TraceId;
$arrFlightData[$Indexes]['AirlineSysId'] = $airlineSysId;
$arrFlightData[$Indexes]['DepartureTime'] = $OriginSegments['DepartureTime'];
$arrFlightData[$Indexes]['ArrivalTime'] = $OriginSegments['ArrivalTime'];
$arrFlightData[$Indexes]['TravelDate'] = $OriginSegments['TravelDate'];
$arrFlightData[$Indexes]['DepartureDateTxt'] = date('D, d M', strtotime($OriginSegments['LocalFromTime']));
$arrFlightData[$Indexes]['ArrivalDateTxt'] = date('D, d M', strtotime($DestinationSegments['LocalToTime']));
$arrFlightData[$Indexes]['LocalFromTime'] = $OriginSegments['LocalFromTime'];
$arrFlightData[$Indexes]['FromUTCTime'] = $OriginSegments['FromUTCTime'];
$arrFlightData[$Indexes]['LocalToTime'] = $DestinationSegments['LocalToTime'];
$arrFlightData[$Indexes]['ToUTCTime'] = $DestinationSegments['ToUTCTime'];
$arrFlightData[$Indexes]['IsDirect'] = '0';
$arrFlightData[$Indexes]['FareClass'] = '';
$arrFlightData[$Indexes]['FlightDuration'] = $OriginSegments['FlightDuration'];
$arrFlightData[$Indexes]['SourcePlaceSysId'] = $OriginSegments['SourcePlaceSysId'];
$arrFlightData[$Indexes]['DestPlaceSysId'] = $DestinationSegments['DestPlaceSysId'];
$arrFlightData[$Indexes]['SourceAirportCode'] = $OriginSegments['SourceAirportCode'];
$arrFlightData[$Indexes]['DestAirportCode'] = $DestinationSegments['DestAirportCode'];
$arrFlightData[$Indexes]['SourcePlaceName'] = $OriginSegments['SourcePlaceName'];
$arrFlightData[$Indexes]['DestPlaceName'] = $DestinationSegments['DestPlaceName'];
$arrFlightData[$Indexes]['StopCount'] = $OriginSegments['StopCount'];
$arrFlightData[$Indexes]['StopCountShow'] = $OriginSegments['StopCount'];
$arrFlightData[$Indexes]['Stops'] = $OriginSegments['Stops'];
$arrFlightData[$Indexes]['TotalFlightMembers'] = $OriginSegments['TotalFlightMembers'];
$arrFlightData[$Indexes]['CurrencyType'] = 1;
$arrFlightData[$Indexes]['PublishedFare'] = $CostToAgentCustomerTotal;
$arrFlightData[$Indexes]['PublishedFareTxt'] = number_format($CostToAgentCustomerTotal, 2);
$arrFlightData[$Indexes]['ApiResultIndex'] = '';
$arrFlightData[$Indexes]['JourneyType'] = $OriginSegments['JourneyType'];
$arrFlightData[$Indexes]['TripType'] = $OriginSegments['TripType'];
$arrFlightData[$Indexes]['IsInternational'] = $OriginSegments['IsInternational'];
$arrFlightData[$Indexes]['logo'] = $OriginSegments['logo'];
$arrFlightData[$Indexes]['IsSeriesFareData'] = false;
$arrFlightData[$Indexes]['IsTJFlightAPI'] = false;
$arrFlightData[$Indexes]['ICSourceSysId'] = 9;
$arrFlightData[$Indexes]['supplier'] = $param['supplier'];
$arrFlightData[$Indexes]['SupplierSysId'] = $param['supplier_id'];
$arrFlightData[$Indexes]['FareRules'] = $fareRules;
$arrFlightData[$Indexes]['CancellationPolicy'] = $cancellationPolicy;
$arrFlightData[$Indexes]['InternalRemarks'] = $internalRemarks;
$arrFlightData[$Indexes]['isAdobrMandatory'] = false;
$arrFlightData[$Indexes]['isCdobrMandatory'] = true;
$arrFlightData[$Indexes]['isIdobrMandatory'] = true;
$arrFlightData[$Indexes]['IsPassMandatory'] = ($OriginSegments['IsInternational'] == 1) ? true : false;
$arrFlightData[$Indexes]['IsPassExpiry'] = ($OriginSegments['IsInternational'] == 1) ? true : false;
$arrFlightData[$Indexes]['IsPassIssue'] = ($OriginSegments['IsInternational'] == 1) ? true : false;
$arrFlightData[$Indexes]['FairRules'] = ($FairRules);
$arrFlightData[$Indexes]['Segments'] = array_values($SegmentsArray);
}
}
}
// echo "<pre>";
// print_r($arrFlightData);
// echo "</pre>";
$arrFlightDataInset = [];
if ($arrFlightData) {
foreach ($arrFlightData as $key => $val) {
$arrFlightDataInset[$key] = $val;
$SegmentsArray = $val['Segments'];
$newarr = [];
if ($SegmentsArray) {
foreach ($SegmentsArray as $keyyy => $value) {
$start = ($SegmentsArray[$keyyy]['destinationArrTime']);
$LAYOVERCity = ($SegmentsArray[$keyyy]['destinationCityName']);
if (isset($SegmentsArray[$keyyy + 1]['originDepTime'])) {
$end = ($SegmentsArray[$keyyy + 1]['originDepTime']);
} else {
$end = 0;
}
$LayoverDuration = null;
$GroundTime = 0;
if ($end > 0) {
$LayoverDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($start, $end);
$timeFirst = strtotime($start);
$timeSecond = strtotime($end);
$GroundTime = (($timeSecond - $timeFirst) / 60);
}
$SegmentsArray[$keyyy]['LAYOVERDuration'] = $LayoverDuration;
$SegmentsArray[$keyyy]['LAYOVERCity'] = $LAYOVERCity;
$SegmentsArray[$keyyy]['GroundTime'] = $GroundTime;
$newarr[] = ['start' => $start, 'end' => $end, 'LayoverDuration' => $LayoverDuration, 'GroundTime' => $GroundTime];
}
}
// echo "<pre> ";
// print_r(($newarr));
// echo "<pre> ";
// print_r(($SegmentsArray));
$ArrSegments = current(($SegmentsArray));
$DepSegments = end(($SegmentsArray));
$destinationArrTime = $ArrSegments['destinationArrTime'];
$originDepTime = $ArrSegments['originDepTime'];
$strDuration = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes($val['LocalFromTime'], $val['LocalToTime']);
$arrFlightDataInset[$key]['FlightDuration'] = $strDuration;
$arrFlightDataInset[$key]['ArrivalTime'] = $DepSegments['strArrivalDtTime'];
$arrFlightDataInset[$key]['Segments'] = $SegmentsArray;
if ($key == 1) {
$arrFlightDataInset[$key]['FlightNumber'] = $ArrSegments['SegFlightNumber'];
$arrFlightDataInset[$key]['AirlineName'] = $ArrSegments['AirlineName'];
$arrFlightDataInset[$key]['AirlineCode'] = $ArrSegments['AirlineCode'];
$arrFlightDataInset[$key]['DepartureTime'] = $ArrSegments['strDepartureDtTime'];
$arrFlightDataInset[$key]['ArrivalTime'] = $DepSegments['strArrivalDtTime'];
// $arrFlightDataInset[$key]['TravelDate'] = $DestinationSegments['TravelDate'];
$arrFlightDataInset[$key]['DepartureDateTxt'] = date('D, d M', strtotime($ArrSegments['originDepTime']));
$arrFlightDataInset[$key]['ArrivalDateTxt'] = date('D, d M', strtotime($DepSegments['destinationArrTime']));
$arrFlightDataInset[$key]['LocalFromTime'] = str_replace('T', ' ', $ArrSegments['originDepTime']);
$arrFlightDataInset[$key]['FromUTCTime'] = $ArrSegments['originDepTime'];
$arrFlightDataInset[$key]['LocalToTime'] = str_replace('T', ' ', $DepSegments['destinationArrTime']);
$arrFlightDataInset[$key]['ToUTCTime'] = $DepSegments['destinationArrTime'];
$strDuration1 = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->CalculateHoursMinutes(str_replace('T', ' ', $ArrSegments['originDepTime']), str_replace('T', ' ', $DepSegments['destinationArrTime']));
$arrFlightDataInset[$key]['FlightDuration'] = $strDuration1;
$objAirport->strAirportCode = $ArrSegments['originAirportCode'];
$arrSourceCityId = $objAirport->getAirportList();
$objAirport->strAirportCode = $DepSegments['destinationAirportCode'];
$arrdestinationCityId = $objAirport->getAirportList();
$intDestinationCountryCode = '';
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 = "";
}
$arrFlightDataInset[$key]['SourcePlaceSysId'] = $intSourceCityId;
$arrFlightDataInset[$key]['DestPlaceSysId'] = $intdestinationCityId;
$arrFlightDataInset[$key]['SourceAirportCode'] = $ArrSegments['originAirportCode'];
$arrFlightDataInset[$key]['DestAirportCode'] = $DepSegments['destinationAirportCode'];
$arrFlightDataInset[$key]['SourcePlaceName'] = $ArrSegments['originCityName'];
$arrFlightDataInset[$key]['DestPlaceName'] = $DepSegments['destinationCityName'];
}
}
}
// echo "<pre>";
// print_r($arrFlightDataInset);
// echo "</pre>";
// die;
$key = 0;
$post = $param;
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['mobile_number'];
$airline_email = $post['email_id'];
$passengerDob = $post['passenger-dob-' . $i];
$AdultpassengerpassengerDob = isset($post['passenger-dob-' . $i]) ? $post['passenger-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] : '';
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'] : 0;
$passengerAddress = ($post['passenger-address-1']) ? $post['passenger-address-1'] : 0;
$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;
$AgencySysId = $this->intLoggedinAgencyId;
if ($i == 1 && $relation == 0) {
$arrCustomer = $ForCustomerSession[$key] = array(
'AgencySysId' => $AgencySysId,
'CRMCustSysId' => 0,
'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',
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
);
//echo "<pre>";print_r($arrCustomer);echo "</pre>";die;
//echo '<pre>';print_r($arrCustomer);die;
} else {
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++;
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
$html->assign(array('param' => $param, 'Data' => $arrFlightDataInset, 'arrCustomerInvoiceData' => $arrCustomerInvoiceData, 'ForCustomerSession' => $ForCustomerSession, 'CurrencyRate' => $this->CurrencyRate, 'CurrencyTitle' => $this->CurrencyTitle));
$bodyText = $html->render('preview-ticket.phtml');
$response = array('success' => true, 'message' => 'success', 'html' => $bodyText);
echo json_encode($response);
exit;
// echo "<pre>";
// print_r($arrFlightDataInset);
// echo "</pre>";
// echo "<pre>";
// print_r($ForCustomerSession);
// echo "</pre>";
// die;
} else {
die('Bad request');
}
}
public function flightInventoryReviewAction() {
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$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($this->agencyDetails['IsCheckWallet']) ? $this->agencyDetails['IsCheckWallet'] : 0;
$sessionFlightSearchParams = isset($arrUrlData['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;
$this->view->IsB2BCustomer = $IsB2BCustomer;
$this->view->walletBalanceAmount = '0.00'; //$wallet[0]['BalanceAmount'];
if ($IsB2BCustomer == 1) {
$B2bAgencyDetailById = $crmcustomerObj->GetAgencyDetailById($AgencySysId);
$B2BAgencySysIdKey = $getAgencyDetail['SecurityKey'];
$B2CAgencySysIdKey = $B2bAgencyDetailById['SecurityKey'];
$apiDataIV = array(
"B2BAgencySysIdKey" => $B2BAgencySysIdKey,
"B2CAgencySysIdKey" => $B2CAgencySysIdKey,
);
$model = new Gtxwebservices_Model_Webservices();
$result = json_decode($model->GetB2Bbalance($apiDataIV), true);
$this->view->walletBalanceAmount = $result['creditBalance'];
// echo "<pre>";
// print_r($result);
// 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($sessionFlightSearchParams->params);echo "</pre>"; intChargeFromWallet
$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...
// $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/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');
$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;
$this->view->intTotalPublishedFare = $TotalPublishedFare;
$this->view->intTotalAmount = $TotalPublishedFare;
$this->view->intTax = $intTDSOnAgencyMarkUp;
$this->view->intAgentMarkUpAmount = $intAgencyMarkUp;
$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;
$agencyMarkUp = 0;
$gtxMarkup = 0;
$offerFare = 0;
$gtxMarkupGST = 0;
$agencyMarkUpGST = 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 calculateSum($calculatePrice, $ExtraMarkup, $ExtraMarkupOnGST) {
$basefare = isset($calculatePrice['BaseFare']) ? ($calculatePrice['BaseFare'] + $calculatePrice['TaxsandFees']) : 0;
$markup = isset($calculatePrice['FixedMarkUp']) ? $calculatePrice['FixedMarkUp'] + $ExtraMarkup : 0;
$GSTOnMarkUp = isset($calculatePrice['GSTOnMarkUp']) ? $calculatePrice['GSTOnMarkUp'] + $ExtraMarkupOnGST : 0;
$total = isset($calculatePrice['BaseFare']) ? $calculatePrice['BaseFare'] + $ExtraMarkup + $ExtraMarkupOnGST + $calculatePrice['FixedMarkUp'] + $calculatePrice['GSTOnMarkUp'] + $calculatePrice['TaxsandFees'] : 0;
return array('basefare' => $basefare, 'markup' => $markup, 'total' => $total, 'GSTOnMarkUp' => $GSTOnMarkUp);
}
public function calculatePrice($FareBreakdown) {
$TotalBaseFare = 0;
$TotalTaxsandFees = 0;
$TotalFixedMarkUp = 0;
$TotalGSTOnMarkUp = 0;
foreach ($FareBreakdown as $key => $value) {
$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
$YR = $value['YR'];
$PBaseFare = $value['BaseFare'];
$intGTXMarkUp = $value['intGTXMarkUp'];
$GTXMarkUpGST = $value['GTXMarkUpGST'];
$apiMarkup = $value['apiMarkup'];
$FixedMarkUp = $value['FixedMarkUp'];
$GSTOnMarkUp = $value['GSTOnMarkUp'];
$intTotalGST = ($value['intTotalGST'] - $GSTOnMarkUp);
$IntCommission = $value['IntCommission'];
$CommissionEarned = $value['CommissionEarned'];
$customerDiscount = ($CommissionEarned - $IntCommission);
$otherCharge = (($YQ + $AGST + $MFT + $MF + $OT + $YR + $intGTXMarkUp + $GTXMarkUpGST) - ($customerDiscount));
$TaxesFees = ($otherCharge + $intTotalGST + $apiMarkup);
$TotalBaseFare += ($PBaseFare);
$TotalTaxsandFees += ($TaxesFees);
$TotalFixedMarkUp += ($FixedMarkUp);
$TotalGSTOnMarkUp += ($GSTOnMarkUp);
}
return array('BaseFare' => $TotalBaseFare, 'TaxsandFees' => $TotalTaxsandFees, 'FixedMarkUp' => $TotalFixedMarkUp, 'GSTOnMarkUp' => $TotalGSTOnMarkUp);
}
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 updateETickettjAction() {
$this->_helper->layout->disableLayout();
$intTPSysId = base64_decode($this->getRequest()->getParam("id"));
$versionId = ($this->getRequest()->getParam("version"));
$objFlight = new Travel_Model_TblFlight();
$Id = $this->getRequest()->getParam("id");
$code = ($this->getRequest()->getParam("code"));
if (!empty($Id)) {
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($Id), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
}
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId, $versionId);
//$arrTrevllerList = $objFlight->GetCustomerListForFlightBooking(23890);
// echo "<pre>";
// print_r($arrCustomerInvoiceData);
// echo "</pre>";
// die;
$this->view->arrtravellerList = $arrtravellerList;
$this->view->arrCustomerInvoiceData = $arrCustomerInvoiceData;
$this->view->intTPSysId = $this->getRequest()->getParam("id");
$this->view->version = $versionId;
$intCustomerSysId = $arrCustomerInvoiceData[0]['CustomerSysId'];
$ICSourceSysId = $arrCustomerInvoiceData[0]['ICSourceSysId'];
$this->view->ICSourceSysId = $ICSourceSysId;
if (!empty($intCustomerSysId)) {
$arrTrevllerDetails = $objFlight->GetAgencyCustomerDetailsForBooking($intCustomerSysId, $intTPSysId);
//echo "<pre>";print_r($arrTrevllerDetails);
$this->view->arrTrevllerDetails = $arrTrevllerDetails;
}
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign('type', 'mailToCustomer');
// $html->assign('arrtravellerList', $arrtravellerList);
// $html->assign('arrCustomerInvoiceData', $arrCustomerInvoiceData);
// $html->assign('arrTrevllerDetails', $arrTrevllerDetails);
// $html->assign('intTPSysId', $this->getRequest()->getParam("intTPSysId"));
// $html->assign('version', $versionId);
// $html->render('e-ticket-TJ.phtml');
}
public function updateEticketDataAction() {
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$objFlight = new Travel_Model_TblFlight();
$TblMarkup = new Markup_Model_Markup();
$VersionId = (isset($getData['VersionId'])) ? $getData['VersionId'] : '';
$pnrDetail = (isset($getData['pnrDetail'])) ? $getData['pnrDetail'] : '';
$pnrInwordDetail = (isset($getData['pnrInwordDetail'])) ? $getData['pnrInwordDetail'] : '';
$TPPaxSysId = (isset($getData['TPPaxSysId'])) ? $getData['TPPaxSysId'] : '';
$TicketFullJsonArray = (isset($getData['TicketFullJson'])) ? $getData['TicketFullJson'] : array();
$passengerSalutation = (isset($getData['passengerSalutation'])) ? $getData['passengerSalutation'] : '';
$passengerFirstName = (isset($getData['passengerFirstName'])) ? $getData['passengerFirstName'] : '';
$passengerLastName = (isset($getData['passengerLastName'])) ? $getData['passengerLastName'] : '';
$ticketNumberDetails = (isset($getData['ticketNumberDetails'])) ? $getData['ticketNumberDetails'] : '';
$ticketNumberInwardDetails = (isset($getData['ticketNumberInwordDetails'])) ? $getData['ticketNumberInwordDetails'] : '';
$intTPSysId = (isset($getData['intTPSysId'])) ? base64_decode($getData['intTPSysId']) : '';
$arrCustomerInvoiceData = $objFlight->customerInvoiceDataBySabir($intTPSysId);
$ICSourceSysId = isset($arrCustomerInvoiceData[0]['ICSourceSysId']) ? $arrCustomerInvoiceData[0]['ICSourceSysId'] : 0;
// echo "<pre>";
// print_r(($getData));
// die;
if ($ICSourceSysId == 9) {
$arrAPIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], true);
if (isset($arrCustomerInvoiceData[1]['APIBookingRes']) && !empty($arrCustomerInvoiceData[1]['APIBookingRes'])) {
$arrAPIBookingRes1 = json_decode($arrCustomerInvoiceData[1]['APIBookingRes'], true);
}
$IsSeriesFareData = (isset($arrAPIBookingRes['value']['IsSeriesFareData'])) ? $arrAPIBookingRes['value']['IsSeriesFareData'] : 0;
$TripType = $arrCustomerInvoiceData[0]['TripType'];
$IsInternational = $arrCustomerInvoiceData[0]['IsInternational'];
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
if ($IsInternational == 1 && $TripType == 2 && $ICSourceSysId != 9) {
$CustomeSegment = [];
if ($IsSeriesFareData == 1) {
$CustomeSegment = $arrAPIBookingRes['value']['InternationalData']['Segments'];
} else {
foreach ($arrAPIBookingRes['value']['InternationalData']['Segments'] as $seg) {
foreach ($seg as $val) {
$CustomeSegment[] = $val;
}
}
}
} else {
$CustomeSegment = $arrAPIBookingRes['value']['Segments'];
$CustomeSegment1 = $arrAPIBookingRes1['value']['Segments'];
}
if (isset($arrAPIBookingRes1) && !empty($arrAPIBookingRes1)) {
$CustomeSegment = array_merge($CustomeSegment, $CustomeSegment1);
} else {
$CustomeSegment = $CustomeSegment;
}
$travellerInfos = $arrAPIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
$newtravellerInfos = array();
$pnrArray = [];
if (!empty($travellerInfos)) {
foreach ($travellerInfos as $key => $val) {
if ($CustomeSegment) {
foreach ($CustomeSegment as $Segkey => $Segvalue) {
$originAirportCode = $Segvalue['originAirportCode'];
$destinationAirportCode = $Segvalue['destinationAirportCode'];
$pnrArray[$originAirportCode . '-' . $destinationAirportCode][] = $pnrDetail[$key][$Segkey];
$val['ti'] = isset($passengerSalutation[$key]) ? $passengerSalutation[$key] : '';
$val['fN'] = isset($passengerFirstName[$key]) ? $passengerFirstName[$key] : '';
$val['lN'] = isset($passengerLastName[$key]) ? $passengerLastName[$key] : '';
$val['pnrDetails'][$originAirportCode . '-' . $destinationAirportCode] = $pnrDetail[$key][$Segkey];
$val['ticketNumberDetails'][$originAirportCode . '-' . $destinationAirportCode] = $ticketNumberDetails[$key][$Segkey];
}
}
$newtravellerInfos[] = $val;
}
}
if ($arrCustomerInvoiceData) {
foreach ($arrCustomerInvoiceData as $Data) {
$VersionId = $Data['VersionId'];
$APIBookingRes = json_decode($Data['APIBookingRes'], true);
$Segment = $APIBookingRes['value']['Segments'];
$SegPNR = [];
if ($Segment) {
foreach ($Segment as $Segkey => $Segvalue) {
$originAirportCode = $Segvalue['originAirportCode'];
$destinationAirportCode = $Segvalue['destinationAirportCode'];
$SegPNR[] = isset($pnrArray[$originAirportCode . '-' . $destinationAirportCode]) ? implode('-', array_unique($pnrArray[$originAirportCode . '-' . $destinationAirportCode])) : [];
}
}
$APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] = $newtravellerInfos;
$APIBookingRes['response']['order']['status'] = 'SUCCESS';
$data['APIBookingRes'] = json_encode($APIBookingRes);
$data['AirlineRefPNR'] = ($SegPNR) ? implode('-', $SegPNR) : '';
$objFlight->updateBookingDetails($data, $VersionId);
}
}
foreach ($TPPaxSysId as $keypax => $valuepax) {
if ($valuepax != '') {
$updatedatapax = array(
'FirstName' => $passengerFirstName[$keypax],
'LastName' => $passengerLastName[$keypax],
'TicketId' => implode('-', $pnrDetail[$keypax]),
'TicketNumber' => implode('-', $ticketNumberDetails[$keypax]),
'TicketFullJson' => json_encode($newtravellerInfos),
);
$objFlight->updateTravelPlanPax($updatedatapax, $valuepax);
}
}
$result = array('status' => true);
echo json_encode($result);
die;
}
// echo "<pre>";
// print_r($newtravellerInfos);
// die;
if ($VersionId != '') {
$FlightBookingResponse = $objFlight->FlightBookingResponse($VersionId);
$GetFlightProposal = $objFlight->GetFlightProposalByTPSysId($intTPSysId);
$AgentSysId = $GetFlightProposal[0]['AgentSysId'];
$agentName = $GetFlightProposal[0]['agentName'];
$AgentAgencyName = $GetFlightProposal[0]['AgentAgencyName'];
$ProposalEmailTo = $GetFlightProposal[0]['ProposalEmailTo'];
$AgentEmailId = $GetFlightProposal[0]['AgentEmailId'];
$countrycode = $GetFlightProposal[0]['countrycode'];
$ContactNo1 = $GetFlightProposal[0]['ContactNo1'];
$AgencyEmailId = $GetFlightProposal[0]['AgencyEmailId'];
$MasterTPSysId = $GetFlightProposal[0]['MasterTPSysId'];
$ICSourceSysId = $GetFlightProposal[0]['ICSourceSysId'];
$AgencyDisplayName = (isset($GetFlightProposal[0]['DisplayName']) && !empty($GetFlightProposal[0]['DisplayName'])) ? $GetFlightProposal[0]['DisplayName'] : $GetFlightProposal[0]['Title'];
$IsB2bSiteurl = (isset($GetFlightProposal[0]['IsB2bSiteurl']) && !empty($GetFlightProposal[0]['IsB2bSiteurl'])) ? $GetFlightProposal[0]['IsB2bSiteurl'] : '';
$AgencySysId = $this->intLoggedinUserAgencySysId;
$SupportContact = $TblMarkup->getAgencyUserDetail(array('AgencySysId' => $AgencySysId, 'ItemSourceType' => 2, 'PlanType' => 1, 'MarketType' => 2));
$APIBookingRes = isset($FlightBookingResponse[0]['APIBookingRes']) ? json_decode($FlightBookingResponse[0]['APIBookingRes'], 1) : '';
$XRefBookingId = isset($FlightBookingResponse[0]['XRefBookingId']) ? ($FlightBookingResponse[0]['XRefBookingId']) : '';
$SourceAirportCode = trim($APIBookingRes['value']['SourceAirportCode']);
$DestAirportCode = trim($APIBookingRes['value']['DestAirportCode']);
$FromDate = trim($APIBookingRes['value']['FromDate']);
$AirlineName = trim($APIBookingRes['value']['AirlineName']);
$FlightNumber = trim($APIBookingRes['value']['FlightNumber']);
$travellerInfos = $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
if (isset($FlightBookingResponse[0]['TripType']) && trim($FlightBookingResponse[0]['TripType']) == 2) {
$APIBookingRes['value']['InwardAutoTicket'] = 1;
$APIBookingRes['value']['InwardGroupPNR'] = isset($pnrInwordDetail[0]) ? $pnrInwordDetail[0] : '';
// $pnrDetail[1] = isset($pnrInwordDetail[0]) ? $pnrInwordDetail[0] : '';
//$ticketNumberDetails[1] = isset($ticketNumberInwardDetails[0]) ? $ticketNumberInwardDetails[0] : '';
}
$newtravellerInfos = array();
if (!empty($travellerInfos)) {
foreach ($travellerInfos as $key => $val) {
if ($ICSourceSysId != 8) {
$val['pnrDetails'][$SourceAirportCode . '-' . $DestAirportCode] = $pnrDetail[$key];
$val['ticketNumberDetails'][$SourceAirportCode . '-' . $DestAirportCode] = $ticketNumberDetails[$key];
}
$val['ti'] = isset($passengerSalutation[$key]) ? $passengerSalutation[$key] : '';
$val['fN'] = isset($passengerFirstName[$key]) ? $passengerFirstName[$key] : '';
$val['lN'] = isset($passengerLastName[$key]) ? $passengerLastName[$key] : '';
if ((isset($FlightBookingResponse[0]['TripType']) && trim($FlightBookingResponse[0]['TripType']) == 2) || $ICSourceSysId == 8) {
if (isset($FlightBookingResponse[0]['TripType']) && trim($FlightBookingResponse[0]['TripType']) == 2) {
$val['pnrInwardDetails'][$SourceAirportCode . '-' . $DestAirportCode] = $pnrInwordDetail[$key];
$val['ticketNumberInwardDetails'][$SourceAirportCode . '-' . $DestAirportCode] = $ticketNumberInwardDetails[$key];
}
if ($APIBookingRes['value']['Segments']) {
foreach ($APIBookingRes['value']['Segments'] as $Segkey => $Segvalue) {
$originAirportCode = $Segvalue['originAirportCode'];
$destinationAirportCode = $Segvalue['destinationAirportCode'];
$val['pnrDetails'][$originAirportCode . '-' . $destinationAirportCode] = (($ICSourceSysId == 8) ? $pnrDetail[$key] : $pnrDetail[$Segkey]);
$val['ticketNumberDetails'][$originAirportCode . '-' . $destinationAirportCode] = (($ICSourceSysId == 8) ? $ticketNumberDetails[$key] : $ticketNumberDetails[$Segkey]);
}
}
}
$newtravellerInfos[] = $val;
}
}
// echo "<pre>";print_r($newtravellerInfos);die;
$APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] = $newtravellerInfos;
$APIBookingRes['response']['order']['status'] = 'SUCCESS';
$APIBookingRes['value']['OnwardAutoTicket'] = 1;
$APIBookingRes['value']['OnwardGroupPNR'] = isset($pnrDetail[0]) ? $pnrDetail[0] : '';
$APIBookingRes['value']['FairRules']['OnwardAutoTicket'] = 1;
$data = array();
$data['APIBookingRes'] = json_encode($APIBookingRes);
if (isset($FlightBookingResponse[0]['TripType']) && trim($FlightBookingResponse[0]['TripType']) == 2) {
$onwardPnr = isset($pnrDetail[0]) ? trim($pnrDetail[0]) : '';
$inwardPnr = isset($pnrInwordDetail[0]) ? trim($pnrInwordDetail[0]) : '';
$data['AirlineRefPNR'] = $onwardPnr . '-' . $inwardPnr;
} else {
$data['AirlineRefPNR'] = isset($pnrDetail[0]) ? trim($pnrDetail[0]) : '';
}
try {
$updateBookingDetails = $objFlight->updateBookingDetails($data, $VersionId);
$updateTP['StatusType'] = 104;
$updateTP['BookingStatus'] = 142;
$objFlight->updateBookingStatusTravelPlan($updateTP, $intTPSysId, $MasterTPSysId);
foreach ($TPPaxSysId as $keypax => $valuepax) {
if ($valuepax != '') {
$TicketFullJsonNew = isset($TicketFullJsonArray[$keypax]) ? json_decode($TicketFullJsonArray[$keypax], 1) : '';
foreach ($TicketFullJsonNew['pnrDetails'] as $pnKey => $pnValue) {
$TicketFullJsonNew['pnrDetails'][$pnKey] = $pnrDetail[$keypax];
$TicketFullJsonNew['ticketNumberDetails'][$pnKey] = $ticketNumberDetails[$keypax];
}
if (isset($FlightBookingResponse[0]['TripType']) && trim($FlightBookingResponse[0]['TripType']) == 2) {
foreach ($TicketFullJsonNew['pnrInwardDetails'] as $pnKey => $pnValue) {
$TicketFullJsonNew['pnrInwardDetails'][$pnKey] = $pnrInwordDetail[$keypax];
$TicketFullJsonNew['ticketNumberInwardDetails'][$pnKey] = $ticketNumberInwardDetails[$keypax];
}
}
$TicketFullJsonNew['ti'] = isset($passengerSalutation[$keypax]) ? $passengerSalutation[$keypax] : '';
$TicketFullJsonNew['fN'] = isset($passengerFirstName[$keypax]) ? $passengerFirstName[$keypax] : '';
$TicketFullJsonNew['lN'] = isset($passengerLastName[$keypax]) ? $passengerLastName[$keypax] : '';
$updatedatapax = array(
'FirstName' => $passengerFirstName[$keypax],
'LastName' => $passengerLastName[$keypax],
'TicketId' => $pnrDetail[$keypax],
'TicketNumber' => $ticketNumberDetails[$keypax],
'TicketFullJson' => json_encode($TicketFullJsonNew),
);
$objFlight->updateTravelPlanPax($updatedatapax, $valuepax);
}
}
if (isset($GetFlightProposal[0]['IsB2BProposal']) && $GetFlightProposal[0]['IsB2BProposal'] == 1) {
$URL = trim($_SESSION['sessionLogin_user']['agencyDetails']['IsB2bSiteURL']) . '/gtxwebservices/flight/update';
} else {
$URL = trim($_SESSION['sessionLogin_user']['agencyDetails']['Url']) . '/gtxwebservices/index/update';
}
//$URL = 'http://local.superdmc.com//gtxwebservices/flight/update';
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$gtxWebservicesModel = new Gtxwebservices_Model_Webservices();
$this->postFields = "";
$this->postFields .= "&AgencySysId=" . $AgencySysId;
$this->postFields .= "&TPSysId=$intTPSysId";
$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog($this->postFields . "\n");
$agencyData = $gtxWebservicesModel->getAgencyInfo($AgencySysId);
$IsAgencySSL = isset($agencyData['IsSSL']) ? (int) $agencyData['IsSSL'] : 0;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
if ($IsAgencySSL == 1) {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
}
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
$output = curl_exec($ch);
//echo "<pre>";print_r($output);exit;
$writeLogObj->writeLog($output . "\n");
curl_close($ch);
$dataRes = json_decode(stripslashes($output), true);
} catch (Exception $err) {
print_r($err);
die;
}
} catch (Exception $err) {
print_r($err);
die;
}
// if ($updateBookingDetails) {
// $params = array();
// $params['sendersEmailId'] = $AgentEmailId;
// $params['FirstName'] = $agentName;
// $params['LastName'] = '';
// $params['countrycode'] = $countrycode;
// $params['ContactNo1'] = $ContactNo1;
// $params['agentName'] = $agentName;
// $params['agencyDisplayName'] = $AgencyDisplayName;
// $params['AgentAgencyName'] = $AgentAgencyName;
// $params['XRefBookingId'] = $XRefBookingId;
// $params['Sector'] = $SourceAirportCode . ' - ' . $DestAirportCode;
// $params['TravelDate'] = $FromDate;
// $params['AirlineName'] = $AirlineName;
// $params['FlightNumber'] = $FlightNumber;
// $params['newtravellerInfos'] = $newtravellerInfos;
// $params['IsB2bSiteurl'] = $IsB2bSiteurl;
// $params['AgencySysId'] = $AgencySysId;
// $params['TPSysId'] = $intTPSysId;
// $params['AgentSysId'] = $AgentSysId;
// $params['arrEmailStatisticsType'] = 1;
// $params['IsConfirm'] = 1;
// $html = new Zend_View();
// $html->setScriptPath(APPLICATION_PATH . '/views/scripts/booking-flight/');
// $html->assign($params);
// $bodyText = $html->render('e-tickettj.phtml');
// $subject = 'Booking Status – Pending - ' . $SourceAirportCode . ' - ' . $DestAirportCode . ' (Ref: ' . $XRefBookingId . ')';
// // echo $bodyText;
// // die("email-template");
// $sendersEmailId = trim($params['sendersEmailId']);
// $emailData = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['AgentAgencyName'], 'subject' => $subject, 'to' => array(trim($ProposalEmailTo)), 'bodyHtml' => $bodyText, 'bodyText' => '');
// $emailData_sender = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['AgentAgencyName'], 'subject' => $subject, 'to' => array($sendersEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
// try {
// $arrEmailStatistics = array(
// "TPSysId" => $params['TPSysId'],
// "TypeSysId" => 1, // 1 For Email 2 For SMS
// "AgencySysId" => $params['AgencySysId'],
// "AgentSysId" => $params['AgentSysId'],
// "Title" => $bodyText,
// "Source" => $params['arrEmailStatisticsType'], // 1 For Fresh Proposals
// "Status" => 0,
// "RefSysId" => "",
// "RefSysStatus" => "",
// "CreateDate" => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss')
// );
// $emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($sendersEmailId));
// $emailstatus1 = Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($sendersEmailId), array(trim($ProposalEmailTo)));
// } catch (Exception $err) { //print_r($mail);
// return 2; // 'There is some error in sending email. Please try after sometime.';
// print_r($err, true);
// }
$result = array('status' => true);
// } else {
// $result = array('status' => false);
// }
} else {
$result = array('status' => false);
}
echo json_encode($result);
die;
}
}
public function cancelEticketDataAction() {
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$objFlight = new Travel_Model_TblFlight();
$TblMarkup = new Markup_Model_Markup();
$VersionId = (isset($getData['VersionId'])) ? $getData['VersionId'] : '';
$pnrDetail = (isset($getData['pnrDetail'])) ? $getData['pnrDetail'] : '';
$ticketNumberDetails = (isset($getData['ticketNumberDetails'])) ? $getData['ticketNumberDetails'] : '';
// echo "<pre>";print_r($getData);die;
$intTPSysId = (isset($getData['intTPSysId'])) ? base64_decode($getData['intTPSysId']) : '';
if ($VersionId != '') {
$FlightBookingResponse = $objFlight->FlightBookingResponse($VersionId);
$GetFlightProposal = $objFlight->GetFlightProposalByTPSysId($intTPSysId);
$arrtravellerList = $objFlight->GetCustomerListForFlightBooking($intTPSysId);
$AgentSysId = $GetFlightProposal[0]['AgentSysId'];
$agentName = $GetFlightProposal[0]['agentName'];
$AgentEmailId = $GetFlightProposal[0]['AgentEmailId'];
$EmailId = $GetFlightProposal[0]['EmailId'];
$AgencyEmailId = $GetFlightProposal[0]['AgencyEmailId'];
$MasterTPSysId = $GetFlightProposal[0]['MasterTPSysId'];
$AgencyDisplayName = (isset($GetFlightProposal[0]['DisplayName']) && !empty($GetFlightProposal[0]['DisplayName'])) ? $GetFlightProposal[0]['DisplayName'] : $GetFlightProposal[0]['Title'];
$IsB2bSiteurl = (isset($GetFlightProposal[0]['IsB2bSiteurl']) && !empty($GetFlightProposal[0]['IsB2bSiteurl'])) ? $GetFlightProposal[0]['IsB2bSiteurl'] : '';
$AgencySysId = $this->intLoggedinUserAgencySysId;
$SupportContact = $TblMarkup->getAgencyUserDetail(array('AgencySysId' => $AgencySysId, 'ItemSourceType' => 2, 'PlanType' => 1, 'MarketType' => 2));
$APIBookingRes = isset($FlightBookingResponse[0]['APIBookingRes']) ? json_decode($FlightBookingResponse[0]['APIBookingRes'], 1) : '';
$XRefBookingId = isset($FlightBookingResponse[0]['XRefBookingId']) ? ($FlightBookingResponse[0]['XRefBookingId']) : '';
$IsSeriesFareData = (isset($APIBookingRes['value']['IsSeriesFareData'])) ? $APIBookingRes['value']['IsSeriesFareData'] : 0;
$SourceAirportCode = trim($APIBookingRes['value']['SourceAirportCode']);
$DestAirportCode = trim($APIBookingRes['value']['DestAirportCode']);
$FromDate = trim($APIBookingRes['value']['FromDate']);
$AirlineName = trim($APIBookingRes['value']['AirlineName']);
$FlightNumber = trim($APIBookingRes['value']['FlightNumber']);
$travellerInfos = $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
$sectorsSelectors[] = $SourceAirportCode . '-' . $DestAirportCode;
$Adult = $Child = $Infant = 0;
$newtravellerInfos = $PaxDetails = array();
if (!empty($travellerInfos)) {
foreach ($travellerInfos as $key => $val) {
$val['pnrDetails'][$SourceAirportCode . '-' . $DestAirportCode] = (isset($pnrDetail[$key]) && !empty($pnrDetail[$key])) ? $pnrDetail[$key] : '--';
$val['ticketNumberDetails'][$SourceAirportCode . '-' . $DestAirportCode] = (isset($ticketNumberDetails[$key]) && !empty($ticketNumberDetails[$key])) ? $ticketNumberDetails[$key] : '--';
$newtravellerInfos[] = $val;
$PaxDetails[] = trim($val['fN']) . '-' . trim($val['lN']);
if ($val['pt'] == 'ADULT') {
$Adult++;
} else if ($val['pt'] == 'CHILD') {
$Child++;
} else {
$Infant++;
}
}
}
$APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] = $newtravellerInfos;
$APIBookingRes['value']['OnwardAutoTicket'] = 1;
$APIBookingRes['value']['FairRules']['OnwardAutoTicket'] = 1;
$APIBookingRes['value']['IsCancelled'] = 1;
$data = array();
$data['APIBookingRes'] = json_encode($APIBookingRes);
try {
if ($IsSeriesFareData == 1) {
$TblInsurance = new Travel_Model_TblInsurance();
$SecurityKey = $TblInsurance->getSecurityCheck($AgencySysId);
$SecurityKey = $SecurityKey['SecurityKey'];
$BookingId = $APIBookingRes['value']['bookingId'];
$PYTHON_API_URL = PYTHON_API_URL;
$url = $PYTHON_API_URL . "flightinventory/booking-cancel-auto-ticket/?SecurityKey=" . $SecurityKey . "&BookingId=" . $BookingId . "&Adult=" . $Adult . "&Child=" . $Child . "&Infant=" . $Infant;
$objPayment = new Payment_Model_Payment();
$resultset = $objPayment->getgtxapiinfo($url);
$datajson = array('url' => $url);
//$resultset = json_decode('{"count":"1","next":"","previous":"","results":{"Status":"1","refId":"EC539FB975F44AD3936390A868D37633","resultSet":{"AC":{"TotalInventory":"1","TotalInventoryCost":"3000"},"Infant":{"TotalInventory":"0","TotalInventoryCost":"0"}}}}', 1);
// $resultset = array('results' => array('refId' => 1));
if (isset($resultset['results']['refId']) && $resultset['results']['refId'] != '') {
$dataModification = array(
"ChangeRequestId" => $resultset['results']['refId'],
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $APIBookingRes['value']['bookingId'],
"RequestType" => 8,
"Remarks" => 'Cancel By Superadmin',
"RequestData" => json_encode($datajson),
"APIResponseData" => json_encode($resultset),
"servicefee" => 0,
"RefundMode" => 'Cash',
"status" => 19,
"refundedamount" => $GetFlightProposal[0]['TotalCost'],
"amendmentcharges" => 0,
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"CreateDate" => date('Y-m-d H:i:s'),
"UpdateDate" => date('Y-m-d H:i:s')
);
$objFlight->insertFlightModification($dataModification);
$param = array();
if (isset($GetFlightProposal[0]['IsB2BProposal']) && $GetFlightProposal[0]['IsB2BProposal'] == 1) {
$returnData = $this->saveOnlineRequest($param, $GetFlightProposal, $arrtravellerList, $dataModification);
if ($returnData['status'] == false) {
echo json_encode($returnData);
exit;
}
}
} else {
$result = array('status' => $resultset['results']['Status'], 'msg' => $resultset['results']['Message']);
echo json_encode($result);
exit;
}
}
$updateBookingDetails = $objFlight->updateBookingDetails($data, $VersionId);
$updateTP['StatusType'] = 10;
$updateTP['querystatus'] = 143;
$updateTP['PaymentStatus'] = 35;
$updateTP['BookingStatus'] = 38;
$updateTP['ChangeRequestId'] = isset($resultset['results']['refId']) ? $resultset['results']['refId'] : '';
$updateTP['ChangeRequestStatus'] = 1;
$objFlight->updateBookingStatusTravelPlan($updateTP, $intTPSysId, $MasterTPSysId);
foreach ($arrtravellerList as $key => $value) {
$data1 = array(
"ChangeRequestId" => isset($resultset['results']['refId']) ? $resultset['results']['refId'] : '',
"ChangeRequestStatus" => 1,
"ChangeRequestRes" => json_encode($resultset),
);
$objFlight->updateTravelPlanPax($data1, $value['TPPaxSysId']);
}
// $URL = 'http://local.superdmc.com/gtxwebservices/flight/updateamendment';
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$gtxWebservicesModel = new Gtxwebservices_Model_Webservices();
if (isset($GetFlightProposal[0]['IsB2BProposal']) && $GetFlightProposal[0]['IsB2BProposal'] == 1) {
$SearchTraceId = isset($APIBookingRes['value']['SearchTraceId']) ? $APIBookingRes['value']['SearchTraceId'] : '';
$URL = trim($_SESSION['sessionLogin_user']['agencyDetails']['IsB2bSiteURL']) . '/gtxwebservices/flight/updateamendment';
$postFieldArray = array(
'AgencySysId' => $GetFlightProposal[0]['B2BAgencySysId'],
'MasterAgencySysId' => $AgencySysId,
'TPSysId' => $intTPSysId,
'dataModification' => json_encode($dataModification),
'sectorsSelectors' => json_encode($sectorsSelectors),
'strUrlData' => ($SearchTraceId),
'PaxDetails' => json_encode($PaxDetails),
'APIBookingRes' => json_encode($APIBookingRes),
);
} else {
$SearchTraceId = isset($APIBookingRes['value']['apiTraceId']) ? $APIBookingRes['value']['apiTraceId'] : $APIBookingRes['value']['SearchTraceId'];
$URL = trim($_SESSION['sessionLogin_user']['agencyDetails']['IsB2bSiteURL']) . '/gtxwebservices/flight/updateamendment';
$postFieldArray = array(
'AgencySysId' => $AgencySysId,
'MasterAgencySysId' => 0,
'TPSysId' => $intTPSysId,
'dataModification' => json_encode($dataModification),
'sectorsSelectors' => json_encode($sectorsSelectors),
'strUrlData' => ($SearchTraceId),
'PaxDetails' => json_encode($PaxDetails),
'APIBookingRes' => json_encode($APIBookingRes),
);
}
$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog($this->postFields . "\n");
$agencyData = $gtxWebservicesModel->getAgencyInfo($AgencySysId);
$IsAgencySSL = isset($agencyData['IsSSL']) ? (int) $agencyData['IsSSL'] : 0;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
if ($IsAgencySSL == 1) {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
}
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFieldArray);
$output = curl_exec($ch);
// echo "<pre>";
// print_r($output);
// die;
$writeLogObj->writeLog($output . "\n");
curl_close($ch);
$dataRes = json_decode(stripslashes($output), true);
} catch (Exception $err) {
print_r($err);
die;
}
} catch (Exception $err) {
print_r($err);
die;
}
if ($updateBookingDetails) {
$params = array();
$params['sendersEmailId'] = (isset($SupportContact['EmailId']) && !empty($SupportContact['EmailId'])) ? $SupportContact['EmailId'] : $AgencyEmailId;
$params['FirstName'] = (isset($SupportContact['FirstName']) && !empty($SupportContact['FirstName'])) ? $SupportContact['FirstName'] : '';
$params['LastName'] = (isset($SupportContact['LastName']) && !empty($SupportContact['LastName'])) ? $SupportContact['LastName'] : '';
$params['countrycode'] = (isset($SupportContact['countrycode']) && !empty($SupportContact['countrycode'])) ? $SupportContact['countrycode'] : '';
$params['ContactNo1'] = (isset($SupportContact['ContactNo1']) && !empty($SupportContact['ContactNo1'])) ? $SupportContact['ContactNo1'] : '';
$params['agentName'] = $agentName;
$params['agencyDisplayName'] = $AgencyDisplayName;
$params['XRefBookingId'] = $XRefBookingId;
$params['Sector'] = $SourceAirportCode . ' - ' . $DestAirportCode;
$params['TravelDate'] = $FromDate;
$params['AirlineName'] = $AirlineName;
$params['FlightNumber'] = $FlightNumber;
$params['newtravellerInfos'] = $newtravellerInfos;
$params['IsB2bSiteurl'] = $IsB2bSiteurl;
$params['AgencySysId'] = $AgencySysId;
$params['TPSysId'] = $intTPSysId;
$params['AgentSysId'] = $AgentSysId;
$params['arrEmailStatisticsType'] = 1;
$params['IsConfirm'] = 0;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('send_updateticket_to_booking_agent.phtml');
//$subject = 'Your Ticket Has Been Booked';
$subject = 'Booking Failed - ' . trim($SourceAirportCode) . ' - ' . trim($DestAirportCode) . ' (Ref: ' . $XRefBookingId . ')';
// echo $bodyText;
// die("email-template");
$sendersEmailId = trim($params['sendersEmailId']);
$emailData = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array(trim($EmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_sender = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array($sendersEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
$arrEmailStatistics = array(
"TPSysId" => $params['TPSysId'],
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $params['AgencySysId'],
"AgentSysId" => $params['AgentSysId'],
"Title" => $bodyText,
"Source" => $params['arrEmailStatisticsType'], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($sendersEmailId));
$emailstatus1 = Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($sendersEmailId), array(trim($AgentEmailId)));
} catch (Exception $err) { //print_r($mail);
return 2; // 'There is some error in sending email. Please try after sometime.';
print_r($err, true);
}
$result = array('status' => true);
} else {
$result = array('status' => false, 'msg' => 'Unable to update please try after some time.');
}
} else {
$result = array('status' => false, 'msg' => 'Unable to update please try after some time.');
}
echo json_encode($result);
die;
}
}
public function exportBookingFlightAction() {
$objFlight = new Travel_Model_TblFlight();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
// if ($this->getRequest()->isPost()) {
// $getData = $this->getRequest()->getPost();
// $this->view->searchArr = $getData;
// if ($getData['dateFrom'] == '' && $getData['dateTo'] == '' && $getData['TravelFromDate'] == '' && $getData['TravelToDate'] == '' && $getData['ProposalId'] == '' && $getData['Flight'] == '' && $getData['BookingId'] == '' && $getData['dateFrom'] == '' && $getData['Pnr_No'] == '' && $getData['orgDest'] == '' && $getData['CustomerName'] == '' && $getData['CustomerPhone'] == '' && $getData['CustomerEmail'] == '' && $getData['hidden_b2bagency_agentId'] == '' && $getData['source'] == '') {
// $getData['dateFrom'] = date('d-m-Y', strtotime(date('d-m-Y') . ' - 30 days'));
// $getData['dateTo'] = date('d-m-Y');
// //echo "<pre>";print_r($getData);die;
// }
// $objFlight->searchArr = $getData;
// }
// if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
// $strFlightBookingListSQL = $objFlight->getFlightBookingList();
// } else {
// $strFlightBookingListSQL = $objFlight->getFlightBookingList($ReportingToSysId);
// }
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchArr = $getData;
$objFlight->searchArr = $getData;
}
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
if ($from_date != NULL && $to_date != NULL) {
$getData = array();
$getData = array(
'TravelToDate' => $to_date,
'TravelFromDate' => $from_date
);
$objFlight->searchArr = $getData;
}
if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
$strFlightBookingListSQL = $objFlight->getFlightBookingList();
} else {
$strFlightBookingListSQL = $objFlight->getFlightBookingList($ReportingToSysId);
}
$arrFlightBookingList = $objFlight->runQueryAllData($strFlightBookingListSQL);
$arrStatusType = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAllStatusType();
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$arrFieldValue = array();
$TotalProcessingFee = $i = $TotalMyCost = $TotalSalePrice = 0;
foreach ($arrFlightBookingList as $key => $value) {
// echo "<pre>";print_r($value);die;
$ICSourceSysId = $value['ICSourceSysId'];
$intTPSysId = $value['TPSysId'];
$TripType = $value['TripType'];
$strProposalId = $value['PlanBookingId'] . "/" . $value['TPSysId'] . "/V" . $value['VersionId'];
$totalPax = 0;
if (!empty($value['RoomInfoJson'])) {
$RoomInfoJson = json_decode($value['RoomInfoJson'], 1);
$RoomInfoJson_ = array_values($RoomInfoJson);
$Adult = (int) $RoomInfoJson_[0]['Adult'];
$Child = (int) $RoomInfoJson_[0]['Child'];
$Infant = (int) $RoomInfoJson_[0]['Infant'];
$totalPax += ($Adult + $Child + $Infant);
}
// print_r($strProposalId);
$IsInternational = $value['IsInternational'];
$TBQAirInvenSysId = $value['TBQAirInvenSysId'];
$AirLineTitle = $value['AirLineTitle'];
$strFlightNumber = $value['FlightNumber'];
//$intTotalCostToCustomer = $value['TotalCost'];
$intCost = $value['Cost'];
$intGTXMarkup = $value['GTXMarkup'];
$intAgencyCommission = $value['AgencyCommission'];
$intAgencyMarkUp = $value['AgencyMarkUp'];
$intAgentServiceTaxAmount = $value['AgentServiceTaxAmount'];
$processingFee = $value['AddTotalCost'];
$AgencyCustomMarkUp = $value['MarkUp'];
$AgentsCustomServiceTaxAmount = $value['AgentsCustomServiceTaxAmount'];
$mFixedMarkUp = 0;
$APIBookingRes = json_decode($value['APIBookingRes'], true);
if ($ICSourceSysId == 8) {
if (empty($intAgencyMarkUp)) {
$mFixedMarkUp = $APIBookingRes['value']['FairRules']['FareBreakdown'][0]['FixedMarkUp'];
}
}
$CancellationProtectionPrice = !empty($value['TotalTcs']) ? $value['TotalTcs'] : 0;
$intTotalCostToCustomer = $value['TotalCost'] + $CancellationProtectionPrice;
$intMyCost = $intTotalCostToCustomer - ($intAgencyCommission + $intAgencyMarkUp + $intAgentServiceTaxAmount + $mFixedMarkUp);
$IsNewMigration = $value['IsNewMigration'];
// echo "<pre>";
// print_r($intTotalCostToCustomer . '=' . $intAgencyCommission . '=' . $intMyCost . '=' . $intAgentServiceTaxAmount);
// echo "</pre>";
//$intAmountPaid = number_format(round($intCost + $intGTXMarkup + $intAgencyCommission),2);
$strSourcePlaces = $value['SourcePlaces'];
$strDestinationPlaces = $value['DestinationPlaces'];
$SourceAirportCode = $value['SourceAirportCode'];
$DestAirportCode = $value['DestAirportCode'];
$objCity = new Travel_Model_TblCity();
if (!empty($strSourceAirportCode)) {
$strSourceCity = $objCity->getCityNameById($strSourceAirportCode);
}
if (!empty($strDestAirportCode)) {
$strDestinationCity = $objCity->getCityNameById($strDestAirportCode);
}
$strFromUTCTime = (array) $value['FromUTCTime'];
$strToUTCTime = (array) $value['ToUTCTime'];
$returnDate = (array) $value['returnDate'];
// $sourceDepartueTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strFromUTCTime['date']);
// $destinationArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strToUTCTime['date']);
$sourceDepartueTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strFromUTCTime['date']);
$destinationArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strToUTCTime['date']);
$returnDateTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($returnDate['date']);
$strBookingId = $value['XRefBookingId'];
$arrBookingId = explode("/", $strBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
$XRefPNR = $value['XRefPNR'];
$AirlineRefPNR = isset($value['AirlineRefPNR']) ? $value['AirlineRefPNR'] : '';
$arrBookingDate = (array) $value['bookingDate'];
$strBookingDate = date('d-M-y', strtotime($arrBookingDate['date']));
$custFirstName = $value['custFirstName'];
$custLastName = $value['custLastName'];
$custEmailId = $value['custEmailId']; //email added
$custContacts = $value['custContacts']; //contact no added
$agtFirstName = $value['agtFirstName'];
$agtLastName = $value['agtLastName'];
$ownerFirstName = $value['ownerFirstName'];
$ownerLastName = $value['ownerLastName'];
$AgencyName = $value['AgencyName'];
$arrTravelDate = (array) $value['FromUTCTime'];
$strTravelDate = date('d-M-y H:i:s', strtotime($arrTravelDate['date']));
$currencySymbol = $customhelper->GetCurrencyByCurrencyType($value['CurrencyType']);
$uid = $value['CustomerSysId'] . ':' . $value['TPSysId'] . ':' . $value['MasterTPSysId'];
$display = 'unique:yes';
$uid = $this->getEnc($uid);
$display = $this->getEnc($display);
if ($IsInternational && $TripType == 2) {
$objFlight = new Travel_Model_TblFlight();
$arrInterNationalFlightList = $objFlight->getInterNationalFlightByMasterId($TBQAirInvenSysId);
// echo "<pre>";
// print_r($TBQAirInvenSysId);
// print_r($arrInterNationalFlightList);
// echo "</pre>";
if (isset($arrInterNationalFlightList) && count($arrInterNationalFlightList) > 0) {
$FlightNumberOutBound = isset($arrInterNationalFlightList[0]['FlightNumber']) ? $arrInterNationalFlightList[0]['FlightNumber'] : '';
$FlightNumberInBound = isset($arrInterNationalFlightList[1]['FlightNumber']) ? $arrInterNationalFlightList[1]['FlightNumber'] : '';
$arrOriginDepartureTimeOutBound = isset($arrInterNationalFlightList[0]['OriginDepartureTime']) ? (array) $arrInterNationalFlightList[0]['OriginDepartureTime'] : '';
$OriginDepartureTimeOutBound = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($arrOriginDepartureTimeOutBound['date']);
$OriginDepartureTimeInBound = isset($arrInterNationalFlightList[1]['OriginDepartureTime']) ? (array) $arrInterNationalFlightList[1]['OriginDepartureTime'] : '';
$OriginDepartureTimeInBound = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($OriginDepartureTimeInBound['date']);
}
}
//echo '<pre>';print_r($value['TPSysId']);die;
// echo '<pre>';
// print_r($APIBookingRes);
// die;
$TraceId = isset($APIBookingRes['Response']['TraceId']) ? $APIBookingRes['Response']['TraceId'] : '';
$PNR = isset($APIBookingRes['Response']['Response']['PNR']) ? $APIBookingRes['Response']['Response']['PNR'] : '';
$BookingId = isset($APIBookingRes['Response']['Response']['BookingId']) ? $APIBookingRes['Response']['Response']['BookingId'] : '';
$IsLCC = isset($APIBookingRes['Response']['Response']['FlightItinerary']['IsLCC']) ? $APIBookingRes['Response']['Response']['FlightItinerary']['IsLCC'] : '';
$JourneyType = isset($APIBookingRes['Response']['Response']['FlightItinerary']['JourneyType']) ? $APIBookingRes['Response']['Response']['FlightItinerary']['JourneyType'] : '';
if ($value['TPSysId'] == $value['TPSysId']) {
//$TicketFor++;
}
// if ($IsInternational == 1 && $JourneyType == 2) {
// $returnDateTime = $returnDateTime;
// } else {
// $returnDateTime = '';
// }
$statusMap = [];
$TicketId = [];
$TicketNumber = [];
if ($ICSourceSysId == 3) {
$Passengers = isset($APIBookingRes['response']['Response']['Response']['PNR']) ? $APIBookingRes['response']['Response']['Response']['PNR'] : '';
} else {
$Passengers = isset($APIBookingRes['response']['itemInfos']['AIR']['travellerInfos']) ? $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] : '';
}
if ($Passengers) {
foreach ($Passengers as $pax) {
//$statusMap = implode('-', $pax['statusMap']);
$TicketId = implode('-', $pax['pnrDetails']);
}
}
$pnr = ($TicketId) ? explode('-', $TicketId) : array();
if (count($pnr) > 2) {
$PNR_Number = $pnr[0] . '-' . $pnr[1];
} else {
$PNR_Number = $pnr[0];
}
$OnwardAutoTicket = isset($APIBookingRes['value']['OnwardAutoTicket']) ? $APIBookingRes['value']['OnwardAutoTicket'] : 1;
if ($OnwardAutoTicket == 0) {
$PNR_Number = '';
}
if ($ICSourceSysId == 7 || $ICSourceSysId == 8 || $ICSourceSysId == 9) {
if (isset($arrBookingId[1]) && !empty($arrBookingId[1])) {
$strXRefBookingId = $strXRefBookingId . ' / ' . $arrBookingId[1] . '';
} else {
$strXRefBookingId = $strXRefBookingId . ' / ' . $PNR_Number . '';
}
} else {
if ($ICSourceSysId == 3) {
$strXRefBookingId = $strXRefBookingId . ' / ' . $Passengers . '';
} elseif ($ICSourceSysId == 10) {
$strXRefBookingId = $strBookingId . ' / ' . $AirlineRefPNR . '';
} else {
$strXRefBookingId = $strXRefBookingId;
}
}
$strTravelDate1 = '';
if ($IsInternational && $TripType == 2) {
$OriginDepartureTimeOutBoundstrDate = (trim($OriginDepartureTimeOutBound['strDate']) != '') ? DateTime::createFromFormat('d M y', @$OriginDepartureTimeOutBound['strDate']) : '';
$OriginDepartureTimeInBoundstrDate = (trim($OriginDepartureTimeInBound['strDate']) != '') ? DateTime::createFromFormat('d M y', @$OriginDepartureTimeInBound['strDate']) : '';
if (!empty($OriginDepartureTimeOutBoundstrDate)) {
$strTravelDate1 = $OriginDepartureTimeOutBoundstrDate->format('d-M-y') . " " . $OriginDepartureTimeOutBound['strTime'] . "/ " . $OriginDepartureTimeInBoundstrDate->format('d-M-y') . " " . $OriginDepartureTimeInBound['strTime'];
}
} else {
// $sourceDepartueTimestrDate = (trim($sourceDepartueTime['strDate']) != '') ? DateTime::createFromFormat('d M y', @$sourceDepartueTime['strDate']) : '';
// echo $sourceDepartueTimestrDate->format('d-M-y') . " " . $sourceDepartueTime['strTime'];
$strTravelDate1 = $strTravelDate;
}
$strFlightNumber1 = '';
if ($IsInternational && $TripType == 2) {
$strFlightNumber1 = trim(@$FlightNumberOutBound) . "/ " . (@$FlightNumberInBound);
} else {
$strFlightNumber1 = trim($strFlightNumber);
}
$SourceAirportCode1 = '';
if ($IsInternational && $TripType == 2) {
$SourceAirportCode1 = trim($SourceAirportCode) . " ⇄ " . trim($DestAirportCode);
} elseif ($TripType == 2) {
$SourceAirportCode1 = trim($SourceAirportCode) . " ⇄ " . trim($DestAirportCode);
} else {
$SourceAirportCode1 = trim($SourceAirportCode) . " → " . trim($DestAirportCode);
}
$CustomerDetails = (($value['IsB2BProposal'] == 1) ? trim($value['B2BAgencyName']) . ' / ' : '') . (!empty($custFirstName) ? trim($custFirstName) . ' ' : '') . (!empty($custLastName) ? trim($custLastName) : '') . ' / ' . (!empty($custEmailId) ? trim($custEmailId) . ' / ' : '') . (!empty($custContacts) ? trim($custContacts) : '');
$Bookingtype = '';
if ($ICSourceSysId == 3) {
$Bookingtype = 'TBO';
} elseif ($ICSourceSysId == 7) {
$Bookingtype = 'TJ';
} elseif ($ICSourceSysId == 9) {
//$Bookingtype = 'Offline';
$Bookingtype = trim($value['SupplierName']);
} elseif ($ICSourceSysId == 8) {
//$Bookingtype = 'SF';
$Bookingtype = trim($value['SupplierName']);
} elseif ($ICSourceSysId == 10) {
$Bookingtype = 'RIYA';
} elseif ($ICSourceSysId == 11) {
$Bookingtype = 'ETRAV';
} elseif ($ICSourceSysId == 12) {
$Bookingtype = 'VIA';
} elseif ($ICSourceSysId == 13) {
$Bookingtype = 'JUSTCLICK';
} elseif ($ICSourceSysId == 14) {
$Bookingtype = 'FLYSHOP';
} elseif ($ICSourceSysId == 15) {
$Bookingtype = 'AKASA';
} elseif ($ICSourceSysId == 17) {
$Bookingtype = 'NEXTRA';
} elseif ($ICSourceSysId == 21) {
$Bookingtype = 'Go Fly Smart';
} elseif ($ICSourceSysId == 22) {
$Bookingtype = 'Air Iq';
} elseif ($ICSourceSysId == 23) {
$Bookingtype = 'CF Departure';
} elseif ($ICSourceSysId == 24) {
$Bookingtype = 'Book N Travel';
} elseif ($ICSourceSysId == 25) {
$Bookingtype = 'Travel Boutique';
}
if ($IsNewMigration == 2) {
$strXRefBookingId = (!empty($strBookingId) ? $strBookingId : 'NA') . '' . (!empty($AirlineRefPNR) ? ' / ' . $AirlineRefPNR : 'NA');
}
$LeadSource = !empty($value['LeadSource']) ? $value['LeadSource'] : 'NA';
$arrFieldValue[$i]['Name1'] = $strBookingDate;
$arrFieldValue[$i]['strProposalId'] = $strProposalId;
$arrFieldValue[$i]['Name2'] = $strTravelDate1;
$arrFieldValue[$i]['Name3'] = trim($strFlightNumber1) . '/ ' . trim($AirLineTitle);
$arrFieldValue[$i]['Name4'] = !empty($strXRefBookingId) ? $strXRefBookingId : 'NA';
$arrFieldValue[$i]['Name5'] = $LeadSource . ' / ' . $Bookingtype;
$arrFieldValue[$i]['Name6'] = $SourceAirportCode1;
$arrFieldValue[$i]['Name7'] = trim($currencySymbol['Symbol']) . ' ' . number_format($intMyCost, 2);
$arrFieldValue[$i]['Name8'] = trim($currencySymbol['Symbol']) . ' ' . number_format(($intTotalCostToCustomer - $intMyCost), 2);
$arrFieldValue[$i]['Name9'] = trim($currencySymbol['Symbol']) . ' ' . number_format($intTotalCostToCustomer, 2);
if ($AgencySysId == 112339) {
$arrFieldValue[$i]['ProceesingFee'] = number_format($processingFee, 2);
}
$arrFieldValue[$i]['Name10'] = $Bookingtype;
$arrFieldValue[$i]['Name11'] = ($OnwardAutoTicket == 1) ? $customhelper->GetTravelPlanStatusName(2, $value['StatusType']) : 'Pending Confirmation';
$arrFieldValue[$i]['Name12'] = $CustomerDetails;
$arrFieldValue[$i]['Name13'] = $totalPax;
$arrFieldValue[$i]['Name14'] = !empty($AgencyName) ? trim($AgencyName) : '';
$arrFieldValue[$i]['Name15'] = (!empty($agtFirstName) ? trim($agtFirstName) : '') . ' ' . (!empty($agtLastName) ? trim($agtLastName) : '');
$arrFieldValue[$i]['Name16'] = (!empty($ownerFirstName) ? trim($ownerFirstName) : '') . ' ' . (!empty($ownerLastName) ? trim($ownerLastName) : '');
$TotalProcessingFee += (float) $processingFee;
$TotalMyCost += (float) $intMyCost;
$TotalSalePrice += (float) $intTotalCostToCustomer;
$i++;
}
$arrFieldValue[$i]['Name1'] = '';
$arrFieldValue[$i]['strProposalId'] = '';
$arrFieldValue[$i]['Name2'] = '';
$arrFieldValue[$i]['Name3'] = '';
$arrFieldValue[$i]['Name4'] = '';
$arrFieldValue[$i]['Name5'] = '';
$arrFieldValue[$i]['Name6'] = '';
$arrFieldValue[$i]['Name7'] = number_format($TotalMyCost, 2);
$arrFieldValue[$i]['Name8'] = number_format(($TotalSalePrice - $TotalMyCost), 2);
$arrFieldValue[$i]['Name9'] = number_format($TotalSalePrice, 2);
if ($AgencySysId == 112339) {
$arrFieldValue[$i]['ProceesingFee'] = number_format($TotalProcessingFee, 2);
}
$arrFieldValue[$i]['Name10'] = '';
$arrFieldValue[$i]['Name11'] = '';
$arrFieldValue[$i]['Name12'] = '';
$arrFieldValue[$i]['Name13'] = '';
$arrFieldValue[$i]['Name14'] = '';
$arrFieldValue[$i]['Name15'] = '';
$arrFieldValue[$i]['Name16'] = '';
if ($AgencySysId == 112339) {
$arrFieldLabel = array(
'Booking Date ',
'Proposal ID',
'Travel Date Time',
'Flight',
'Booking Id / PNR No.',
'Source',
'From / To Dest.',
'My Cost',
'Markups',
'Sale Price',
'Processing Fee',
'Type',
'Status',
'Customer Details',
'Total Pax',
'Agency Name',
'Booked By',
'Owner'
);
} else {
$arrFieldLabel = array(
'Booking Date ',
'Proposal ID',
'Travel Date Time',
'Flight',
'Booking Id / PNR No.',
'Source',
'From / To Dest.',
'My Cost',
'Markups',
'Sale Price',
'Type',
'Status',
'Customer Details',
'Total Pax',
'Agency Name',
'Booked By',
'Owner'
);
}
$sheetTitle = 'Flight Booking';
//echo "<pre>";print_r($arrFieldValue);die;
Zend_Controller_Action_HelperBroker::getStaticHelper("CreateExcel")->exportToExcel($sheetTitle, $arrFieldLabel, $arrFieldValue);
exit;
}
public function exportBookingFlightQueueAction() {
$objFlight = new Travel_Model_TblFlight();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
//echo "<pre>";print_r($sessionLogin_user->IsSuperAdmin);exit;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchArr = $getData;
$objFlight->searchArr = $getData;
}
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
if ($from_date != NULL && $to_date != NULL) {
$getData = array();
$getData = array(
'TravelToDate' => $to_date,
'TravelFromDate' => $from_date
);
$objFlight->searchArr = $getData;
}
if ($sessionLogin_user->UserRoleTitle == 'Owner' || (isset($sessionLogin_user->IsSuperAdmin) && $sessionLogin_user->IsSuperAdmin == 1)) {
$strFlightBookingListSQL = $objFlight->getFlightBookingListQueue();
} else {
$strFlightBookingListSQL = $objFlight->getFlightBookingListQueue($ReportingToSysId);
}
$arrFlightBookingList = $objFlight->runQueryAllData($strFlightBookingListSQL);
$arrStatusType = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getAllStatusType();
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$arrFieldValue = array();
$i = 0;
foreach ($arrFlightBookingList as $key => $value) {
$ICSourceSysId = $value['ICSourceSysId'];
$intTPSysId = $value['TPSysId'];
$TripType = $value['TripType'];
$strProposalId = $value['PlanBookingId'] . "/" . $value['TPSysId'] . "/V" . $value['VersionId'];
// print_r($strProposalId);
$IsInternational = $value['IsInternational'];
$TBQAirInvenSysId = $value['TBQAirInvenSysId'];
$AirLineTitle = $value['AirLineTitle'];
$strFlightNumber = $value['FlightNumber'];
//$intTotalCostToCustomer = $value['TotalCost'];
$intCost = $value['Cost'];
$intGTXMarkup = $value['GTXMarkup'];
$intAgencyCommission = $value['AgencyCommission'];
$intAgencyMarkUp = $value['AgencyMarkUp'];
$intAgentServiceTaxAmount = $value['AgentServiceTaxAmount'];
$AgencyCustomMarkUp = $value['MarkUp'];
$AgentsCustomServiceTaxAmount = $value['AgentsCustomServiceTaxAmount'];
$mFixedMarkUp = 0;
$APIBookingRes = json_decode($value['APIBookingRes'], true);
if ($ICSourceSysId == 8) {
$mFixedMarkUp = $APIBookingRes['value']['FairRules']['FareBreakdown'][0]['FixedMarkUp'];
}
$intTotalCostToCustomer = $value['TotalCost'];
$intMyCost = $intTotalCostToCustomer - ($intAgencyCommission + $intAgencyMarkUp + $intAgentServiceTaxAmount + $mFixedMarkUp);
// echo "<pre>";
// print_r($intTotalCostToCustomer . '=' . $intAgencyCommission . '=' . $intMyCost . '=' . $intAgentServiceTaxAmount);
// echo "</pre>";
//$intAmountPaid = number_format(round($intCost + $intGTXMarkup + $intAgencyCommission),2);
$strSourcePlaces = $value['SourcePlaces'];
$strDestinationPlaces = $value['DestinationPlaces'];
$SourceAirportCode = $value['SourceAirportCode'];
$DestAirportCode = $value['DestAirportCode'];
$objCity = new Travel_Model_TblCity();
if (!empty($strSourceAirportCode)) {
$strSourceCity = $objCity->getCityNameById($strSourceAirportCode);
}
if (!empty($strDestAirportCode)) {
$strDestinationCity = $objCity->getCityNameById($strDestAirportCode);
}
$strFromUTCTime = (array) $value['FromUTCTime'];
$strToUTCTime = (array) $value['ToUTCTime'];
$returnDate = (array) $value['returnDate'];
// $sourceDepartueTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strFromUTCTime['date']);
// $destinationArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strToUTCTime['date']);
$sourceDepartueTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strFromUTCTime['date']);
$destinationArrivalTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($strToUTCTime['date']);
$returnDateTime = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($returnDate['date']);
$strBookingId = $value['XRefBookingId'];
$arrBookingId = explode("/", $strBookingId);
$strXRefBookingId = trim($arrBookingId[0]);
$XRefPNR = $value['XRefPNR'];
$arrBookingDate = (array) $value['bookingDate'];
$strBookingDate = date('d-M-y', strtotime($arrBookingDate['date']));
$custFirstName = $value['custFirstName'];
$custLastName = $value['custLastName'];
$custEmailId = $value['custEmailId']; //email added
$custContacts = $value['custContacts']; //contact no added
$agtFirstName = $value['agtFirstName'];
$agtLastName = $value['agtLastName'];
$ownerFirstName = $value['ownerFirstName'];
$ownerLastName = $value['ownerLastName'];
$AgencyName = $value['AgencyName'];
$arrTravelDate = (array) $value['FromUTCTime'];
$strTravelDate = date('d-M-y H:i:s', strtotime($arrTravelDate['date']));
$currencySymbol = $customhelper->GetCurrencyByCurrencyType($value['CurrencyType']);
$uid = $value['CustomerSysId'] . ':' . $value['TPSysId'] . ':' . $value['MasterTPSysId'];
$display = 'unique:yes';
$uid = $this->getEnc($uid);
$display = $this->getEnc($display);
if ($IsInternational && $TripType == 2) {
$objFlight = new Travel_Model_TblFlight();
$arrInterNationalFlightList = $objFlight->getInterNationalFlightByMasterId($TBQAirInvenSysId);
// echo "<pre>";
// print_r($TBQAirInvenSysId);
// print_r($arrInterNationalFlightList);
// echo "</pre>";
if (isset($arrInterNationalFlightList) && count($arrInterNationalFlightList) > 0) {
$FlightNumberOutBound = isset($arrInterNationalFlightList[0]['FlightNumber']) ? $arrInterNationalFlightList[0]['FlightNumber'] : '';
$FlightNumberInBound = isset($arrInterNationalFlightList[1]['FlightNumber']) ? $arrInterNationalFlightList[1]['FlightNumber'] : '';
$arrOriginDepartureTimeOutBound = isset($arrInterNationalFlightList[0]['OriginDepartureTime']) ? (array) $arrInterNationalFlightList[0]['OriginDepartureTime'] : '';
$OriginDepartureTimeOutBound = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($arrOriginDepartureTimeOutBound['date']);
$OriginDepartureTimeInBound = isset($arrInterNationalFlightList[1]['OriginDepartureTime']) ? (array) $arrInterNationalFlightList[1]['OriginDepartureTime'] : '';
$OriginDepartureTimeInBound = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getDateFormatFromDbDates($OriginDepartureTimeInBound['date']);
}
}
//echo '<pre>';print_r($value['TPSysId']);die;
// echo '<pre>';
// print_r($APIBookingRes);
// die;
$TraceId = isset($APIBookingRes['Response']['TraceId']) ? $APIBookingRes['Response']['TraceId'] : '';
$PNR = isset($APIBookingRes['Response']['Response']['PNR']) ? $APIBookingRes['Response']['Response']['PNR'] : '';
$BookingId = isset($APIBookingRes['Response']['Response']['BookingId']) ? $APIBookingRes['Response']['Response']['BookingId'] : '';
$IsLCC = isset($APIBookingRes['Response']['Response']['FlightItinerary']['IsLCC']) ? $APIBookingRes['Response']['Response']['FlightItinerary']['IsLCC'] : '';
$JourneyType = isset($APIBookingRes['Response']['Response']['FlightItinerary']['JourneyType']) ? $APIBookingRes['Response']['Response']['FlightItinerary']['JourneyType'] : '';
if ($value['TPSysId'] == $value['TPSysId']) {
//$TicketFor++;
}
// if ($IsInternational == 1 && $JourneyType == 2) {
// $returnDateTime = $returnDateTime;
// } else {
// $returnDateTime = '';
// }
$statusMap = [];
$TicketId = [];
$TicketNumber = [];
if ($ICSourceSysId == 3) {
$Passengers = isset($APIBookingRes['response']['Response']['Response']['PNR']) ? $APIBookingRes['response']['Response']['Response']['PNR'] : '';
} else {
$Passengers = isset($APIBookingRes['response']['itemInfos']['AIR']['travellerInfos']) ? $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] : '';
}
if ($Passengers) {
foreach ($Passengers as $pax) {
//$statusMap = implode('-', $pax['statusMap']);
$TicketId = implode('-', $pax['pnrDetails']);
}
}
$pnr = explode('-', $TicketId);
if (count($pnr) > 2) {
$PNR_Number = $pnr[0] . '-' . $pnr[1];
} else {
$PNR_Number = $pnr[0];
}
$OnwardAutoTicket = isset($APIBookingRes['value']['OnwardAutoTicket']) ? $APIBookingRes['value']['OnwardAutoTicket'] : 1;
if ($OnwardAutoTicket == 0) {
$PNR_Number = '';
}
if ($ICSourceSysId == 7 || $ICSourceSysId == 8) {
if (isset($arrBookingId[1]) && !empty($arrBookingId[1])) {
$strXRefBookingId = $strXRefBookingId . ' / ' . $arrBookingId[1] . '';
} else {
$strXRefBookingId = $strXRefBookingId . ' / ' . $PNR_Number . '';
}
} else {
if ($ICSourceSysId == 3) {
$strXRefBookingId = $strXRefBookingId . ' / ' . $Passengers . '';
} else {
$strXRefBookingId = $strXRefBookingId;
}
}
$strTravelDate1 = '';
if ($IsInternational && $TripType == 2) {
$OriginDepartureTimeOutBoundstrDate = (trim($OriginDepartureTimeOutBound['strDate']) != '') ? DateTime::createFromFormat('d M y', @$OriginDepartureTimeOutBound['strDate']) : '';
$OriginDepartureTimeInBoundstrDate = (trim($OriginDepartureTimeInBound['strDate']) != '') ? DateTime::createFromFormat('d M y', @$OriginDepartureTimeInBound['strDate']) : '';
if (!empty($OriginDepartureTimeOutBoundstrDate)) {
$strTravelDate1 = $OriginDepartureTimeOutBoundstrDate->format('d-M-y') . " " . $OriginDepartureTimeOutBound['strTime'] . "/ " . $OriginDepartureTimeInBoundstrDate->format('d-M-y') . " " . $OriginDepartureTimeInBound['strTime'];
}
} else {
// $sourceDepartueTimestrDate = (trim($sourceDepartueTime['strDate']) != '') ? DateTime::createFromFormat('d M y', @$sourceDepartueTime['strDate']) : '';
// echo $sourceDepartueTimestrDate->format('d-M-y') . " " . $sourceDepartueTime['strTime'];
$strTravelDate1 = $strTravelDate;
}
$strFlightNumber1 = '';
if ($IsInternational && $TripType == 2) {
$strFlightNumber1 = trim(@$FlightNumberOutBound) . "/ " . (@$FlightNumberInBound);
} else {
$strFlightNumber1 = trim($strFlightNumber);
}
$SourceAirportCode1 = '';
if ($IsInternational && $TripType == 2) {
$SourceAirportCode1 = trim($SourceAirportCode) . " ⇄ " . trim($DestAirportCode);
} elseif ($TripType == 2) {
$SourceAirportCode1 = trim($SourceAirportCode) . " ⇄ " . trim($DestAirportCode);
} else {
$SourceAirportCode1 = trim($SourceAirportCode) . " → " . trim($DestAirportCode);
}
$CustomerDetails = (($value['IsB2BProposal'] == 1) ? trim($value['B2BAgencyName']) . ' / ' : '') . (!empty($custFirstName) ? trim($custFirstName) . ' ' : '') . (!empty($custLastName) ? trim($custLastName) : '') . ' / ' . (!empty($custEmailId) ? trim($custEmailId) . ' / ' : '') . (!empty($custContacts) ? trim($custContacts) : '');
$Bookingtype = '';
if ($ICSourceSysId == 3) {
$Bookingtype = 'TBO';
} elseif ($ICSourceSysId == 7) {
$Bookingtype = 'TJ';
} elseif ($ICSourceSysId == 9) {
// $Bookingtype = 'Offline';
$Bookingtype = trim($value['SupplierName']);
} elseif ($ICSourceSysId == 8) {
// $Bookingtype = 'SF';
$Bookingtype = trim($value['SupplierName']);
} elseif ($ICSourceSysId == 10) {
$Bookingtype = 'RIYA';
} elseif ($ICSourceSysId == 11) {
$Bookingtype = 'ETRAV';
}
$arrFieldValue[$i]['Name1'] = $strBookingDate;
$arrFieldValue[$i]['strProposalId'] = $strProposalId;
$arrFieldValue[$i]['Name2'] = $strTravelDate1;
$arrFieldValue[$i]['Name3'] = trim($strFlightNumber1) . '/ ' . trim($AirLineTitle);
$arrFieldValue[$i]['Name4'] = !empty($strXRefBookingId) ? $strXRefBookingId : 'NA';
$arrFieldValue[$i]['Name5'] = !empty($value['LeadSource']) ? $value['LeadSource'] : 'NA';
$arrFieldValue[$i]['Name6'] = $SourceAirportCode1;
$arrFieldValue[$i]['Name7'] = trim($currencySymbol['Symbol']) . ' ' . number_format($intMyCost, 2);
$arrFieldValue[$i]['Name8'] = trim($currencySymbol['Symbol']) . ' ' . number_format(($intTotalCostToCustomer - $intMyCost), 2);
$arrFieldValue[$i]['Name9'] = trim($currencySymbol['Symbol']) . ' ' . number_format($intTotalCostToCustomer, 2);
$arrFieldValue[$i]['Name10'] = $Bookingtype;
$arrFieldValue[$i]['Name11'] = ($OnwardAutoTicket == 1) ? $customhelper->GetTravelPlanStatusName(2, $value['StatusType']) : 'Pending Confirmation';
;
$arrFieldValue[$i]['Name12'] = $CustomerDetails;
$arrFieldValue[$i]['Name13'] = !empty($AgencyName) ? trim($AgencyName) : '';
$arrFieldValue[$i]['Name14'] = (!empty($agtFirstName) ? trim($agtFirstName) : '') . ' ' . (!empty($agtLastName) ? trim($agtLastName) : '');
$arrFieldValue[$i]['Name15'] = (!empty($ownerFirstName) ? trim($ownerFirstName) : '') . ' ' . (!empty($ownerLastName) ? trim($ownerLastName) : '');
$i++;
}
$arrFieldLabel = array(
'Booking Date ',
'Proposal ID',
'Travel Date Time',
'Flight',
'Booking Id / PNR No.',
'Source',
'From / To Dest.',
'My Cost',
'Markups',
'Sale Price',
'Type',
'Status',
'Customer Details',
'Agency Name',
'Booked By',
'Owner'
);
$sheetTitle = 'Flight Booking';
//echo "<pre>";print_r($sheetTitle);die;
Zend_Controller_Action_HelperBroker::getStaticHelper("CreateExcel")->exportToExcel($sheetTitle, $arrFieldLabel, $arrFieldValue);
exit;
}
public function GetSubmitAmendmentSeriesFare($param, $arrCustomerInvoiceData, $arrtravellerList) {
$APIBookingRes = json_decode($arrCustomerInvoiceData[0]['APIBookingRes'], 1);
$AmendmentRequestData = new Zend_Session_Namespace('AmendmentRequestData');
$data = $AmendmentRequestData->params;
$ChangeResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->GetSubmitAmendmentSeriesFare($data, $this->intLoggedinUserAgencySysId);
$objFlight = new Travel_Model_TblFlight();
$intChangeRequestStatus = $ChangeResponse['status']['success'];
$strErrorMessage = $ChangeResponse['errors'][0]['message'];
$bookingId_TJ = $APIBookingRes['value']['bookingId'];
$intTPSysId = base64_decode($param['id']);
$requestType = $param['requestType'];
$requestTypeValue = $param['requestTypeValue'];
$cRemarks = $param['cRemarks'];
$MasterTPSysId = $arrCustomerInvoiceData[0]['MasterTPSysId'];
$VersionId = $arrCustomerInvoiceData[0]['VersionId'];
$PaxDetails = $data['PaxDetails'];
$TPPaxSysId = $data['TPPaxSysId'];
$isCancelType = $data['isCancelType'];
$sectorsSelectors = $param['sectorsSelectors'];
$intChangeRequestStatus = 1;
$newtravellerInfos = array();
$travellerInfos = $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
if (isset($arrCustomerInvoiceData[0]['IsB2BProposal']) && $arrCustomerInvoiceData[0]['IsB2BProposal'] == 1) {
$SearchTraceId = isset($APIBookingRes['value']['SearchTraceId']);
} else {
$SearchTraceId = trim($APIBookingRes['value']['apiTraceId']);
}
if (!empty($travellerInfos)) {
foreach ($travellerInfos as $key => $val) {
$newtravellerInfos[$key] = $val;
$Paxname = trim($val['fN']) . '-' . trim($val['lN']);
if (in_array($Paxname, $PaxDetails)) {
$newtravellerInfos[$key]['cancel'] = 1;
}
}
}
// echo "<pre>";
// print_r($requestTypeValue);
// die;
if ($intChangeRequestStatus == 1) {
try {
if (isset($arrtravellerList) && !empty($arrtravellerList)) {
$dataModification = array(
"ChangeRequestId" => $ChangeResponse['amendmentId'],
"ChangeRequestStatus" => 1,
"TPSysId" => $intTPSysId,
"BookingId" => $bookingId_TJ,
"RequestType" => $requestTypeValue,
"Remarks" => $cRemarks,
"RequestData" => json_encode($data),
"APIResponseData" => json_encode($ChangeResponse),
"servicefee" => 0,
"RefundMode" => 'Cash',
"status" => (isset($isCancelType) && $isCancelType == 2) ? '71' : '19',
"refundedamount" => $ChangeResponse['RefundAmount'],
"amendmentcharges" => $ChangeResponse['amendmentCharges'],
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"CreateDate" => date('Y-m-d H:i:s'),
"UpdateDate" => date('Y-m-d H:i:s')
);
$objFlight->insertFlightModification($dataModification);
if (isset($arrCustomerInvoiceData[0]['IsB2BProposal']) && $arrCustomerInvoiceData[0]['IsB2BProposal'] == 1) {
$response = $this->saveOnlineRequest($param, $arrCustomerInvoiceData, $arrtravellerList, $dataModification);
if ($response['status'] == false) {
echo json_encode($response);
exit;
}
} else {
$response = ['status' => true];
}
$APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'] = $newtravellerInfos;
$ubddata = array();
$ubddata['APIBookingRes'] = json_encode($APIBookingRes);
$updateBookingDetails = $objFlight->updateBookingDetails($ubddata, $VersionId);
$updateTP['StatusType'] = (isset($isCancelType) && $isCancelType == 2) ? '71' : '19';
$updateTP['ChangeRequestId'] = $ChangeResponse['amendmentId'];
$updateTP['ChangeRequestStatus'] = (int) $requestType;
$objFlight->updateBookingStatusTravelPlan($updateTP, $intTPSysId, $MasterTPSysId);
if (isset($TPPaxSysId) && !empty($TPPaxSysId)) {
$TPPaxSysIds = implode(',', $TPPaxSysId);
$data1 = array(
"ChangeRequestId" => $ChangeResponse['amendmentId'],
"ChangeRequestStatus" => 1,
"ChangeRequestRes" => json_encode($ChangeResponse)
);
$objFlight->updateTravelPlanPaxByTPPaxSysId($data1, $TPPaxSysIds);
}
$URL = trim($_SESSION['sessionLogin_user']['agencyDetails']['IsB2bSiteURL']) . '/gtxwebservices/flight/updateamendment';
// $URL = 'http://local.superdmc.com/gtxwebservices/flight/updateamendment';
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$gtxWebservicesModel = new Gtxwebservices_Model_Webservices();
$postFieldArray = array(
'AgencySysId' => $arrCustomerInvoiceData[0]['B2BAgencySysId'],
'MasterAgencySysId' => $AgencySysId,
'TPSysId' => $intTPSysId,
'dataModification' => json_encode($dataModification),
'sectorsSelectors' => json_encode($sectorsSelectors),
//'strUrlData' => trim($APIBookingRes['value']['SearchTraceId']), Old was
'strUrlData' => trim($SearchTraceId),
'PaxDetails' => json_encode($PaxDetails),
'APIBookingRes' => json_encode($APIBookingRes),
'isCancelType' => $isCancelType,
);
$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog($postFieldArray . "\n");
$agencyData = $gtxWebservicesModel->getAgencyInfo($AgencySysId);
$IsAgencySSL = isset($agencyData['IsSSL']) ? (int) $agencyData['IsSSL'] : 0;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
if ($IsAgencySSL == 1) {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
}
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFieldArray);
$output = curl_exec($ch);
$writeLogObj->writeLog($output . "\n");
curl_close($ch);
$data = json_decode(stripslashes($output), true);
} catch (Exception $err) {
print_r($err);
die;
}
$status = $response['status'];
$TransactionId = $response['TransactionId'];
$TblMarkup = new Markup_Model_Markup();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$SupportContact = $TblMarkup->getAgencyUserDetail(array('AgencySysId' => $AgencySysId, 'ItemSourceType' => 2, 'PlanType' => 1, 'MarketType' => 2));
if ($updateBookingDetails) {
$AgencyDisplayName = (isset($arrCustomerInvoiceData[0]['DisplayName']) && !empty($arrCustomerInvoiceData[0]['DisplayName'])) ? $arrCustomerInvoiceData[0]['DisplayName'] : $arrCustomerInvoiceData[0]['CompanyName'];
$SourceAirportCode = trim($APIBookingRes['value']['SourceAirportCode']);
$DestAirportCode = trim($APIBookingRes['value']['DestAirportCode']);
$FromDate = trim($APIBookingRes['value']['FromDate']);
$AirlineName = trim($APIBookingRes['value']['AirlineName']);
$FlightNumber = trim($APIBookingRes['value']['FlightNumber']);
$travellerInfos = $APIBookingRes['response']['itemInfos']['AIR']['travellerInfos'];
$sectorsSelectors[] = $SourceAirportCode . '-' . $DestAirportCode;
$EmailId = $arrCustomerInvoiceData[0]['EmailId'];
$params = array();
$params['sendersEmailId'] = (isset($SupportContact['EmailId']) && !empty($SupportContact['EmailId'])) ? $SupportContact['EmailId'] : $AgencyEmailId;
$params['FirstName'] = (isset($SupportContact['FirstName']) && !empty($SupportContact['FirstName'])) ? $SupportContact['FirstName'] : '';
$params['LastName'] = (isset($SupportContact['LastName']) && !empty($SupportContact['LastName'])) ? $SupportContact['LastName'] : '';
$params['countrycode'] = (isset($SupportContact['countrycode']) && !empty($SupportContact['countrycode'])) ? $SupportContact['countrycode'] : '';
$params['ContactNo1'] = (isset($SupportContact['ContactNo1']) && !empty($SupportContact['ContactNo1'])) ? $SupportContact['ContactNo1'] : '';
$params['agentName'] = $arrCustomerInvoiceData[0]['agentName'];
$params['agencyDisplayName'] = $AgencyDisplayName;
$params['XRefBookingId'] = $bookingId_TJ;
$params['Sector'] = $SourceAirportCode . ' - ' . $DestAirportCode;
$params['TravelDate'] = $FromDate;
$params['AirlineName'] = $AirlineName;
$params['FlightNumber'] = $FlightNumber;
$params['newtravellerInfos'] = $travellerInfos;
$params['IsB2bSiteurl'] = $IsB2bSiteurl;
$params['AgencySysId'] = $AgencySysId;
$params['TPSysId'] = $intTPSysId;
$params['AgentSysId'] = $arrCustomerInvoiceData[0]['AgentSysId'];
$params['arrEmailStatisticsType'] = 1;
$params['IsConfirm'] = 0;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('send_updateticket_to_booking_agent.phtml');
//$subject = 'Your Ticket Has Been Booked';
$subject = 'Booking Failed - ' . trim($SourceAirportCode) . ' - ' . trim($DestAirportCode) . ' (Ref: ' . $bookingId_TJ . ')';
// echo $bodyText;
// die("email-template");
$sendersEmailId = trim($params['sendersEmailId']);
$emailData = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array(trim($EmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_sender = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array($sendersEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
$arrEmailStatistics = array(
"TPSysId" => $params['TPSysId'],
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $params['AgencySysId'],
"AgentSysId" => $params['AgentSysId'],
"Title" => $bodyText,
"Source" => $params['arrEmailStatisticsType'], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($sendersEmailId));
$emailstatus1 = Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($sendersEmailId), array(trim($AgentEmailId)));
} catch (Exception $err) { //print_r($mail);
return 2; // 'There is some error in sending email. Please try after sometime.';
print_r($err, true);
}
$result = array('status' => true);
} else {
$result = array('status' => false, 'msg' => 'Unable to update please try after some time.');
}
if ($status == true) {
$response = array('success' => true, 'refundid' => $TransactionId, 'msg' => 'Refund submit successfully', 'redirect' => true);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to submit refund. please try again.');
echo json_encode($response);
exit;
}
echo Zend_Json::Encode($response);
exit;
}
} catch (Exception $e) {
print_r($e->getMessage());
exit;
}
} else {
$strMsg = "Oops! Your booking Can'nt be cancel right now please try again latter, Please contact administrator for more details";
$redirect = false;
$response = array('success' => true, 'msg' => $strMsg, 'redirect' => $redirect);
echo json_encode($response);
exit;
}
}
public function saveOnlineRequest($param, $arrCustomerInvoiceData, $arrtravellerList, $dataModification) {
$objPackage = new Travel_Model_TblPackage();
$objAgency = new Travel_Model_TblAgency();
$UserSysId = $arrCustomerInvoiceData[0]['UserSysId'];
$B2BAgencySysId = $arrCustomerInvoiceData[0]['B2BAgencySysId'];
$CreditLimitData = $objAgency->getCreditBalanceForAgency($B2BAgencySysId);
if (!empty($CreditLimitData)) {
$CreditSysId = isset($CreditLimitData['CreditSysId']) ? $CreditLimitData['CreditSysId'] : '';
$AgencySysId = $B2BAgencySysId;
$Amount = isset($dataModification['refundedamount']) ? $dataModification['refundedamount'] : '';
$CurrencyType = isset($arrCustomerInvoiceData[0]['CurrencyType']) ? $arrCustomerInvoiceData[0]['CurrencyType'] : '1';
$PlanType = 7;
$Remark = 'Refund';
$CreditDate = $currentDate = date("Y-m-d H:i:s");
$PaymentMode = 'Wallet Refund';
$RefrenceNo = isset($dataModification['BookingId']) ? $dataModification['BookingId'] : '';
$checkCreditBalance = $objAgency->checkCreditBalance($AgencySysId, $CreditSysId);
if (!empty($checkCreditBalance)) {
$updateData = [
'CreditDate' => $CreditDate,
'UpdateDate' => $CreditDate,
'BalanceAmount' => new Zend_Db_Expr("BalanceAmount + $Amount")
];
$whereQuery1 = array('CreditSysId = ? ' => $CreditSysId, 'AgencySysId = ? ' => $AgencySysId);
try {
$objPackage->updateData('TB_Agency_Credit', $updateData, $whereQuery1);
$getBalanceArray = $objAgency->checkCreditBalance($AgencySysId, $CreditSysId);
$getBalance = isset($getBalanceArray[0]['BalanceAmount']) ? $getBalanceArray[0]['BalanceAmount'] : 0;
$CreditAmount = isset($getBalanceArray[0]['CreditAmount']) ? $getBalanceArray[0]['CreditAmount'] : 0;
$GUID = $this->GUID();
$saveHistoryData = [
'TrxId' => $GUID,
'AgencySysId' => $AgencySysId,
'CreditSysId' => $CreditSysId,
'IsCredit' => 2,
'PlanType' => $PlanType,
'CurrencyType' => $CurrencyType,
'PaymentMode' => $PaymentMode,
'RefrenceNo' => $RefrenceNo,
'BalanceAmount' => $getBalance,
'CreditAmount' => $CreditAmount,
'Amount' => $Amount,
'CreditDays' => 0,
'CreditDate' => $CreditDate,
'UserSysId' => $UserSysId,
'Remark' => $Remark,
'OTPCode' => 0,
'TrxType' => 1, // plus
'CodeValidFrom' => $currentDate,
'CodeValidTo' => $currentDate,
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
'IsMarkForDel' => 0,
'IsActive' => 1,
];
try {
$objPackage->insertData("TB_Agency_Credit_History", $saveHistoryData);
http_response_code(200);
$returnArray = array("status" => true, "TransactionId" => $GUID, "message" => "");
} catch (Zend_Exception $e) {
http_response_code(500);
$returnErrorMessage = $e->getMessage();
$returnArray = array('status' => false, 'message' => $returnErrorMessage, 'CreditSysId' => '');
}
} catch (Zend_Exception $e) {
http_response_code(500);
$returnErrorMessage = $e->getMessage();
$returnArray = array('status' => false, 'message' => $returnErrorMessage, 'CreditSysId' => '');
}
} else {
http_response_code(500);
$returnArray = array("status" => false, "TransactionId" => "", "message" => "Please contact");
}
} else {
http_response_code(500);
$returnArray = array("status" => false, "TransactionId" => "", "message" => "Please contact");
}
return $returnArray;
}
}