| 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/greenvalley/public/js/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;
//console.log($scope);
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);
$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.Currency = response.data.CurrencyTitle;
$scope.FiltStopCount = response.data.FiltStopCount;
$scope.ArrPriceUnique = response.data.ArrPriceUnique;
$scope.MinriceRange = response.data.MinriceRange;
$scope.MaxriceRange = response.data.MaxriceRange;
$scope.FXMinriceRange = response.data.MinriceRange;
$scope.FXMaxriceRange = response.data.MaxriceRange;
$('#priceRage').val($scope.MinriceRange + '-' + $scope.MaxriceRange);
$('.domestround').show();
$('#slide_amount').html('<span>' + response.data.CurrencyTitle + ' ' + $scope.MinriceRange + '</span> <span class="rightprice">' + response.data.CurrencyTitle + ' ' + $scope.MaxriceRange + '</span>');
//console.log($scope.MinriceRange);
//console.log($scope.MaxriceRange);
$("#slider-range").slider({
range: true,
min: $scope.MinriceRange,
max: $scope.MaxriceRange,
values: [$scope.MinriceRange, $scope.MaxriceRange],
slide: function(event, ui) {
$("#slide_amount").html('<span>' + response.data.CurrencyTitle + ' ' + ui.values[0] + "</span> <span class='rightprice'>" + response.data.CurrencyTitle + ' ' + ui.values[1] + '</span>');
// Get values
var min = ui.values[0];
var max = ui.values[1];
$('#priceRage').val(min + '-' + max);
$scope.MinriceRange = min;
$scope.MaxriceRange = max;
}
});
}, function errorCallback(response) {
}).finally(function() {
$scope.loadingFlight = false;
$scope.FilterloadingFlight = false;
$scope.hotelType = 'Standard';
$scope.orderby = 'Price';
$scope.orderval = false;
$scope.limit = 15; // total result
$scope.limitRound = 15; // 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.changeMaxSlider = function() {
console.log('ffff');
};
$scope.priceRange = function(item) {
// var resultsetFiltered = [];
// $.each(item.FairRules, function (index, element) {
// console.log(element.PublishedFare);
// //return (parseInt(element.PublishedFare) >= $scope.MinriceRange && parseInt(element.PublishedFare) <= $scope.MaxriceRange);
// });
// return (parseInt(item['PublishedFare']) >= $scope.MinriceRange && parseInt(item['PublishedFare']) <= $scope.MaxriceRange);
};
$scope.filterByFlightMatchingAND = function(data) {
var matchesAND = true;
//
for (var obj in $scope.filter) {
if ($scope.filter.hasOwnProperty(obj)) {
if (noSubFilter($scope.filter[obj])) continue;
if (!$scope.filter[obj][data[obj]]) {
matchesAND = false;
break;
}
}
}
return matchesAND;
};
function noSubFilter(obj) {
for (var key in obj) {
if (obj[key]) return false;
}
return true;
};
$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': [], 'FiltStopCountRound': [], 'AirlineName': [], 'AirlineNameReturn': [], 'Times': [], 'TimesReturn': [], 'Arrivetimes': [], 'ArrivetimesReturn': [], '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-airline-return')) {
filterSTR.AirlineNameReturn.push($(this).val());
} else if ($(this).hasClass('filter-stop')) {
filterSTR.FiltStopCount.push($(this).val());
} else if ($(this).hasClass('filter-stop-round')) {
filterSTR.FiltStopCountRound.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-times-return')) {
filterSTR.TimesReturn.push($(this).val());
} else if ($(this).hasClass('filter-arrivetimes')) {
filterSTR.Arrivetimes.push($(this).val());
} else if ($(this).hasClass('filter-arrivetimes-return')) {
filterSTR.ArrivetimesReturn.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());
}
}
});
var filterprice = $('#priceRage').val();
//console.log(filterprice);
filterSTR.price.push(filterprice);
// 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;
}
if ((filterSTR.FiltStopCountRound.length > 0) || (filterSTR.price.length > 0) || (filterSTR.TimesReturn.length > 0) || (filterSTR.ArrivetimesReturn.length > 0) || (filterSTR.AirlineNameReturn.length > 0) || (filterSTR.baggage.length > 0) || (filterSTR.meals.length > 0) || (filterSTR.refundable.length > 0)) {
$scope.flightlistInbound = this.filterFromArrayReturn($scope.resultsetFullInb, filterSTR);
} else {
$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.filterFromArrayReturn = function(data, filterSTR) {
var resultsetFiltered = [];
resultsetFiltered = $scope.applyStopCountFilterReturn(data, filterSTR.FiltStopCountRound);
resultsetFiltered = $scope.applyPriceRangeFilter(resultsetFiltered, filterSTR.price);
resultsetFiltered = $scope.applyTimesReturnFilter(resultsetFiltered, filterSTR.TimesReturn);
resultsetFiltered = $scope.applyArrivetimesReturnFilter(resultsetFiltered, filterSTR.ArrivetimesReturn);
resultsetFiltered = $scope.applyAirlineFilterReturn(resultsetFiltered, filterSTR.AirlineNameReturn);
resultsetFiltered = $scope.applyBaggageFilter(resultsetFiltered, filterSTR.baggage);
resultsetFiltered = $scope.applyMealsFilter(resultsetFiltered, filterSTR.meals);
resultsetFiltered = $scope.applyRefundableFilter(resultsetFiltered, filterSTR.refundable);
return resultsetFiltered;
};
$scope.applyPriceRangeFilter = function(data, priceArr) {
var resultsetFiltered = [];
if (priceArr.length == 0) {
return data;
}
$.each(data, function(index, element) {
var Ismatched = false;
$.each(element.FairRules, function(indexpr, FairRules) {
var PublishedFare = (Math.round(FairRules.PublishedFare));
if (priceArr.length > 0) {
$.each(priceArr, function(indexinn, elementinn) {
var elementinnSP = elementinn.split('-');
if (PublishedFare >= parseInt(elementinnSP[0]) && PublishedFare <= parseInt(elementinnSP[1])) {
Ismatched = true;
//resultsetFiltered.push(element);
}
});
}
})
//console.log(Ismatched);
if (Ismatched) {
resultsetFiltered.push(element);
}
});
//console.log(resultsetFiltered);
return resultsetFiltered;
};
$scope.applyAirlineFilterReturn = function(data, airlineArr) {
// number of nights
// console.log(data);
var resultsetFiltered = [];
if (airlineArr.length == 0) {
return data;
}
$.each(data, function(index, element) {
if (airlineArr.length > 0) {
$.each(airlineArr, function(indexinn, elementinn) {
if (elementinn == element.AirlineName) {
//if( $scope.checkAlreadyExistsInArray( element.AirlineName , resultsetFiltered , 'AirlineName' ) == false ) {
resultsetFiltered.push(element);
//}
}
});
}
});
return resultsetFiltered;
};
$scope.applyArrivetimesReturnFilter = function(data, timesArrArrival) {
var resultsetFiltered = [];
if (timesArrArrival.length == 0) {
return data;
}
$.each(data, function(index, element) {
if (timesArrArrival.length > 0) {
$.each(timesArrArrival, function(indexinn, elementinn) {
var elementinnSP = elementinn.split('-');
if (element.ArrivalTime >= elementinnSP[0] && element.ArrivalTime <= elementinnSP[1]) {
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.applyTimesReturnFilter = 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.applyStopCountFilterReturn = function(data, StopArr) {
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.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.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.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.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) {
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.PriceID = PriceID;
$scope.DepDare = DepDare;
$scope.classss = classss;
$scope.IsSeriesFareData = item.IsSeriesFareData;
$scope.FareRules = item.FareRules;
$scope.index = index;
$scope.IsLCC = IsLCC;
$scope.TotalBaseFare = 0;
$scope.TotalTaxsandFees = 0;
$scope.FareBreakdown = [];
//console.log(item.FareRules);
$scope.Currency = item.FairRules[0].Currency;
if (PriceID != '') {
var SelectedPrice = PriceID;
} else {
var SelectedPrice = $('#PriceClass_' + index).val();
}
$('#myModal_viewmore').modal('show');
$.each(item.FairRules, function(key, Fare) {
var CurrencyRate = Fare.CurrencyRate;
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 * CurrencyRate);
$scope.TotalTaxsandFees += ((MF + YQ + AGST + MFT + OT + MU + YR + FixedMarkUp + GSTOnMarkUp) * CurrencyRate);
});
}
}
});
var url = SITEURL + "flight/viewmore";
$http({
method: "POST",
url: url,
data: { item: item, PriceID: PriceID },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
if (response.data.success) {
// $scope.finalFareSummary = response.data.finalFareSummary;
$('.FareSummaryDiv').html(response.data.html);
} else {
alert(response.data.message);
}
}, function errorCallback(response) {
alert(response.data.message);
});
};
$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 = [];
$scope.Currency = item.FairRules[0].Currency;
if (PriceID != '') {
var SelectedPrice = PriceID;
} else {
var SelectedPrice = $('#RoundPriceClass_' + index).val();
}
$('#myModal_viewmore').modal('show');
$.each(item.FairRules, function(key, Fare) {
var CurrencyRate = Fare.CurrencyRate;
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 * CurrencyRate);
$scope.TotalTaxsandFees += ((MF + YQ + AGST + MFT + OT + MU + YR + FixedMarkUp + GSTOnMarkUp) * CurrencyRate);
});
}
}
});
var url = SITEURL + "flight/viewmore";
$http({
method: "POST",
url: url,
data: { item: item, PriceID: PriceID },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
if (response.data.success) {
// $scope.finalFareSummary = response.data.finalFareSummary;
$('.FareSummaryDiv').html(response.data.html);
} else {
alert(response.data.message);
}
}, function errorCallback(response) {
alert(response.data.message);
});
};
$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.duration();
}
});
};
$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.duration();
}
});
};
$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.LocalToTime = Outbound.LocalToTime;
$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.LocalFromTime = Inbound.LocalFromTime;
$scope.duration();
$scope.roundtrip2 = Inbound;
return $scope.roundtrip2;
}
};
$scope.duration = function() {
var t0 = $scope.LocalToTime;
var t1 = $scope.LocalFromTime;
var start = t0;
var end = t1;
start = new Date(start);
end = new Date(end);
var diff = end.getTime() - start.getTime();
var time_difference = new Object();
time_difference.hours = Math.floor(diff / 1000 / 60 / 60);
diff -= time_difference.hours * 1000 * 60 * 60;
if (time_difference.hours < 10) time_difference.hours = time_difference.hours;
time_difference.minutes = Math.floor(diff / 1000 / 60);
diff -= time_difference.minutes * 1000 * 60;
if (time_difference.minutes < 10) time_difference.minutes = time_difference.minutes;
// console.log(time_difference);
if (time_difference.hours < 2) {
setTimeout(function() {
$('.bookNowRound').attr('title', 'Departure time must be greater than previous Arrival time by 2 hours.');
$('.bookNowRound').css('background', '#575251');
}, 2000);
$scope.BookingAllowed = false;
} else {
$('.bookNowRound').removeAttr('title', '');
$('.bookNowRound').css('background', '#00783a');
$scope.BookingAllowed = true;
}
};
$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);
if ($scope.BookingAllowed) {
$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);
});
} else {
alert('Departure time must be greater than previous Arrival time by 2 hours.');
}
};
}]);
$(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);
});