| 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/b2b.hellogtx.com/public/js/hotelinv/ng/ |
Upload File : |
app.filter('sumOfValue', function () {
return function (data, key) {
if (angular.isUndefined(data) || angular.isUndefined(key))
return 0;
var sum = 0;
angular.forEach(data, function (value) {
sum = sum + parseInt(value[key], 10);
});
return sum;
}
});
app.controller("FlightListingController", ['$scope', '$http', '$location', '$filter', '$window', function ($scope, $http, $location, $filter, $window) {
// var url = SITEURL+"public/data/dynamic/finalresultflight.json";
var url = SITEURL + "flight/getflightsearch";
// alert(url);
$scope.loadingFlight = true;
$scope.loadingFareRules = true;
$scope.FilterloadingFlight = true;
$scope.totalFlightsOutbound = 0;
$scope.totalFlightsInbound = 0;
$scope.totalFlights = 0;
$scope.limit = 0;
$scope.limitRound = 0;
$scope.roundtrip = [];
$scope.roundtrip2 = [];
$scope.orderByFlight = '';
$scope.orderByFlight2 = '';
$scope.filter = {};
$scope.reverse = false;
$scope.reverseR = false;
$scope.PublishedFare = 'PublishedFare';
$scope.PublishedFareRound = 'PublishedFare';
$scope.categories = ['AirlineName'];
$scope.AirlineName = [];
$scope.FiltStopCount = [];
$scope.ArrPriceUnique = [];
$scope.class_status = false;
var absUrl = $location.absUrl();
var sURLVariables = absUrl.split('?');
$http({
method: "POST",
url: url,
data: sURLVariables[1],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
// console.log(response.data.outbound);
$scope.loadingFlight = false;
$scope.FilterloadingFlight = false;
$scope.flightlistOutboundfull = response.data.outbound;
$scope.flightlistOutbound = $scope.resultsetFullOut = response.data.outbound;
$scope.flightlistInbound = $scope.resultsetFullInb = response.data.inbound;
$scope.totalFlightsOutbound = response.data.outbound.length;
$scope.totalFlightsInbound = response.data.inbound.length;
var AName = [];
angular.forEach(response.data.arrAirlineName, function (value, key) {
var airl = value.split('-');
this.push(airl);
}, AName);
// console.log(AName);
$scope.AirlineName = AName;
$scope.FiltStopCount = response.data.FiltStopCount;
$scope.ArrPriceUnique = response.data.ArrPriceUnique;
$scope.MinriceRange = response.data.MinriceRange;
$scope.MaxriceRange = response.data.MaxriceRange;
$('#priceRage').val($scope.MinriceRange + '-' + $scope.MaxriceRange);
$("#slider").slider({
range: true,
min: $scope.MinriceRange,
max: $scope.MaxriceRange,
values: [$scope.MinriceRange, $scope.MaxriceRange],
slide: function (event, ui) {
// Get values
var min = ui.values[0];
var max = ui.values[1];
$('.maxvalue_text_left').val(min);
$('.maxvalue_text_right').val(max);
$('#priceRage').val(min + '-' + max);
}
});
}, function errorCallback(response) {
}).finally(function () {
$scope.loadingFlight = false;
$scope.FilterloadingFlight = false;
$scope.hotelType = 'Standard';
$scope.orderby = 'Price';
$scope.orderval = false;
$scope.limit = 10; // total result
$scope.limitRound = 10; // total result
$scope.totalFlightsOutbound = $scope.flightlistOutbound.length; // total result
$scope.totalFlightsInbound = $scope.flightlistInbound.length; // total result
// $scope.AirlineName = $scope.searchInResponseForFilter( $scope.flightlistOutbound , $scope.AirlineName , 'AirlineName' );
//console.log($scope.AirlineName);
});
$scope.getItems = function (obj, array) {
return (array || []).map(function (w) {
return w[obj];
}).filter(function (w, idx, arr) {
if (typeof w === 'undefined') {
return false;
}
return arr.indexOf(w) === idx;
});
};
$scope.loadMoreNew = function () {
if ($scope.loadingFlight === false) {
if ($scope.limit + 10 < $scope.flightlistOutbound.length) {
$scope.limit += 10;
} else {
$scope.limit = $scope.flightlistOutbound.length;
}
}
};
$scope.loadMoreRound = function () {
if ($scope.loadingFlight === false) {
if ($scope.limitRound + 10 < $scope.flightlistInbound.length) {
$scope.limitRound += 10;
} else {
$scope.limitRound = $scope.flightlistInbound.length;
}
}
};
$scope.sortBy = function (PublishedFare) {
$scope.reverse = ($scope.PublishedFare === PublishedFare) ? !$scope.reverse : false;
$scope.PublishedFare = PublishedFare;
$('.onewayflight').click();
};
$scope.sortByRound = function (PublishedFareRound) {
$scope.reverseR = ($scope.PublishedFareRound === PublishedFareRound) ? !$scope.reverseR : false;
$scope.PublishedFareRound = PublishedFareRound;
$('.twowayflight').click();
};
$scope.filterData = function () {
// declare the variable here
var filterSTR = { 'price': [], 'FiltStopCount': [], 'AirlineName': [], 'Times': [], 'Arrivetimes': [], 'baggage': [], 'meals': [],'refundable': [] };
angular.element('.filter-box input:checkbox').each(function () {
if ($(this).is(":checked")) {
if ($(this).hasClass('filter-airline')) {
filterSTR.AirlineName.push($(this).val());
}
else if ($(this).hasClass('filter-stop')) {
filterSTR.FiltStopCount.push($(this).val());
}
else if ($(this).hasClass('filter-price')) {
filterSTR.price.push($(this).val());
}
else if ($(this).hasClass('filter-times')) {
filterSTR.Times.push($(this).val());
}
else if ($(this).hasClass('filter-arrivetimes')) {
filterSTR.Arrivetimes.push($(this).val());
}
else if ($(this).hasClass('filter-baggage')) {
filterSTR.baggage.push($(this).val());
}
else if ($(this).hasClass('filter-meals')) {
filterSTR.meals.push($(this).val());
}
else if ($(this).hasClass('filter-refundable')) {
filterSTR.refundable.push($(this).val());
}
}
});
// if filter has any value
if ((filterSTR.AirlineName.length > 0) || (filterSTR.FiltStopCount.length > 0) || (filterSTR.price.length > 0) || (filterSTR.Times.length > 0) || (filterSTR.Arrivetimes.length > 0) || (filterSTR.baggage.length > 0) || (filterSTR.meals.length > 0) || (filterSTR.refundable.length > 0)) {
$scope.flightlistOutbound = this.filterFromArray($scope.resultsetFullOut, filterSTR);
$scope.flightlistInbound = this.filterFromArray($scope.resultsetFullInb, filterSTR);
// console.log($scope.flightlistOutbound);
}
else {
$scope.flightlistOutbound = $scope.resultsetFullOut;
$scope.flightlistInbound = $scope.resultsetFullInb;
}
};
$scope.filterFromArray = function (data, filterSTR) {
var resultsetFiltered = [];
resultsetFiltered = $scope.applyPriceRangeFilter(data, filterSTR.price);
resultsetFiltered = $scope.applyStopCountFilter(resultsetFiltered, filterSTR.FiltStopCount);
resultsetFiltered = $scope.applyTimesFilter(resultsetFiltered, filterSTR.Times);
resultsetFiltered = $scope.applyArriveTimesFilter(resultsetFiltered, filterSTR.Arrivetimes);
resultsetFiltered = $scope.applyAirlineFilter(resultsetFiltered, filterSTR.AirlineName);
resultsetFiltered = $scope.applyBaggageFilter(resultsetFiltered, filterSTR.baggage);
resultsetFiltered = $scope.applyMealsFilter(resultsetFiltered, filterSTR.meals);
resultsetFiltered = $scope.applyRefundableFilter(resultsetFiltered, filterSTR.refundable);
return resultsetFiltered;
};
$scope.applyAirlineFilter = function (data, nightArr) {
// number of nights
// console.log(data);
var resultsetFiltered = [];
if (nightArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (nightArr.length > 0) {
$.each(nightArr, function (indexinn, elementinn) {
if (elementinn == element.AirlineName) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyMealsFilter = function (data, nightArr) {
// console.log(nightArr);
var resultsetFiltered = [];
if (nightArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (nightArr.length > 0) {
$.each(nightArr, function (indexinn, elementinn) {
if (elementinn == 1) {
var eltrue = false;
} else {
var eltrue = true;
}
if (eltrue == element.IsLCC) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyStopCountFilter = function (data, StopArr) {
// number of nights
// console.log(data);
var resultsetFiltered = [];
if (StopArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (StopArr.length > 0) {
$.each(StopArr, function (indexinn, elementinn) {
if (elementinn == element.StopCount) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyTimesFilter = function (data, timesArr) {
var resultsetFiltered = [];
if (timesArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (timesArr.length > 0) {
$.each(timesArr, function (indexinn, elementinn) {
var elementinnSP = elementinn.split('-');
if (element.DepartureTime >= elementinnSP[0] && element.DepartureTime <= elementinnSP[1]) {
//if(elementinn == element.FilterPrice) {
//if( $scope.checkAlreadyExistsInArray( element.PkgSysId , resultsetFiltered , 'PkgSysId' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyArriveTimesFilter = function (data, timesArr) {
var resultsetFiltered = [];
if (timesArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (timesArr.length > 0) {
$.each(timesArr, function (indexinn, elementinn) {
var elementinnSP = elementinn.split('-');
if (element.ArrivalTime >= elementinnSP[0] && element.ArrivalTime <= elementinnSP[1]) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyBaggageFilter = function (data, BaggagepArr) {
var resultsetFiltered = [];
if (BaggagepArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (BaggagepArr.length > 0) {
$.each(BaggagepArr, function (indexinn, elementinn) {
if (JSON.parse(elementinn) == element.IsBagIncludes) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyPriceRangeFilter = function (data, priceArr) {
var resultsetFiltered = [];
if (priceArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (priceArr.length > 0) {
$.each(priceArr, function (indexinn, elementinn) {
if (elementinn == element.FilterPrice) {
//if( $scope.checkAlreadyExistsInArray( element.PkgSysId , resultsetFiltered , 'PkgSysId' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyRefundableFilter = function (data, refundableArr) {
// number of nights
//
var resultsetFiltered = [];
if (refundableArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (refundableArr.length > 0) {
$.each(refundableArr, function (indexinn, elementinn) {
console.log((elementinn));
if (JSON.parse(elementinn) == element.IsRefundable) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.searchInResponseForFilter = function (data, filterValues, type) {
var finaldata = [];
var innerkey = '';
if (type == 'AirlineName') {
innerkey = 'AirlineName';
$.each(data, function (index, element) {
if ($.inArray(element[innerkey], filterValues) != -1) {
// push data in final array if already not exists
if (($.inArray(element[innerkey], finaldata)) == -1) {
finaldata.push(element[innerkey]);
}
}
});
return finaldata;
}
else {
return data;
}
};
$scope.ViewMore = function (item, DepDare, classss, index, IsLCC,PriceID=null) {
$scope.viewmore = item;
$scope.DepDare = DepDare;
$scope.classss = classss;
$scope.index = index;
$scope.IsLCC = IsLCC;
$scope.TotalBaseFare = 0;
$scope.TotalTaxsandFees = 0;
$scope.FareBreakdown = [];
if(PriceID != ''){
var SelectedPrice = PriceID;
}else{
var SelectedPrice = $('#PriceClass_' + index).val();
}
$('#myModal_viewmore').modal('show');
//alert(SelectedPrice);
$.each(item.FairRules, function (key, Fare) {
if (SelectedPrice == Fare.PriceID) {
$scope.FareBreakdown = Fare.FareBreakdown;
if (Fare.FareBreakdown) {
$.each(Fare.FareBreakdown, function (k, value) {
var PBaseFare = value.BaseFare;
var MF = value.MF;
var YQ = value.YQ;
var AGST = value.AGST;
var MFT = value.MFT;
var OT = value.OT;
var YR = value.YR;
var MU = value.MU;
var FixedMarkUp = value.FixedMarkUp;
var GSTOnMarkUp = value.GSTOnMarkUp;
$scope.TotalBaseFare += PBaseFare;
$scope.TotalTaxsandFees += (MF + YQ + AGST + MFT + OT + MU + YR + FixedMarkUp + GSTOnMarkUp);
});
}
}
});
};
$scope.ViewMoreRound = function (item, DepDare, classss, index, IsLCC,PriceID=null) {
$scope.viewmore = item;
$scope.DepDare = DepDare;
$scope.classss = classss;
$scope.index = index;
$scope.IsLCC = IsLCC;
$scope.TotalBaseFare = 0;
$scope.TotalTaxsandFees = 0;
$scope.FareBreakdown = [];
if(PriceID != ''){
var SelectedPrice = PriceID;
}else{
var SelectedPrice = $('#RoundPriceClass_' + index).val();
}
$('#myModal_viewmore').modal('show');
$.each(item.FairRules, function (key, Fare) {
if (SelectedPrice == Fare.PriceID) {
$scope.FareBreakdown = Fare.FareBreakdown;
if (Fare.FareBreakdown) {
$.each(Fare.FareBreakdown, function (k, value) {
var PBaseFare = value.BaseFare;
var MF = value.MF;
var YQ = value.YQ;
var AGST = value.AGST;
var MFT = value.MFT;
var OT = value.OT;
var YR = value.YR;
var MU = value.MU;
var FixedMarkUp = value.FixedMarkUp;
var GSTOnMarkUp = value.GSTOnMarkUp;
$scope.TotalBaseFare += PBaseFare;
$scope.TotalTaxsandFees += (MF + YQ + AGST + MFT + OT + MU + YR + FixedMarkUp + GSTOnMarkUp);
});
}
}
});
};
$scope.onewayflight = function ($scope, index, PriceID) {
angular.element('.SingleSelect input:radio').each(function (v, k) {
if ($(this).is(":checked")) {
// $scope.class_status = true;
$scope.summprice($scope.item.ApiResultIndex, index, PriceID);
}
});
};
$scope.twowayflight = function ($scope, index, PriceID) {
angular.element('.roundSelect input:radio').each(function (v, k) {
if ($(this).is(":checked")) {
$scope.summpricetwo($scope.item.ApiResultIndex, index, PriceID);
}
});
};
$scope.summprice = function (ApiResultIndex, index, PriceID) {
if (ApiResultIndex) {
$scope.PublishedFareTxt = 0;
var outboundFlightIndex = ApiResultIndex;
var Outbound = $scope.flightlistOutbound.find(function (item) {
if (item.ApiResultIndex === outboundFlightIndex) {
return item;
}
});
$.each(Outbound.FairRules, function (key, Fare) {
if (PriceID == Fare.PriceID) {
$scope.PublishedFareTxt = Fare.PublishedFare;
}
});
$scope.roundtrip = Outbound;
return $scope.roundtrip;
}
};
$scope.summpricetwo = function (ApiResultIndex, index, PriceID) {
if (ApiResultIndex) {
$scope.RPublishedFareTxt = 0;
var inboundFlightIndex = ApiResultIndex;
var Inbound = $scope.flightlistInbound.find(function (item) {
if (item.ApiResultIndex === inboundFlightIndex) {
return item;
}
});
$.each(Inbound.FairRules, function (key, Fare) {
if (PriceID == Fare.PriceID) {
$scope.RPublishedFareTxt = Fare.PublishedFare;
}
});
$scope.roundtrip2 = Inbound;
return $scope.roundtrip2;
}
};
$scope.bookNow = function ($scope, index, PriceID=null) {
if(PriceID != ''){
var SelectedPrice = PriceID;
}else{
var SelectedPrice = $('#PriceClass_' + index).val();
}
var url = SITEURL + "flight/book-noow";
var jsonString = JSON.stringify($scope.item);
//var FairRulesString = JSON.stringify($scope.item.FairRules);
//var SegmentsString = $($scope.item.Segments).serializeArray();//($scope.item.Segments);
$http({
method: "POST",
url: url,
data: { Outbound: jsonString, Inbound: '', SingleSelect: SelectedPrice },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
if (response.data.success) {
$window.location.href = response.data.url;
} else {
alert(response.data.message);
}
}, function errorCallback(response) {
alert(response.data.message);
});
};
$scope.bookNowRound = function (Outbound, Inbound) {
var SingleSelect = $("input[name=SingleSelect]:checked").val();
var roundSelect = $("input[name=roundSelect]:checked").val();
// console.log(Inbound);
var url = SITEURL + "flight/book-noow";
var jsonStringOut = JSON.stringify(Outbound);
var jsonString = JSON.stringify(Inbound);
$http({
method: "POST",
url: url,
data: { Outbound: jsonStringOut, Inbound: jsonString, SingleSelect: SingleSelect, roundSelect: roundSelect },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
if (response.data.success) {
$window.location.href = response.data.url;
} else {
alert(response.data.message);
}
}, function errorCallback(response) {
alert(response.data.message);
});
};
}]);
$(document).on('click', '.PriceClass', function () {
var index = $(this).attr('index');
var value = $(this).val();
$('#PriceClass_' + index).val(value);
});
$(document).on('click', '.RoundPriceClass', function () {
var index = $(this).attr('index');
var value = $(this).val();
$('#RoundPriceClass_' + index).val(value);
});