| 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 : |
//var hotelSearch = angular.module("hotelSearch", []);
app.directive("scroll", function ($window) {
return function (scope, element, attrs) {
angular.element($window).bind("scroll", function () {
// if (this.pageYOffset >= 350) {
if ($(window).scrollTop() >= ($(document).height() - $(window).height()) * 0.75) {
element.addClass('min');
$('#loadmore').click();
}
});
};
});
app.controller("HotelListingController", ['$scope', '$http', '$location', '$window','rvServices', '$timeout', function ($scope, $http, $location, $window, rvServices, $timeout ) {
$scope.limitToHotelResults = 0;
$scope.totalHotelResults = 0;
$scope.sortedHotelResults = 0;
$scope.loadingHotel = true;
$scope.loadingRoomInfo = true;
$scope.TotalRoomsDetails = 0;
$scope.PublishedPrice = 'PublishedPrice';
$scope.reverse = false;
$scope.limit = 0;
$scope.FiltStarType = [];
$scope.FiltPriceUnique = [];
$scope.AllFilterAreaUnique = [];
$scope.AllFilterHotelProperty = [];
$scope.FilterCategory = [];
$scope.FilterMealPlan = [];
$scope.flag = 0;
$scope.ErrorRoomInfo = false;
var absUrl = $location.absUrl();
var sURLVariables = absUrl.split('?');
var SearchTraceId = $('#SearchTraceId').val();
console.log('mangal');
// console.log(sURLVariables[1]);
var url = SITEURL + "hotelsinv/search/search-results/TraceId/" + SearchTraceId;
$http({
method: "POST",
url: url,
data: sURLVariables[1],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
$scope.loadingHotel = false;
$scope.Hotellist = $scope.HotellistFull = response.data.result;
console.log(response.data.result);
$scope.totalHotelResults = response.data.result.length;
$scope.FiltStarType = response.data.FilterStarRating;
$scope.FiltPriceUnique = response.data.FilterPrice;
$scope.FilterAreaUnique = response.data.FilterAreaUnique;
$scope.FilterHotelProperty = response.data.FilterHotelProperty;
$scope.FilterCategory = response.data.FilterCategory;
$scope.FilterMealPlan = response.data.FilterMealPlan;
// $scope.RequestRoomInfo();
// $scope.RequestHotelInfo();
console.log($scope.FilterMealPlan);
}, function errorCallback(response) {
}).finally(function () {
$scope.orderby = 'PublishedPrice';
$scope.orderval = false;
$scope.limit = 10;
});
$scope.loadMore = function () {
if ($scope.Hotellist.length > 0) {
var increamented = $scope.limit + 10;
$scope.limit = increamented > $scope.Hotellist.length ? $scope.Hotellist.length : increamented;
if($scope.Hotellist.length == $scope.limit){
$('.loadMore').hide();
}
}
};
$scope.sortBy = function (PublishedPrice) {
$scope.reverse = ($scope.PublishedPrice === PublishedPrice) ? !$scope.reverse : false;
$scope.PublishedPrice = PublishedPrice;
};
$scope.filterData = function () {
var filterSTR = { 'price': [], 'starType': [],'Category':[],'MealPlan':[],'Area':[],'Property':[] };
angular.element('.filter-box input:checkbox').each(function () {
if ($(this).is(":checked")) {
if ($(this).hasClass('filter-price')) {
filterSTR.price.push($(this).val());
} else if ($(this).hasClass('filter-star')) {
filterSTR.starType.push($(this).val());
} else if ($(this).hasClass('filter-category')) {
filterSTR.Category.push($(this).val());
} else if ($(this).hasClass('filter-mealplan')) {
filterSTR.MealPlan.push($(this).val());
} else if ($(this).hasClass('filter-area')) {
filterSTR.Area.push($(this).val());
} else if ($(this).hasClass('filter-property')) {
filterSTR.Property.push($(this).val());
}
}
});
if ((filterSTR.price.length > 0) || (filterSTR.starType.length > 0) || (filterSTR.Category.length > 0) || (filterSTR.MealPlan.length > 0) || (filterSTR.Area.length > 0) || (filterSTR.Property.length > 0)) {
$scope.Hotellist = this.filterFromArray($scope.HotellistFull, filterSTR);
} else {
$scope.Hotellist = $scope.HotellistFull;
}
};
$scope.filterFromArray = function (data, filterSTR) {
var resultsetFiltered = [];
resultsetFiltered = $scope.applyPriceRangeFilter(data, filterSTR.price);
resultsetFiltered = $scope.applyStarTypeFilter(resultsetFiltered, filterSTR.starType);
resultsetFiltered = $scope.applyCategoryFilter(resultsetFiltered, filterSTR.Category);
resultsetFiltered = $scope.applyMealPlanFilter(resultsetFiltered, filterSTR.MealPlan);
resultsetFiltered = $scope.applyAreaFilter(resultsetFiltered, filterSTR.Area);
resultsetFiltered = $scope.applyPropertyFilter(resultsetFiltered, filterSTR.Property);
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) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyAreaFilter = function (data, AreaArr) {
var resultsetFiltered = [];
if (AreaArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (AreaArr.length > 0) {
$.each(AreaArr, function (indexinn, elementinn) {
if (elementinn == element.FilterArea) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyPropertyFilter = function (data, PropertyArr) {
var resultsetFiltered = [];
if (PropertyArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (PropertyArr.length > 0) {
$.each(PropertyArr, function (indexinn, elementinn) {
if (elementinn == element.FilterPropertyName) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyStarTypeFilter = function (data, StarArr) {
var resultsetFiltered = [];
if (StarArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (StarArr.length > 0) {
$.each(StarArr, function (indexinn, elementinn) {
if (elementinn == element.StarRating) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyCategoryFilter = function (data, categoryArr) {
var resultsetFiltered = [];
if (categoryArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (categoryArr.length > 0) {
$.each(categoryArr, function (indexinn, elementinn) {
if (elementinn == element.Category) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.applyMealPlanFilter = function (data, MealPlanArr) {
var resultsetFiltered = [];
if (MealPlanArr.length == 0) {
return data;
}
$.each(data, function (index, element) {
if (MealPlanArr.length > 0) {
$.each(MealPlanArr, function (indexinn, elementinn) { console.log(elementinn);console.log(element.mealPlanArray);console.log($.inArray(elementinn, element.mealPlanArray));
if ($.inArray(elementinn, element.mealPlanArray) != -1) {
// if (elementinn == element.Category) {
resultsetFiltered.push(element);
}
});
}
});
return resultsetFiltered;
};
$scope.RequestHotelInfo = function () {
var url = SITEURL + "hotelsinv/search/request-hotel-info";
$http({
method: "POST",
url: url,
data: null,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
$scope.loadingRoomInfo = false;
console.log(response.data.result);
});
};
$scope.RequestRoomInfo = function (val, index) {
$('.hotel_infoDIV_' + index).show();
$('.hotel_booking').hide();
var flag = $('#flag_' + index).val();
// alert(flag);
// return false;
$scope.loadingRoomInfo = true;
$scope.ErrorRoomInfo = false;
var url = SITEURL + "hotelsinv/search/request-room-info";
$http({
method: "POST",
url: url,
data: { hotelData: val, TraceId: val.TraceId, ResultIndex: val.ResultIndex, HotelCode: val.HotelCode, flag: flag, index: index },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
// console.log(response.data);
$scope.loadingRoomInfo = false;
if (response.data.ArrRoomInfo.ResponseStatus == 1) {
$scope.RoomInfo = (response.data.RoomInfo);
$scope.HotelRoomsDetails = (response.data.ArrRoomInfo.HotelRoomsDetails);
$scope.TotalRoomsDetails = (response.data.ArrRoomInfo.HotelRoomsDetails.length);
$scope.IsUnderCancellationAllowed = (response.data.ArrRoomInfo.IsUnderCancellationAllowed);
$scope.refundTax = (response.data.ArrRoomInfo.refundTax);
// var HotelInfoResult = (response.data.ArrHotelInfo.HotelInfoResult);
$scope.HotelDetails = (response.data.ArrHotelInfo.HotelInfoResult.HotelDetails);
$scope.RoomFacilities = (response.data.ArrHotelInfo.HotelInfoResult.HotelDetails.HotelFacilities);
// $scope.RoomFacilities = RoomFacilities.join(" ");
$scope.flag++;
$('#flag_' + index).val($scope.flag);
} else {
$scope.ErrorRoomInfo = true;
$scope.ErrorMessage = response.data.ArrRoomInfo.Error.ErrorMessage;
}
});
};
$scope.BookRoomNow = function (item, val, index) {
// alert(flag);
// return false;
var url = SITEURL + "hotelsinv/search/book-room";
$http({
method: "POST",
url: url,
data: { item: item, val: val, index: index },
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);
}
});
};
$scope.HotelDetail = function (item, index) {
var url = SITEURL + "hotelsinv/index/hotel-detail/" + item.SearchHotelTraceId + '/' + item.TraceId;
$http({
method: "POST",
url: url,
data: { item: item, index: index, page: 'NA' },
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);
}
});
};
$scope.ViewMap = function (item, index) {
var url = SITEURL + "hotelsinv/index/hotel-view-map/" + item.SearchHotelTraceId + '/' + item.TraceId;
$http({
method: "POST",
url: url,
data: { item: item, index: index, page: 'NA' },
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function successCallback(response) {
$('#HotelMaps').modal('show');
$('#HotelMapsDIV').html(response.data);
});
};
$scope.rvGetSeoUrl = function (str) {
return rvServices.rvSanitizeForUrl(str);
};
$scope.Cancellation = function (val) {
$('#cancellationpolicyPOP').modal('show');
//$('#CancellationPolicy').show();
var Listul = $('<ul></ul>');
angular.forEach(val.CancellationPolicies, function (value, key) {
Listul.append('<li>From: ' + value.strFromDate + ' To: ' + value.strToDate + ' : ' + value.Currency + ' ' + value.Charge + ' Charges.</li>');
});
$('#cancellation_div').html(Listul);
$('li.CancellationPolicy').html(val.CancellationPolicy);
};
$scope.GetValue = function() {
var itemArr = [];
angular.element('.comision_checkbox input:checked').each(function(v, k) {
itemArr.push($('#selectedHotelRoomData'+this.value).val());
});
var url = SITEURL + "hotelsinv/search/get-selected-share-data";
$.ajax({
url: url,
type: 'POST',
data: {item:itemArr},
dataType: 'html',
beforeSend: function () {
}, success: function (result) {
$('#hotelRoomWiseData').html(result);
$('.pleaseWaitPop').show();
$('.shareWithWhatsappPOP').hide();
}
})
//console.log(($scope.allselected));
};
}]);