(function(rt){ rt.templates.operators = { main: '\
\
\
\
\ \
\
\
\
\
\ \
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\ ', alert: '\
<%=msg %>
\ ', confirm: '\
<%=msg %>
\
\ ', selection: '\
\
<$ru: закрыть,en: close$>
\ \
\
\ ', iAmTourist: '\
\
\
\
\ ', agency_tourist: '\ \
\ ', iAmAgent: '\
\
' + (document.location.host == 'online2.rt.plus' || document.location.host == 'cabinet.leningrad.travel' ? '' : '

Для новых партнеров: Регистрация туристических агентств проводится сотрудниками отдела по работе с турагентами. Для получения подробной информации, вам необходимо пройти в раздел регистрация агентства. Заказы принимаются только после регистрации.
') , searchUniversal: '\
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \
\
\
\
\ \
\
\ \
\
\
\ data-type="hotelavia">\ \
\
\ data-type="tours">\ \
\
\ data-type="hotel">\ \
\
\ data-type="avia">\ \
\
\ data-type="excursion">\ \
\
\ data-type="transfers">\ \
\
\ \ \
\ ', showUniversalMaket: '\
\
\ \ \ \
\ \
\ \
\
\
\
\
Производится поиск авиаперелёта на соседние даты для проверки наличия наилучшей цены.
\
\
\
\
\
\
\
\
\
\
Производится поиск авиаперелёта на соседние даты
\
\
\
\
\
\
\
\
\
\
\
\ \ ', tableDay: '\ <% var z=0, x=0;%>\ \ \ \ <% for (var i = 0; i < from.length; i++) { %>\ \ <% } %>\ \ <% var h = 0;\ for (var i = 0; i < to.length; i++) {%>\ \ \ <% for (var y = 0; y < from.length; y++) {\ \ \ var thereIsData = (data[to[i]] != undefined && data[to[i]][from[y]] != undefined); %>\ \ <% } %>\ \ <% \ h++;\ } %>\
<%=from[i]%>
<%=to[i]%> table_search ts<%=to[i].replace(".","").replace(".","") %>-<%=from[y].replace(".","").replace(".","") %> <%=thereIsData ? "hasData "+(data[to[i]][from[y]][0] - avia_min_sum) : "" %> <%=(thereIsData && (data[to[i]][from[y]][0] - avia_min_sum) > 1 ? "tsmin" : "tsmax") %>" style="<%=thereIsData ? "background-color: " + pricesColor[data[to[i]][from[y]][0]]: "" %>">\ <% if (thereIsData) {%>\ \ <% if (data[to[i]][from[y]][0] == bestPrice) { %><% } %>\ <%=widget.calcFinalPrice(data[to[i]][from[y]][0],sum,to[i],from[y]).formatted %> Р\ <% } else { %>\ \ <% } %>\
', show_visa: '\ <% if (visas.length > 1) { %>\
\ Город подачи документов: \ \
\ <% } %>\ <% var first = true;\ for ( var i in visas) { %>\
">\ <%=visas[i][1] %>\
\ \ <% first = false; } %>\ ', sortings: '\
\ \ <$ru: Цена, en: Price $>\ \ \ \ <$ru: Название, en: Name $>\ \ \
\
\ <$ru: Валюта, en: Currency $>: \ RUB\ USD\ EUR\ GBP\
\
\
\ \ \ ', rt_universal_hotel: '\ <% if (widget.check_sum_avia() && avia) { %>\
\ Выбран прямой перелет без пересадок. Авиаперелет с пересадками дешевле на <%=widget.sum_min_avia() %> P\
\ <% } %>\ <% for (var i in data) { %> \
\
\
\

<%=data[i].name %> <%=data[i].category %>

\
\
\
\ <% for (var y in data[i].images) {%>\
" >
\ <% } %>\
\
\
\
\

<%=data[i].description %>

\ <% if (data[i].adr != "") {%>\

<%=data[i].adr %>

\ <% } %>\
\
\
\
\ <% if (data[i].recomendation == 1) { %> <% } %>\ <% if (data[i].spec_text != "") { %>
<%=data[i].spec_text %>
<% } %>\ <% if (data[i].sochi == 1) { %> <% } %>\

\ Проживание:
с <%=data[i].start %> на <%=data[i].night %> <%=widget.sklon_nights(data[i].night) %>
\ по <%=data[i].stop %>\

\ <% if (avia) { %>\

\ Перелёт:
<%=widget.show_info_fly(data[i].start+"-"+data[i].night) %>\

\ <% } %>\ \
\ \ <% if (avia) { %>\ <%=widget.cost_hotel_avia(data[i].start+"-"+data[i].night,data[i].room[0].priceavia.prices.rur) %> Р\ <% } else { %>\ <%=data[i].room[0].prices.rur %> Р\ <% } %>\ \
\
\
\
\ \
\
\

Номер

\

По питанию

\

Статус

\

\
\
\ \ <% for (var y in data[i].room) if (y < 3) { \ var room = data[i].room[y]; \ %>\
" src:room_id="<%=y %>">\
\

<%=room.name %>

\

<%=room.meal %>

\

"><%=(room.st == 0 ? "Ожидание" : (room.rt_status == "AV" && room.autobron == 1 ? "Автобронирование" : "В наличии" ) ) %>

\

\ <% if (avia) { %>\ <%=widget.cost_hotel_avia(data[i].start+"-"+data[i].night,room.priceavia.prices.rur) %> Р\ <%=widget.cost_hotel_avia(data[i].start+"-"+data[i].night,room.priceavia.prices.usd,"usd") %> $\ <%=widget.cost_hotel_avia(data[i].start+"-"+data[i].night,room.priceavia.prices.eur,"eur") %> €\ <%=widget.cost_hotel_avia(data[i].start+"-"+data[i].night,room.priceavia.prices.gbp,"gbp") %> £\ <% } else { %>\ <%=room.prices.rur %> Р\ <%=room.prices.usd %> $\ <%=room.prices.eur %> €\ <%=room.prices.gbp %> £\ <% } %> \

\
\
\ <% } %>\ \ <% if (data[i].room.length > 3) { %>\ \
+ Посмотреть больше прайсов и типов питания
\ \ <% } %>\
\ <% } %>\ \ \ ', rt_avia_params:'\
\
\
\ \
\ \ \
\
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\
\
\
\
\
\ \ \
\
\
\
\ \
\
\
\ ', rt_universal_avia: '\ \
\ <% for (var st in structure) { \ for (var st2 in structure[st]) { \ for (var st3 in structure[st][st2]) { \ var strucs = structure[st][st2][st3];\ %>\
\
\
\
\ <% var first = true;\ var count = 0;\ for (var i in strucs) { \ count++; \ var flys = data[strucs[i]]; \ var latest = flys.origin[(flys.origin.length -1)][(flys.origin[(flys.origin.length -1)].length - 1)]; \ %>\
" src:sim="<%=i %>">\ \ <%=flys.origin[0][0].time_from %>\
\ \ <%=latest.time_from %>\
\ <% first = false; } %>\
\
\ <% if (count > 8) { %>\ \ \ <% } %>\
\ <% var first = true;\ for (var i in strucs) {\ \ var flys = data[strucs[i]]; \ %>\
ticket-<%=i %>">\ \ <% for (var z in flys.origin) { %>\
\ <%=(z == 0 ? "Туда" : "Обратно") %>: <%=(flys.origin[z].length == 1 ? "Прямой рейс" : "Рейс с пересадками") %>\
\ \ <% for (var y in flys.origin[z]) {\ var fly = flys.origin[z][y];\ var city = fly.fly.split(" - ");\ var hour = " ч. ";\ var country = fly.countries.split(" - ");\ %>\ <% if (fly.timeport) { %>\
\
Пересадка <%=(fly.timeport > 60 ? parseInt(fly.timeport / 60) + hour + (fly.timeport - parseInt(fly.timeport / 60) * 60) : fly.timeport) %> м.
\
\ <% } %>\
\
\
\ \
\
\
\
\
\
\
\
\ <%=city[0] %>\
\
\ <%=country[0] %>\
\
\
\
\
\
<%=fly.time_from %>
\
<%=fly.date_from %>
\
\
\
\
\
\
В пути
\
\
<%=(fly.time > 60 ? parseInt(fly.time / 60) + hour + (fly.time - parseInt(fly.time / 60) * 60) : fly.time) %> м.
\
\
\
\
\
\
<%=fly.time_to %>
\
<%=fly.date_to %>
\
\
\
\
\
\ <%=city[1] %>\
\
\ <%=country[1] %>\
\
\
\
\
\
\ \
\
\
\
\
\
\
\ <% } %>\ <% } %>\ \
\ <% first = false; } %>\
\ <% } %>\ <% } %>\ <% } %>\
\ \ ', rt_universal_excursion: '\ <% for(var i in data){ \ var find = data[i]; %>\
\
\
\

<%=find.name%>

\
\ \
\
\ <% for (var y in find.images) {%>\ \ <% } %>\
\ \ \
\ \
\
\ <%=find.description %> <%=(typeof(find.durationinbusoneway) != "undefined" && find.durationinbusoneway == "00:02" ? "Подробнее (место встречи, расписание)" : "Подробнее... ") %>\
\ Город: <%=find.cityname %>\
\
\
\ <% if (typeof(find.excursiontype) != "undefined" && find.excursiontype != "") { %>\ Тип экскурсии: <%=(find.excursiontype == 2 ? "Пешеходная экскурсия" : (find.excursiontype == 3 ? "Круизы" : "Автобусная экскурсия")) %> \
\ <% } %>\
\
\ <% if (typeof(find.durationinbusoneway) != "undefined" && find.durationinbusoneway != "") { %>\ Вид экскурсии: <%=(find.durationinbusoneway == "00:02" ? "Групповая" : "Индивидуальная") %>\
\ <% } %>\
\
\ <% if (typeof(find.routecomplexity) != "undefined" && find.routecomplexity != "") { %>\ Количество человек: <%=find.routecomplexity%>\
\ <% } %>\
\
\ <% if (typeof(find.excursionduration) != "undefined" && find.excursionduration != "") { %>\ Продолжительность: <%=find.excursionduration%>\
\ <% } %>\
\
\ Статус: Быстрое подтверждение \
\
\
\ \
\
\

\ Дата\ \

\ \
\ <%=find.prices.rur %> Р\ <%=find.prices.usd %> $\ <%=find.prices.eur %> €\ <%=find.prices.gbp %> £\
\
\
\
\
\ <% } %>\ ', rt_universal_transfers: '\ <% for(var i in data){ \ var find = data[i]; %>\
\
\
\

<%=find.name%>

\
\ \
\
\ <% for (var y in find.images) {%>\ \ <% } %>\
\ \ \
\ \
\
\
\ <% if (typeof(find.otkuda) != "undefined" && find.otkuda != "") { %>\ Откуда: <%=find.otkuda %>\
\ <% } %>\
\
\ <% if (typeof(find.kuda) != "undefined" && find.kuda != "") { %>\ Куда: <%=find.kuda %>\
\ <% } %>\
\
\ <% if (typeof(find.carcass) != "undefined" && find.carcass != "") { %>\ Класс: <%=find.carcass %>\
\ <% } %>\
\
\ <% if (typeof(find.rt_ow) != "undefined" && find.rt_ow != "") { %>\ Направление: <%=find.rt_ow %>\
\ <% } %>\
\
\ <% if (typeof(find.types) != "undefined" && find.types != "") { %>\ Тип: <%=find.types %>\
\ <% } %>\
\
\ Статус: Быстрое подтверждение \
\
\ <%=find.description %> \
\
\
\ \ \
\
\ <% } %>\ <% if (data.length == 0) { %>\ Для поиска трансферов, выберите "Откуда" и "Куда"\ <% } %>\ ', rt_universal_transfers_form: '\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\ \
\
\
\
\ \ \ \ ', rt_universal_tours: '\ <% for(var i in data){ %>\
\
\ <$ru: Заезд, en: Check in$>\

<%=data[i].start %>\

\
\
\ <$ru: Ночи, en: Nights $>\

<%=data[i].night %>

\
\
\ <$ru: Размещение, en: Accommodation $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].name %>, <%=data[i].hotels[y].city %>

\ <% } %>\ <% } %>\
\
\ <$ru: Тип проживания, en: Accommodation type $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].room %>

\ <% } %>\ <% } %>\
\
\ <$ru: Питание, en: Meals $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].meal %>

\ <% } %>\ <% } %>\
\
\ <$ru: Программа, en: Program $>\

<%=data[i].name %>

\
\
\ <$ru: Места, en: Places $>\ <% if (data[i].hotels.length > 0) { %>\ <$ru: Быстрое подтверждение, en: Quick confirmation $> \ <% } %>\
\
\ \
\ <%=data[i].prices.rur %> Р\ <%=data[i].prices.usd %> $\ <%=data[i].prices.eur %> €\ <%=data[i].prices.gbp %> £\
\
\ \
\ <% } %>\ <$ru: Развернуть, en: Expand$>\ ', rt_universal_packet: '\ <% for(var i in data){ %>\
\
\ Заезд\

<%=data[i].start %>

\
\
\ Ночи\

<%=data[i].night %>

\
\
\ Размещение\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].name %>, <%=data[i].hotels[y].city %>

\ <% } %>\ <% } %>\
\
\ Тип проживания\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].room %>

\ <% } %>\ <% } %>\
\
\ Питание\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].meal %>

\ <% } %>\ <% } %>\
\
\ Программа\

<%=data[i].name %>

\
\
\ Места\ <% if (data[i].hotels.length > 0) { %>\ Быстрое подтверждение \ <% } %>\
\
\ Перелёт\ <% if (data[i].flight == 1) { %>\
\ <% } else { \ for (var f in data[i].flight.origin) {\ for (var f_o in data[i].flight.origin[f]) {\ var flight = data[i].flight.origin[f][f_o];\ \ if (parseInt(flight.seat) == 100) { %>\
\ <%} \ if (parseInt(flight.seat) < 100) { %>\
\ <%} \ }\ }\ } %>\
\
\ <%\ var prices = data[i].prices;\ if (typeof(data[i].flight_prices) != "undefined" ) {\ var prices = data[i].flight_prices;\ } \ %>\ \
\ <%=prices.rur %> Р\ <%=prices.usd %> $\ <%=prices.eur %> €\ <%=prices.gbp %> £\
\
\ \
\ <% } %>', searchTour: '\
\
\
\
\ \ \
\
\
\
\ \ \ \
\
\
\
\ \
\
\
\ \
\
\ \ \
\ ', searchTourCategory: '\
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \
\
\
\
\ \
\
\
\ \
\
\ \ \
\ ', tourDescription: '\
\ Печать\

<%=data.Name %>

\ \

<%=data.description %>

\
\
\
<%=hotelTour %>
\
\

Дополнительно оплачивается.

\
\
\ ', tour_description: '\
\

<%=data.data.Name %>

\ \

<%=data.data.Description %>

\
\

В стоимость включены:

\ <% for ( var i in data.included) {%>\

- <%=data.included[i].NAME %>;

\ <% } %>\
\ \
\

Дополнительно оплачивается.

\ <%=data.additinalCharge %>\
\
\

Программа тура.

\ <%=data.programs %>\
\
Печать\
\ ', tourOrder: '\
\

<%=data.Name %>

\
Без перелёта
\
\
\ <$ru: итого,en: total$> <%=price%> Р \
\
\ Итого для агента <%=priceToPay %> Р \ style="display:none" <% } %>>Показать цену для агента\
\
\
\
\ ', data_order_transfer: '\ <% for (var i in data) {%>\
\
\
\

Трансфер: <%=data[i].otkuda %>

\ <% if (data[i].type_destanation == "avia") { %>\

Время прилёта самолёта: (время местное)

\ <% } %>\ <% if (data[i].type_destanation == "train") { %>\

Время прибытия поезда: (время местное)

\ <% } %>\ \ \
\
\ \ \
\
\ \
\
\ :\
\
\ \
\
\ \ <% if (data[i].type_destanation == "palce" || data[i].type_destanation == "hotel") { %>\
\ \ \ \ \
\ <% } else { %>\ \ <% } %>\ <% if (data[i].type_destanation == "avia") { %>\
\ № рейса / терм: \
\ <% } %>\ <% if (data[i].type_destanation == "train") { %>\
\ \ № поезда вагон: \
\ <% } %>\
\
\

<%=data[i].kuda %>

\ <% if (data[i].type_destanation_back == "palce" || data[i].type_destanation_back == "hotel") { %>\
\ \ \ \ \
\ <% } else { %>\ \ <% } %>\ <% if (data[i].type_destanation_back == "avia") { %>\
\ № рейса / терм: \
\ <% } %>\ <% if (data[i].type_destanation_back == "train") { %>\
\ \ № поезда вагон: \
\ <% } %>\
\
\
\
\ <% if (data[i].rt_ow == "Туда и обратно") { %>\

Трансфер обратно: <%=data[i].kuda %>

\ <% if (data[i].type_destanation_back == "avia") { %>\

Время вылета самолёта: (время местное)

\ <% } %>\ <% if (data[i].type_destanation_back == "train") { %>\

Время прибытия поезда: (время местное)

\ <% } %>\
\
\ \ \
\
\ \
\
\ :\
\
\ \
\
\ <% if (data[i].type_destanation_back == "palce" || data[i].type_destanation_back == "hotel") { %>\
\ \ \ \ \
\ <% } else { %>\ \ <% } %>\ <% if (data[i].type_destanation_back == "avia") { %>\
\ № рейса / терм: \
\ <% } %>\ <% if (data[i].type_destanation_back == "train") { %>\
\ \ № поезда вагон: \
\ <% } %>\ <% } %>\ \
\
\ <% if (data[i].rt_ow == "Туда и обратно") { %>\

<%=data[i].otkuda %>

\ <% if (data[i].type_destanation == "avia") { %>\

Время вылета самолёта: (время местное)

\ <% } %>\ <% if (data[i].type_destanation == "train") { %>\

Время прибытия поезда: (время местное)

\ <% } %>\ <% if (data[i].type_destanation == "palce" || data[i].type_destanation == "hotel") { %>\
\ \ \ \ \
\ <% } else { %>\ \ <% } %>\ <% if (data[i].type_destanation == "avia") { %>\
\ № рейса / терм: \
\ <% } %>\ <% if (data[i].type_destanation == "train") { %>\
\ \ № поезда вагон: \
\ <% } %>\ <% } %>\
\
\
\ <% } %>\ \ \ ', action_order: '\
\
\
\
\ \ \
\
\
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\ <$ru: Политика защиты персональных данных,en: Personal data security policy$>\
\
\
\
\
\
\
\ \ \ ', hotelOrderTour: '\ <% for (var i in data.hotels) {\ var hotel = data.hotels[i]; \ %>\
\
<%=hotel.HotelName %>
\
\
Город
\
<%=hotel.CityName %>
\
\
\
Заезд
\ <%\ var date_h = hotel.CheckInDate.split("-");\ %>\
<%=date_h[2] %>.<%=date_h[1] %>.<%=date_h[0] %> г., <%=(hotel.Duration-1) %> <%=hotel.nightText %>
\
\
\
Номер
\
<%=hotel.RoomTypeName %>, <%=hotel.RoomCategoryName %>
\
\
\
Питание
\
<%=hotel.MealTypeName %>
\
\
\ <% } %>\ ', universaal_filters: '\
rt-filter-alf <% } else { %> rt-filter-checkbox <% } %>">\ \ \ <% if (filter == "owrt") { %>\
\ \ \
\ <% } %>\ <% if (filter != "owrt") { %><%=name %><% } %>\ \ <% if (filter != "owrt") { %>\
\ <% if (filter == "alf") { %>\ \ \ <% } %>\ <% for (var i in list) { \ if (filter == "alf") {\ %>\
\ \ \
\ <%\ } else if (filter == "status") {\ %>\
\ " type="checkbox" name="filter_<%=type %>_<%=filter %>" value="<%=list[i] %>">\ \
\ <%\ } else if (filter == "type_excurions") {\ %>\
\ " type="checkbox" name="filter_<%=type %>_<%=filter %>" value="<%=list[i] %>">\ \
\ <%\ } else if (filter == "dates") {\ var dates = list[i].split("-");\ if (typeof(dates[1]) != "undefined") { \ %>\
\ \ \
\ <%\ } else { %>\
\ \ \
\ <% }\ } else if (filter == "sale"){\ %>\
\ " >\ \
\ <% } else { %>\
\ \ \
\ <% } %>\ <% } %>\
\ <% } %>\
\ \ ', toursFilter: '\ \
\
\ Стоимость тура\
\ \ \
\
\
\
\
\
\
\ <% if (filter.tour_type.length > 1) {%>\
\ Тип тура\ <% for (var i in filter.tour_type) { %>\
\ \ \
\ <% } %>\
\ <% } %>\ <% if (filter.hotel_cat.length > 1) {%>\
\ Категория отелей\ <% for (var i in filter.hotel_cat) { %>\
\ \ \
\ <% } %>\
\ <% } %>\ <% if (filter.program.length > 1) {%>\
\ Программа тура\ <% for (var i in filter.program) { %>\
\ \ \
\ <% } %>\
\ <% } %>\
\ \ ', tourFindTable: '\ \ \
\
\ \
\ \
\ \
\ \
\ \
\
\
\ \ ', tourFindTableResult: '\ <% for(var i=0; i < data.length; i++){ %>\
\
\ <$ru: Заезд, en: Check in$>\

<%=data[i].CheckInDate %>

\
\
\ <$ru: Ночи, en: Nights $>\

<%=(data[i].Duration-1) %>

\
\
\ <$ru: Размещение, en: Accommodation $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].HotelName %>, <%=data[i].hotels[y].CityName %>

\ <% } %>\ <% } %>\
\
\ <$ru: Тип проживания, en: Accommodation type $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].RoomTypeName %>, <%=data[i].hotels[y].RoomCategoryName %>

\ <% } %>\ <% } %>\
\
\ <$ru: Питание, en: Meal $>\ <% if (data[i].hotels.length > 0) { %>\ <% for (var y in data[i].hotels) {%>\

<%=data[i].hotels[y].MealTypeName %>

\ <% } %>\ <% } %>\
\
\ <$ru: Места, en: Places $>\ <% if (data[i].hotels.length > 0) { %>\ Быстрое подтверждение \ <% } %>\
\
\ \
\ \
\ <% } %>', tourFindTableMini: '\ \
\
\
\ \
\
\ ', buttons: '\ <% if(franch != ""){ %>\ \ <% } %>\ <% if(order_for ==\'tourist\' || order_for ==\'both\'){ %>\ \ <% } %>\    \ <% if(order_for == \'agent\' || order_for==\'both\'){ %>\ \ <% } %>\ <% if(order_for ==\'tourist\'){ %>\

Бронирование отелей для агенств осуществляется через Личный кабинет Агента\
<% } %>\ ', suggestCity: '\ <% for (var i in iata) { %>\ <%=iata[i][0] %> <%=iata[i][2] %>, <%=iata[i][3] %>\ <% } %>\ ', showOffice: '\
\
закрыть
\ \
\ \
\
\ ', showOfficeInCity: '\ \ ', paginators: '\
\ \ <% \ var start = page-2;\ if (start < 1) {\ start = 1;\ }\ var end = parseInt(start)+4;\ if (end > pages) {\ end = pages;\ }\ for (var i=start; i<=end; i++) { %>\ rt-paginator-page-<%=i%>"><%=i%>\ <% } %>\ \
\ \ \ \ ', hotelinfoSearch: '\
\
\
Дата заезда:
\
\ \
\
\
\
Ночей:
\
\ \
\
\
\
Взрослые:
\
\
\
\
\
Дети:
\
\
\
\
\
\
\
\ \
\
\ ', catalogSearchResult: '\ <% numRoom = 0; %>\ <% counter = 0; %>\ <% sum = 0; %>\ <% for(var r=0; r < rooms.length; r++) { %>\ <% counter++; %>\
\
\ <%=rooms[r].roomname%>\
\
\ <%=rooms[r].mealname%>\
\
\ <% if(rooms[r].IsSpo == "true"){ %>
Спецпреложение
<% } %>\ <% if(rooms[r].status == "0"){ %>

Под запрос

<% }else{ %>

Места есть

<% } %>\
\
\ <% for(var y in rooms[r].priceinothercurrency){ \ if(counter == 1 && y == currency) { sum = rooms[r].priceinothercurrency[y]; } \ %>\
\ style="display:none;"<% } %> param="<%=y%>" <% if(counter==1 && y == currency){ %>checked="checked"<% } %>>\ \
\ <% } %>\
\
\ <% } %>\
\
\ <%=sum %> P\
\
\
Заказать
\
\
\ ', hotelinfo2: '\
\
<%=hotel.name %> (<%=hotel.starname %>)
\ \
\ \
\
\ <%=hotel.description %>\ <%=hotel.description_full %>\
\ <% if (typeof(hotel.service) != "undefined") { %>\ <% if (hotel.service.length > 0) { %>\
\

Инфраструктура и профиль

\
    \ <% for (var i in hotel.service) { %>\
  • <%=hotel.service[i] %>
  • \ <% } %>\
\
\ <% } %>\ <% } %>\
\ \ <%=hotel.address%>\
\ <% if (hotel.phone != "") { %>\
\ <%=hotel.phone%>\
\ <% } %>\ <% if(hotel.website){ %>\
\ \ <%=hotel.website%>\
\ <% } %>\
\
\ <% if (hotel.lon != "" && hotel.lon != null) { %>\ \ <% }%>\
\
\
\ ', excursion_info: '\
<%=name %>
\
\
\
\ \
\
\
\
<%=maindescription %>
\
\ <% if (typeof(excursiontype) != "undefined" && excursiontype != "") { %>\ Тип экскурсии: <%=(excursiontype == 2 ? "Пешеходная экскурсия" : (excursiontype == 3 ? "Круизы" : "Автобусная экскурсия")) %>\
\ <% } %>\
\
\ <% if (typeof(durationinbusoneway) != "undefined" && durationinbusoneway != "") { %>\ Вид экскурсии: <%=(durationinbusoneway == "00:02" ? "Групповая" : "Индивидуальная") %>\
\ <% } %>\
\
\ <% if (typeof(routecomplexity) != "undefined" && routecomplexity != "") { %>\ Количество человек: <%=routecomplexity%>\
\ <% } %>\
\
\ <% if (typeof(recommendation) != "undefined" && recommendation != "") { %>\ Время начала: <%=recommendation %>\
\ <% } %>\
\
\ <% if (typeof(rootpoint) != "undefined" && rootpoint != "") { %>\ Место встречи: <%=rootpoint %>\
\ <% } %>\
\ \
\ <% if (typeof(excursionduration) != "undefined" && excursionduration != "") { %>\ Продолжительность: <%=excursionduration%>\
\ <% } %>\
\
\ <% if (typeof(mealdescription) != "undefined" && mealdescription != "") { %>\ Питание: <%=mealdescription %>\
\ <% } %>\
\
\ <% if (typeof(additionalpayments) != "undefined" && additionalpayments != "") { %>\ Дополнительно оплачивается: <%=additionalpayments%>\
\ <% } %>\
\
\
\ \ ', hotelinfo: '\ <% console.log(hotel); %>\
\
<%=hotel.default.NAME %> (<%=hotel.default.CATEGORYNAME %>)
\
\
\ \
\ \
\
\ <%=hotel.default.DESCRIPTION %>\
\
\

Инфраструктура и профиль

\
    \ <% for (var i in hotel.services) { %>\
  • <%=hotel.services[i] %>
  • \ <% } %>\
\
\ <% if (hotel.HotelDescription.length > 0) { %>\
\

Описание отеля

\
    \ <% for (var i in hotel.HotelDescription) { %>\
  • <%=hotel.HotelDescription[i].NAME %>: <%=hotel.HotelDescription[i].TEXT %>
  • \ <% } %>\
\
\ <% } %>\ \
\
\ <% for (var i in hotel.HotelRoomDescriptions) { %>\
\

<%=hotel.HotelRoomDescriptions[i].NAME %>

\ <% if (hotel.HotelRoomDescriptions[i].DESCRIPTION != undefined && hotel.HotelRoomDescriptions[i].DESCRIPTION != "") { %>\

<%=hotel.HotelRoomDescriptions[i].DESCRIPTION %>

\ <% } %>\ <% if (hotel.HotelRoomDescriptions[i].MAINPLACES != undefined && hotel.HotelRoomDescriptions[i].MAINPLACES != "") { %>\

Количество основных мест: <%=hotel.HotelRoomDescriptions[i].MAINPLACES %>

\ <% } %>\ <% if (hotel.HotelRoomDescriptions[i].EXTRAPLACES != undefined && hotel.HotelRoomDescriptions[i].EXTRAPLACES != "") { %>\

Количество дополнительных мест: <%=hotel.HotelRoomDescriptions[i].EXTRAPLACES %>

\ <% } %>\ <% if (hotel.HotelRoomDescriptions[i].AREA != undefined && hotel.HotelRoomDescriptions[i].AREA != "") { %>\

Площадь номера: <%=hotel.HotelRoomDescriptions[i].AREA %> кв.м.

\ <% } %>\ <% if (hotel.HotelRoomDescriptions[i].EQUIPMENT != undefined && hotel.HotelRoomDescriptions[i].EQUIPMENT != "") { %>\

В номере: <%=hotel.HotelRoomDescriptions[i].EQUIPMENT %>

\ <% } %>\ <% if (hotel.HotelRoomDescriptions[i].BATHROOM != undefined && hotel.HotelRoomDescriptions[i].BATHROOM != "") { %>\

Санузел: <%=hotel.HotelRoomDescriptions[i].BATHROOM %>

\ <% } %>\
\ <% var images = hotel.HotelRoomDescriptions[i].Images;\ for (var y in images) { %>\
\ \
\ <% } %>\
\
\ <% } %>\
\
\
\ <% if (hotel.default.GPSLATITUDE != "" && hotel.default.GPSLATITUDE != null) { %>\ \ <% } else if (hotel.default.STREET != "" && hotel.default.STREET != null) { %>\ \ <% } %>\
\
\
\
\ ', offer: '\
\
style="display:none" <% } %>>\
\
\
\ \ ', otherOrderButton: '\
\
\ Добавить в заказ:\
\
\ \ \ \ \
\
\ ', order: '\
закрыть
\
\
\
\
\
\
\ ', passport_block: '\
\
\
\ \
\
\
\ \
\
\
\
\
\
\
\
\
\ \
\ \
\ \ \ ', rt_order_avia_edit: '\
<%=title %>
\
\
\ \ \ ', order_calc: '\
Итого: <%=itogo %> P
\ \ \ \ \ ', order_hotel: '\
\ <% if (typeof(i_code) != "undefined") { %>\ \ <% } else { %>\ \ <% } %>\
\ Заявка на бронирование <%=hotel %>\
\
\
\ Заезд\ <%=start %>\
\
\ Ночей\ <%=night %>\
\
\ Город\ <%=city %>\
\
\ Номер\ <%=room %>\
\
\ Питание\ <%=meal %> \
\
\ Стоимость\ <%=widget.price_avia_order(prices[currency], priceavia, currency) %> <%=widget.icon_currency(currency) %> \
\
\
\ <% if (typeof(cancellation) == "undefined") { %>\ \ <% } else { %>\ <%=widget.render("cancelation",cancellation) %>\ <% } %>\
\
\ \ ', order_transfers: '\
\ <% if (typeof(i_code) != "undefined") { %>\ \ <% } else { %>\ \ <% } %>\
\ Заявка на <%=name %>\
\
\
\ Откуда\ <%=otkuda %>\
\
\ Куда\ <%=kuda %>\
\
\ Направление\ <%=rt_ow %>\
\
\ Дата\ <%=date %>\
\
\ Тип\ <%=types %>\
\
\ Стоимость\ <%=prices[currency] %> <%=widget.icon_currency(currency) %> \
\
\
\
<%=description %>\
\
\ \ ', order_avia: '\
\
\ <% if (typeof(i_code) != "undefined") { %>\ \ <% } else { %>\ \ <% } %>\ <% for (var z in origin) { %>\
\ <%=(z == 0 ? "Туда" : "Обратно") %>: <%=(origin[z].length == 1 ? "Прямой рейс" : "Рейс с пересадками") %>\
\ \ <% for (var y in origin[z]) {\ var fly = origin[z][y];\ var city = fly.fly.split(" - ");\ var hour = " ч. ";\ var country = fly.countries.split(" - ");\ %>\ <% if (fly.timeport) { %>\
\
Пересадка <%=(fly.timeport > 60 ? parseInt(fly.timeport / 60) + hour + (fly.timeport - parseInt(fly.timeport / 60) * 60) : fly.timeport) %> м.
\
\ <% } %>\
\
\
\ \
\
\
\
\
\
\
\
\ <%=city[0] %>\
\
\ <%=country[0] %>\
\
\
\
\
\
<%=fly.time_from %>
\
<%=fly.date_from %>
\
\
\
\
\
\
В пути
\
\
<%=(fly.time > 60 ? parseInt(fly.time / 60) + hour + (fly.time - parseInt(fly.time / 60) * 60) : fly.time) %> м.
\
\
\
\
\
\
<%=fly.time_to %>
\
<%=fly.date_to %>
\
\
\
\
\
\ <%=city[1] %>\
\
\ <%=country[1] %>\
\
\
\
\
\
\ \
\
\
\
\
\
\
\ <% } %>\ <% } %>\ \
\
\ \ ', order_tour: '\
\ <% if (typeof(i_code) != "undefined") { %>\ \ <% } else { %>\ \ <% } %>\
\ Тур: <%=name %>\
\
\
\ Заезд\ <%=start %>\
\
\ Ночи\ <%=night %>\
\
\ Размещение\ <% for (var i in hotels) { %>\

<%=hotels[i].name %>, <%=hotels[i].city %>

\ <% } %>\
\
\ Тип проживания\ <% for (var i in hotels) { %>\

<%=hotels[i].room %>

\ <% } %>\
\
\ Питание\ <% for (var i in hotels) { %>\

<%=hotels[i].meal %>

\ <% } %>\
\
\ \
\ Стоимость: <%=prices[currency] %> <%=widget.icon_currency(currency) %>\
\
\ \ ', order_packet: '\
\
\ Тур: <%=name %>\
\
\
\ Заезд\ <%=start %>\
\
\ Ночи\ <%=night %>\
\
\ Размещение\ <% for (var i in hotels) { %>\

<%=hotels[i].name %>, <%=hotels[i].city %>

\ <% } %>\
\
\ Тип проживания\ <% for (var i in hotels) { %>\

<%=hotels[i].room %>

\ <% } %>\
\
\ Питание\ <% for (var i in hotels) { %>\

<%=hotels[i].meal %>

\ <% } %>\
\
\
\ \ ', order_excursion: '\
\ <% if (typeof(i_code) != "undefined") { %>\ \ <% } else { %>\ \ <% } %>\
\ Экскурсия: <%=name %>. Дата: <%=select_date %>\
\
\ Стоимость: <%=prices[currency] %> <%=widget.icon_currency(currency) %>\
\
\ \ ', cancelation: '\ <% if (status) {%>\ <% if (info != "") {%>\ <%=info %>\ <% } %>\ <% if (today == "1") {%>\ Штраф за отмену брони <%=sum %> <%=currency %>. Особенности уточните у менеджера.
\ Внимание! Автоматическое бронирование для данного заказа отключено, аннуляция заказа возможна только со штрафами.\ <% } else {%>\ Бесплатная отмена бронирования до <%=from %>. После этой даты штраф составит <%=sum %> <%=currency %>. Особенности уточните у менеджера.\ <% } %>\ <% } else { %>\ Просьба уточнить порядок аннуляции и размер штрафных санкций у менеджера по заявке.\ <% } %>\ <% if (typeof(comment ) != "undefined" && comment != "" ) { %>\
<%=comment %>\ <% } %>\ ', avia_order_part: '\ <% var z = 0; %>\ <% for (var i=1; i<=all; i++) { z++; \ var type="inf";\ if (z <= adult) type = "adult";\ if (z <= parseInt(child)+parseInt(adult) && z > adult) type = "child";\ %>\ \
\
\ <%=i %>. <% if (z <= adult) { %>Возраст 12 лет и более <% } %><% if (z <= parseInt(child)+parseInt(adult) && z > adult) { %>Ребёнок (2 - 12 лет) <% } %><% if (z <= parseInt(child)+parseInt(adult)+parseInt(inf) && z > parseInt(child)+parseInt(adult)) { %>Младенец (до 2 лет) <% } %>\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \
\
\
\
\ \ \
\
\
\
\ \
\
\
\
\ \ \ \
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\ <% } %>\ ', order_part: '\ <% var u=0; %>\
\
Взрослые:
\ <% for(var y=0; y < adult; y++){ %>\ <% u++; %>\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \
\
\
\
\ \ \
\
\
\
\
\
\ \ \
\
\
\
\ \ \
\
\
\
\
\
\ \ \
\
\ <% } %>\ \ <% if (child.length > 0) {%>\
Дети:
\ <% } %>\ <% for(var k in child){ %>\ <% u++; %>\
\
\ \ \
\
\
\
\ \ \
\
\
\
\ \
\
\
\
\ \ \
\
\
\ \ \ \
\
\ <% } %>\
\ ', hotelinfoOpers: '\ <% if (hotel.description_full != "") {%>\ \ \ \ \ \ \ \ \ \
\
<%=hotel.name+", "+hotel.starname %>
\
\
\ \ \ \ \ \ \ \ \ \
\ \ \ <% for(var i=0; i < hotel.image.length; i++){ %>\ \ <% } %>\ \ \
\
\
\
\ <%=hotel.description_full%>\
\
\ Инфраструктура:
\ <% for (var i in hotel.service) {%>\ - <%=hotel.service[i] %>
\ <% } %>

\
\ \ <% if (hotel.phone != "") { %>\
\ <%=hotel.phone%>\
\ <% } %>\ <% if(hotel.website){ %>\ \ <% } %>\ \
\
\ <% if (hotel.lon != "" && hotel.lon != null) { %>\ \ <% }%>\ \
\ <% } else {%>\

Информация по отелю в скором времени будет обновлена

\ <% } %>\ ', avia: '\
\
\
\
\ \ \ <% var similar = "";\ var similarcount = 0;\ for(var i in aero){ \ var find = aero[i];\ similarcount = (similar == find.similar ? similarcount + 1 : 0);\ if (similarcount == 1) { %>\ \ <% } %>\ \ \ <% similar = find.similar; %>\ \ \ \ \ \ \ \ \ \ \ \ \ <% for(var w in aero[i].origin) { %>\ \ \ \ <% for(var y in aero[i].origin[w]){ %>\ \ \ \ \ \ \ \ \ \ <% } %>\ <% } %>\
\ \ \ \ \ \
\ <%=aero[i].oper %> <% if (aero[i].oper == "Low-cost") {%> (<%=aero[i].FTNAME %>) <%}%>\
\ \ Макс.время в пути:\ <%=aero[i].timeMax %><$ru:м, en:m$>.\ \
\ <% if (aero[i].return == 1) { %> Билет возвратный <% } %>\ <% if (aero[i].return == 2) { %> Аннуляция билета со штрафами <% } %>\ <% if (aero[i].return == 0) { %> Билет не возвратный <% } %>\
\ <$ru:Перелет, en:Flight$> #1\
\ \ \
\
\ Цена на всех пассажиров, включая\ сборы\ . Ответственный перевозчик:\ <%=aero[i].carrier %>\
\ <% for (y in aero[i].tax) { %>\

<%=aero[i].tax[y].code %> : <%=aero[i].tax[y].sum %> руб.

\ <% } %>\
\
\
\
АвиакомпанияВылетПрилет№ РейсаВ путиКлассМест
\ <$ru:Перелёт, en:Flight$> #<%=w+1 %>\
\ \ \ <%=air[aero[i].origin[w][y].DepartureAirport][<$ru:1, en:0$>] %> (<%=aero[i].origin[w][y].DepartureAirport %>)\
\ <%=aero[i].origin[w][y].DepartureTime %>\ <%=aero[i].origin[w][y].DepartureDate %>\
\ <%=air[aero[i].origin[w][y].ArrivalAirport][<$ru:1, en:0$>] %> (<%=aero[i].origin[w][y].ArrivalAirport %>)\
\ <%=aero[i].origin[w][y].ArrivalTime %>\ <%=aero[i].origin[w][y].ArrivalDate %>\
\ <%=aero[i].origin[w][y].OperatingAirline %> <%=aero[i].origin[w][y].FlightNumber %>\
\ <$ru:Борт, en:Board$>:<%=aero[i].origin[w][y].AirEquipType %>\
<%=aero[i].origin[w][y].airTime %><$ru:м, en:m$>.\ <%=classbrone[aero[i].origin[w][y].OperatingAirline+aero[i].origin[w][y].ResBookDesigCode][2] %>(<%=classbrone[aero[i].origin[w][y].OperatingAirline+aero[i].origin[w][y].ResBookDesigCode][w] %>)\
\ <$ru:<%=aero[i].origin[w][y].Meal %>, en: $>\
<%=aero[i].origin[w][y].SeatsRemaining %>
\ <% } %>\
', }; })(rosstour);(function(rt){ rt.Control.FixedSelect = rt.Control.extend({ construct: function(opts){ var self = this; this.mixin(this.defaults, opts); this.$el = rt.$(''); this.$el.change(self.proxy(self.changed)); }, getValue: function(){ return this.$el.val(); }, setValue: function(v){ this.$el.val(v); } }); rt.Control.Nights = rt.Control.Input.extend({ setDifference: function(){ if(!this.start.dp.date || !this.stop.dp.date){ this.nights.setValue(''); return; } var day = 3600*24*1000; var nights = ((this.stop.dp.date - this.start.dp.date)/day); if(nights < 0){ this.nights.setValue('1'); this.recalculateEnd(); return; } this.nights.setValue(nights); } }); rt.Control.End = rt.Control.Datepicker.extend({ setValueNoChange: function(v){ this.$el[0].value = this.value = v; } }); rt.Widget.Operators = rt.Widget.extend({ name: 'operators', serviceName: 'operators', defaults: function(){ return { templates: this.getTemplates(), order_for: 'tourist', id_agency:'13285', email_agency:'', ip:'82.151.193.208', purchase_url:'', load_opers:'0', version:5, avia_table_min_sum:0, language: 'ru', online:'', tourID:'', tour_type:'', opers:[], online_cart:[], dates_tour:[], dates_tours:{}, tourists_data:{}, min_price:{}, edit_fly:false, searching:false, inside:false, cart:[], stat:{}, show_city:'', avia_structure:{}, avia_min_sum:0, url_search:{}, country_id:{}, avia_table:{}, avia_table_one:{}, tour_avia_table:{}, tour_avia_table_one:{}, no_bg:false, count_search:0, param_search: { avia_for_tour:[], tour:{ 'day':'', 'country_id':'', 'direction_id':'', 'city_avia':'', 'tour_id':'', 'nights':'', 'avia':'', }, universal:{ 'day':'', 'country_id':'', 'region_id':'', 'city_id':'', 'city_avia':'', 'nights':'', 'avia':'', 'sessionid':"d41d8cd98f00b204e9800998ecf8427e", }, tourists:{ adult:2, child:0, }, sessionid:'', }, request: { hotelavia:'', tours:'', hotel:'', avia:'', excursion:'', transfers:'', }, result: { hotelavia:{}, tours:{}, hotel:{}, avia:{}, excursion:{}, transfers:{}, packet:{}, }, lists: { hotelavia:[], tours:[], hotel:[], avia:[], excursion:[], transfers:[], packet:[], }, filters: {}, filters_selected: {}, what_search: [], settings: { tours:{ page:1, setPage:30, }, hotel:{ page:1, setPage:30, }, avia:{ page:1, setPage:30, }, hotelavia:{ page:1, setPage:30, }, excursion:{ page:1, setPage:30, }, transfers:{ page:1, setPage:30, }, packet:{ page:1, setPage:30, }, }, gt_autocomplete_options: { maxSuggestionCount: 4, rightBlockLiDisplayCount: 4, yandexMap: { objectIcon: 'islands#redIcon', clusterIcon: 'islands#redClusterIcons' }, placeholder: true } }; }, reset_results: function() { // this.cart = []; this.online_cart = []; this.settings.tours.page = 1; this.settings.hotel.page = 1; this.settings.avia.page = 1; this.settings.hotelavia.page = 1; this.settings.excursion.page = 1; this.settings.transfers.page = 1; this.searching = true; this.result = { hotelavia:{}, tours:{}, hotel:{}, avia:{}, excursion:{}, transfers:{}, }; this.request = { hotelavia:'', tours:'', hotel:'', avia:'', excursion:'', transfers:'', }; this.lists = { hotelavia:[], tours:[], hotel:[], avia:[], excursion:[], transfers:[], packet:[], } this.filters = { hotelavia:{ stars:[], status:[], alf:[], }, tours:{ chekin:[], status:[], name:[], }, hotel:{ stars:[], status:[], alf:[], }, avia:{}, excursion:{ name:[], cityname:[], }, transfers:{ otkuda_type:[], kuda_type:[], }, }; this.filters_selected = { hotelavia:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, tours:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, packet:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, hotel:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, avia:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, excursion:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, transfers:{ page:1, sort:'price', filters: {}, currency: 'RUR', }, }; this.avia_table_min_sum= { 'all':0, 'one':0, }; }, loadDependencies: function(){ var self = this; var $vers = this.version; var index; this.loading = []; //less2css.php?file= - компилятор less // http://api.ross-tur.ru/less2css.php?file=service/operators/1/css/style.less var css = [ 'http://api.rt.plus/service/reset.css', // 'http://api.ross-tur.ru/less2css.php?file=service/operators/'+$vers+'/css/style.less', // 'http://api.ross-tur.ru/service/operators/'+$vers+'/css/style-css.css', 'http://api.rt.plus/service/widget.css', 'http://api.rt.plus/service/js/themes/blitzer/jquery-uiRT.css', // 'http://api.ross-tur.ru/service/js/periodpicker/jquery.periodpicker.min.css', 'http://api.rt.plus/service/operators/'+$vers+'/css/style-fix.css', ]; var i; for(i=0; i < css.length; i++){ if (!rt.$('link[href="'+css[i]+'"]').length){ rt.$('').appendTo("head"); } } // переключим виджет стран в режим кавказа var CountrySelectorWidget = 'CountrySelectorWidget.js'; if(self.online == 'kavkaz') { CountrySelectorWidget = 'CountrySelectorWidgetKavkaz.js'; } var js = [ //'http://code.jquery.com/jquery-1.10.2.js', 'http://api.rt.plus/service/hotels/jquery.maskedinput.min.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/gt_autocomplete.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/gt_allpages.js', 'http://api.rt.plus/service/js/jquery-ui-1.10.4.custom.min.js', //Избавится от УИ 'http://api.rt.plus/service/operators/'+$vers+'/js/PeopleSelectorWidget.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/'+CountrySelectorWidget, 'http://api.rt.plus/service/operators/'+$vers+'/js/jquery.nstSlider.min.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/NightsSelectorWidget.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/gt_airlines_selector.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/rtNights.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/jquery.selectric.mod.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/jquery.periodpicker.full.min.js', 'http://api.rt.plus/service/operators/'+$vers+'/js/rainbowvis.js', // 'http://api-maps.yandex.ru/2.1/?lang=ru_RU&load=package.full', ]; for(i=0; i < js.length; i++) this.scriptLoad(js[i]); }, scriptLoad: function(url) { var self = this; this.loading.push(url); $.ajax({ url:url, dataType:'script', scriptCharset:'utf-8', async: true, cache:false, success: function() { index = self.loading.indexOf(url); self.loading.splice(index, 1); self.checkAllLoaded(); }, }); }, //fill form with url search params fillFormByHashParams: function(param){ var data = this.getUrlParams(); if(!Object.keys( data).length) return; var params, length; params = ['regions', 'city', 'start', 'stop', 'rooms']; if(typeof(param) != 'undefined' && params.indexOf(param) >= 0) params = [param]; for(var x=0; x < params.length; x++){ param = params[x]; if(param == 'rooms'){ if(typeof(data.rooms) != 'undefined' && Object.keys( data.rooms).length){ for(var i in data.rooms){ if( typeof(data.rooms[i].quantity) != 'undefined' && typeof(data.rooms[i].adult) != 'undefined' && typeof(data.rooms[i].children) != 'undefined' && parseInt(data.rooms[i].quantity) && parseInt(data.rooms[i].adult) ){ this.rooms[parseInt(i)-1].checked.prop('checked', true); this.showRoomControls(parseInt(i)-1); this.rooms[parseInt(i)-1].adult.setValue(parseInt(data.rooms[i].adult)); this.rooms[parseInt(i)-1].quantity.setValue(parseInt(data.rooms[i].quantity)); length = Object.keys( data.rooms[i].children ).length; if(length){ this.rooms[parseInt(i)-1].children.setValue(length); this.addAgeControls(parseInt(i)-1); for(var j in data.rooms[i].children){ this.addAgeControls(parseInt(i)-1); this.rooms[parseInt(i)-1].ages[parseInt(j)-1].setValue( data.rooms[i].children[j] ); } } } this.room.adult.setValue(parseInt(data.rooms[i].adult)); } } } else if(typeof(data[param]) != 'undefined' && this[param].getValue().toString() != data[param].toString()){ if(['start', 'stop'].indexOf(param) >= 0){ if(!/[0-3][0-9]\.[0-1][0-9]\.20[1-2][0-9]/.test(data[param])) continue; } if(['city'].indexOf(param) >= 0){ this[param].$el.val(data[param]); this[param].setValue(this[param].$el.val()); } else { this[param].setValue(data[param], true); } } } if(this.start.getValue() && this.stop.getValue()){ this.$host.find('.start #rt-hotel-start').val(this.start.getValue()); this.$host.find('.stop #rt-hotel-stop').val(this.stop.getValue()); (this.proxy(this.nights.setDifference))(); } return true; }, //set url according to search params setHashParams: function(data){ var string = []; for(var i in data){ if(i == 'nights') continue; if(i == 'rooms'){ for(var j=0; j < data.rooms.length; j++){ string.push('rooms['+(j+1)+'][adult]='+data.rooms[j]['adult']); string.push('rooms['+(j+1)+'][quantity]='+data.rooms[j]['quantity']); for(var c=0; c < data.rooms[j]['children'].length; c++){ string.push('rooms['+(j+1)+'][children]['+(c+1)+']='+data.rooms[j].children[c]); } } } else string.push(i+'='+data[i]); } return string.join('&'); }, //get search params from url hash getUrlParams: function(){ var data={}, tmp, i, matches, obj; var hash = window.location.hash.toString(); if(hash && hash.length > 1){ hash = hash.slice(1); hash = hash.split("&"); if(hash.length){ for(i = 0; i < hash.length; i++){ tmp = hash[i].split("="); if(tmp.length == 2){ tmp[0] = decodeURIComponent(tmp[0]); tmp[1] = decodeURIComponent(tmp[1]); matches = /([^\[\]]+)\[([^\[\]]+)\](\[([^\[\]]+)\])?(\[([^\[\]]+)\])?/.exec(tmp[0]); //rooms = {1: {adult: 7}} if(matches){ if(typeof(data[matches[1]]) == 'undefined'){ data[matches[1]] = {}; } if(typeof(matches[4])!='undefined'){ if(typeof(data[matches[1]][matches[2]]) == 'undefined'){ data[matches[1]][matches[2]] = {}; } if(typeof(matches[6])!='undefined'){ if(typeof(data[matches[1]][matches[2]][matches[4]])=='undefined'){ data[matches[1]][matches[2]][matches[4]] = {}; } data[matches[1]][matches[2]][matches[4]][matches[6]] = tmp[1]; } else data[matches[1]][matches[2]][matches[4]] = tmp[1]; } else data[matches[1]][matches[2]] = tmp[1]; } else data[tmp[0]] = tmp[1]; } } } } return data; }, checkAllLoaded: function(deffered){//если не загружены зависимости, функция deffered будет вызвана после загрузки; if(!rt.$.isArray(this.loading)){ this.loadDependencies(); } if(this.loading.length){ if(typeof(deffered) == 'function') this.afterLoading = deffered; return false; } if(typeof(this.afterLoading) == 'function') { deffered = this.afterLoading; this.afterLoading = false; deffered.call(); } return true; }, makeControl: function(Control, opts){ var self = this; var opts = opts || {}; var after = opts.after || function(){}; var control; var makeRequest = opts.dependsOn ? this.getExtractor(opts.dependsOn) : function(){return {}}; control = new Control(rt.$.extend({ loader:new rt.Loader.Ajax(rt.$.extend({ widget:this, method:opts.method, makeRequest:makeRequest }, opts.loaderOpts || {})), onChange:after, onUpdate:after },opts.controlOpts || {})); return control; }, getExtractor: function(fieldnames){ var self = this; return function(){ var res = { }; for(var i in fieldnames){ if(fieldnames[i] == 'city_id') { res.city_id = self.param_search.universal.city_id;} else if(fieldnames[i] == 'country_id') { res.country_id = self.param_search.universal.country_id;} else if(fieldnames[i] == 'noall') { res.noall = self.noall = 1;} else if(fieldnames[i] == 'action') { res.action = self.action;} else if(fieldnames[i] == 'code' && self.set.code != 0) { res.regions = self.set.code; res.noall = 1;} else if(typeof(self[fieldnames[i]]) != 'undefined' && typeof(self[fieldnames[i]].getValue()) != 'undefined') res[fieldnames[i]] = self[fieldnames[i]].getValue(); } if (res.regions && self.cityAdd == '' && (self.action == 'excursion' || self.action == 'transfer')) res.regions = undefined; return res; }; }, init: function(){ // alert(); // delete Array.prototype.max; // delete Array.prototype.min; this.lang = rt.lang = this.language; // alert(this.lang); var self = this; // if (this.online == 'inside') document.location.href = 'http://online-rosstour.ru/searchForm/incoming.php'; this.appendSearchControls(); var $navigation = false; this.$host.html(this.render('main',{'navigation':$navigation})); }, appendSearchControls: function(){ var self = this; self.$host.find('.startLoader').hide(); self.$host.find('.main').show(); if(!self.checkAllLoaded(self.proxy(self.appendSearchControls))) return false; // setTimeout(function() { // },1000); this.variable(); this.$host.find('div.buttonSearch').on('click', self.proxy(self.search)); this.search_check_param(); $.mask.definitions = { 9: "[0-9]", b: "[A-Za-zА-Яа-я]", r: "[А-Яа-я]", a: "[A-Za-z]", d: "[A-Za-z0-9]", o: "[0123]", n: "[12]", e: "[90]", m: "[01]", "*": "[A-Za-zА-Яа-я0-9]", }; this.showSearcheTour(); // setTimeout(function() { // },950); }, search_check_param: function() { var self = this; this.$host.find('#rt-search-param').on('click',function() { if (self.$host.find('.search-param').is(':visible')) { self.$host.find('.search-param').animate({height: "hide"}, 240); } else { self.$host.find('.search-param').animate({height: "show"}, 240); } return false; }); }, variable: function() { this.hotel_search_form = this.$host.find('.hotel_search_form').eq(0); this.getCourses(); this.rooms = []; this.disabled = false; this.overlay = this.$host.find('.hotels_search_overlay').eq(0); this.overlayOffice = this.$host.find('.hotels_office_overlay').eq(0); this.overlayAlert = this.$host.find('.hotels_alert_overlay').eq(0); this.overlaySelect = this.$host.find('.hotels_selection_overlay').eq(0); this.peneality = {}; this.sid = ''; this.set = { link:'', start:false, latlon:'', aviaSid:'', map_container:'map', avia:'1', error:'', } this.maps = { cityArray: [], }; //Исключить фильтр по лечению в регионах и гороадх this.includeMedFilterRigons = [18,14,81,9,10,12,11]; this.includeMedFilterCity = [246,477,9,316,335,601,12,602,10,469,14,13,404,603,11,588,597,589,92,647,654,649,658,659,651,661,653,656,655,645,652,660,648,650,644,646,249,245,240,662,572,440,439,434,443,447,461,480,441,435,446,271,273,268]; }, alert: function(msg) { var self = this; this.showOverlayAlert(); this.$host.find('#alert').html(this.render('alert',{'msg':msg})); var top = rt.$(window).scrollTop(); var l = $('.hotel_search_form').position().left; var width = $('.hotel_search_form').width(); var margin = (width-300)/2; this.$host.find('#alert').css('top', (top+200)+'px'); //this.$host.find('#alert').css('left', l+'px'); if (margin > 0) this.$host.find('#alert').css('margin-left', margin+'px'); this.$host.find('#alert').animate({height: "show"}, 500); this.$host.find('#alert button').on('click', function() { self.$host.find('#alert').animate({height: "hide"}, 500); self.overlayAlert.hide(); }); }, confirm: function(msg, func) { var self = this; this.showOverlayAlert(); this.$host.find('#alert').html(this.render('confirm',{'msg':msg})); var top = rt.$(window).scrollTop(); var l = $('.hotel_search_form').position().left; var width = $('.hotel_search_form').width(); var margin = (width-300)/2; this.$host.find('#alert').css('top', (top+200)+'px'); //this.$host.find('#alert').css('left', l+'px'); if (margin > 0) this.$host.find('#alert').css('margin-left', margin+'px'); this.$host.find('#alert').animate({height: "show"}, 500); this.$host.find('#alert .confirm-no').on('click', function() { self.$host.find('#alert').animate({height: "hide"}, 500); self.overlayAlert.hide(); }); // this.$host.find('#alert .confirm-yes').on('click', function() { // self.$host.find('#alert').animate({height: "hide"}, 500); // self.overlayAlert.hide(); // self.show_table_other_date(); // }); this.$host.find('#alert .confirm-yes').on('click', func); }, showHoteInfo: function() { var self = this; this.$host.find('.hotel_search_form').hide(); if (this.hotelID == '') return false; this.get('hotelInfo',{hotel:this.hotelID, version:this.version}).then(function(data) { self.HotelInfo(data); self.overlay.hide(); self.$host.find('#close_order_dialog').hide(); self.$host.find('.infoHotelSite').hide(); self.order_holder.css({'top':'0','margin-left':'0','position':'relative'}); }); }, showExcursionInfo: function() { var self = this; this.$host.find('.hotel_search_form').hide(); if (this.hotelID == '') return false; this.get('offerExcursion',{id:this.hotelID, version:this.version}).then(function(data) { self.showOrderHolder(self.render('order')); self.order_holder.find('#passport').html(data); self.overlay.hide(); self.$host.find('#close_order_dialog').hide(); self.$host.find('.infoHotelSite').hide(); self.order_holder.css({'top':'0','margin-left':'0','position':'relative'}); }); }, getFullHotelInfo: function(id,showSearch) { var self = this; this.hotelinfoId = id; this.get('hotelInfo',{hotel:id,version:this.version}).then(function(data) { self.HotelInfo(data,showSearch); }); }, hotelinfoSearch:function(show) { if (!show) { this.order_holder.find('#passport .hotelinfoSearch').remove(); return false; } this.order_holder.find('#passport .hotelinfoSearch').html(this.render('hotelinfoSearch')); this.order_holder.find('.hotelinfoSearch-date').datepicker().val(this.recalculateEnd("4")); this.order_holder.find('.hotelinfoSearch-date').datepicker("option",{ "minDate":"4", beforeShow: function() {$('#ui-datepicker-div').css('z-index','15'); }, }); this.order_holder.find('.hotelinfoSearch-night').val(1).mask('9?9'); this.hotelinfoSearchAdult = this.makeControl(rt.Control.AdultSelect); this.hotelinfoSearchChild = this.makeControl(rt.Control.ChildrenSelect,{after: this.proxy(this.hotelinfoSearchChildParam)}); this.hotelinfoSearchAdult.$el.appendTo(this.order_holder.find('.hotelinfoSearchAdult .control')); this.hotelinfoSearchChild.$el.appendTo(this.order_holder.find('.hotelinfoSearchChild .control')); this.order_holder.find('.hotelinfoSearch select').selectric(); this.order_holder.find('.hotelinfoSearchBtn').on('click',this.proxy(this.hotelinfoSearchBtn)); }, hotelinfoSearchBtn: function() { var self = this; var $region = this.catalogRegions.getValue(); var $date = this.order_holder.find('.hotelinfoSearch-date').val(); var $night = this.order_holder.find('.hotelinfoSearch-night').val(); var $hotel_id = this.hotelinfoId; this.order_holder.find('.catalogSearchResult').html(''); this.get('searchHotelCatalog',{ 'region':$region, 'start':$date, 'night':$night, 'hotel_id':$hotel_id, 'adult':this.hotelinfoSearchAdult.getValue(), 'child':this.hotelinfoSearchChildRes(), }).then(function(data) { self.hotelSearcheResult(data); }); }, hotelinfoSearchChildRes: function() { var $count = this.hotelinfoSearchChild.getValue(); if ($count == 0) { return 0; } var $res = []; this.order_holder.find('.hotelinfoSearchChildParam select').each(function() { $res.push($(this).val()); }); return $res.join(','); }, hotelSearcheResult:function(data) { if (data.find[0] == undefined) { this.order_holder.find('.catalogSearchResult').html('По заданным параметрам вариантов размещения не найдено'); return false; } this.catalogHotelRoom = 1; var self = this; this.order_holder.find('.catalogSearchResult').html(this.render('catalogSearchResult',{'rooms':data.find[data.catalogHotel].room,'currency':'RUR','i':data.catalogHotel})); this.order_holder.find('label.pioc').on('click',function() { self.order_holder.find('.catalogHotelPrice').html($(this).html()); self.catalogHotelRoom = $(this).attr('tnumber'); }); this.order_holder.find('.catalogOrderButton').on('click',function() { self.set.avia = 0; for(var i = 0; i < data.find.length; i++){ data.find[i] = self.sortRoomsResults(data.find[i]); } self.list = data.find; self.sid = data.sessionid; self.dataform = data.dataform; self.order(data.find[data.catalogHotel]); self.order_holder.find('#tabs ul a').eq(0).click(); }); }, hotelinfoSearchChildParam: function() { var $counAdult = this.hotelinfoSearchChild.getValue(); this.order_holder.find('.hotelinfoSearchChildParam .control').html(''); if ($counAdult > 0) { for(var j=0; j < $counAdult; j++){ age_select = this.makeControl(rt.Control.AgeSelect); this.order_holder.find('.hotelinfoSearchChildParam .control').append(age_select.$el); this.order_holder.find('.hotelinfoSearchChildParam select').selectric(); } } }, referenceCat: function() { var $res = {}; if (this.catalogCategories != undefined) { for (var i in this.catalogCategories.items) { $res[this.catalogCategories.items[i].code] = this.catalogCategories.items[i].name; } } else if (this.categories != undefined) { for (var i in this.categories.items) { $res[this.categories.items[i].code] = this.categories.items[i].name; } } else if (this.TourHotelCategories != undefined) { for (var i in this.TourHotelCategories.items) { $res[this.TourHotelCategories.items[i].code] = this.TourHotelCategories.items[i].name; } } l($res); return $res; }, HotelInfo: function(list_item,showSearch){ this.showOrderHolder(this.render('order')); var self = this; // $cat = this.referenceCat(); var data = {'hotel':list_item,'cat':''}; this.order_holder.find('#passport').html(this.render('hotelinfo', data)); this.order_holder.find('#passport #hotelinfo-tabs').tabs(); this.hotelinfoSearch(showSearch); // this.maps.cityArray = []; // this.maps.cityArray.push([list_item.default.Street,list_item.default.Name,'',list_item.Images[0]]); // this.map_container = 'hotel-map'; this.order_holder.find('.hotelinfo-gallery-item').on('click', function() { self.order_holder.find('.hotelinfo-gallery-item').removeClass('active'); $(this).addClass('active'); var $img = $(this).attr('src:full'); var $hint = $(this).attr('src:hint'); self.order_holder.find('.hotelinfo-gallery-big').attr('src',$img); self.order_holder.find('.catalog-hint').html($hint); }); this.order_holder.find('.hotelinfo-gallery-block .col-xs-6:first-child .hotelinfo-gallery-item').click(); if (this.action != undefined) { // this.showMaps(); } }, HotelInfoOffer: function(list_item){ this.showOrderHolder(this.render('order')); var self = this; var data = {'hotel':list_item}; this.order_holder.find('#passport').html(this.render('hotelinfo2', data)); this.order_holder.find('#passport #hotelinfo-tabs').tabs(); this.order_holder.find('.hotelinfo-gallery-item').on('click', function() { self.order_holder.find('.hotelinfo-gallery-item').removeClass('active'); $(this).addClass('active'); var $img = $(this).attr('src:full'); var $hint = $(this).attr('src:hint'); self.order_holder.find('.hotelinfo-gallery-big').attr('src',$img); self.order_holder.find('.catalog-hint').html($hint); }); this.order_holder.find('.hotelinfo-gallery-block .col-xs-6:first-child .hotelinfo-gallery-item').click(); }, HotelInfoAlean: function(list_item) { var self = this; }, showSearcheTour: function() { this.action = "tour"; this.setTour = { 'v':'new', 'count':'30', 'page':'1', }; this.$host.find('.container').removeClass('container'); this.$host.find('.forms_search #searchTour').addClass('active'); this.$host.find('.input_form_tour').show(); this.$host.find('.tours').show(); if (this.param_search.tour.tour_id != '') { if (this.$host.find('.input_form_tour').html() == "") this.$host.find('.input_form_tour').html(this.render('searchTour')); } else { if (this.$host.find('.input_form_tour').html() == "") this.$host.find('.input_form_tour').html(this.render('searchTourCategory')); } this.addFormTour(); }, addFormTour:function() { if (this.tour) return; var self = this; this.tour = this.$host.find('.input_form_tour'); this.universal = this.$host.find('.input_form_tour'); var first = true; var init = true; this.tourCalendar = this.$host.find('#rt-search-date'); this.$host.find('#rt-tour-avia').GTAutocomplete(this.gt_autocomplete_options); this.iataGoodTravelAction(); // alert(); $(document).on('gta-init', function(event, data, suggestionValue) { data = { airport_name:"", city_iata:"", city_name:"Без перелёта", code:"ru", code_cyr:"ru", country_code:"ru", country_name:"", }; suggestionValue = { 'code': '', 'name': 'Без перелёта', 'country_name': '', 'country_code': 'ru' }; var result = suggestionValue.name + ' ' + suggestionValue.country_name; self.tour.find('#rt-tour-avia').GTAutocomplete('change', data).val(result); self.tour.find('#rt-tour-avia').attr('data-value', JSON.stringify(suggestionValue)); }); var $n = ['','ь','и','и','и','ей']; var $now = new rt.Date(); this.tourCalendar.periodpicker({ end: '#rt-search-date-stop', lang: 'ru', cells: [1, 2], yearsLine: false, fullsizeButton: false, formatDate: 'DD.MM.YYYY', formatDecoreDateWithYear: 'D MMMM', minDate: $now.format('d.m.Y'), i18n: { 'ru' : { 'Select period' : 'Дата вылета', 'Choose period' : '' } }, onAfterShow: function () { $('#rt-search-date').parents('.search-block-item').find('.period_picker_input').removeClass('rt-error'); $('#rt-search-date').parents('.search-block-item').find('label').addClass('rt-label-open'); }, onAfterHide: function () { if(this.startinput.val() == "") { $('#rt-search-date').parents('.search-block-item').find('label').removeClass('rt-label-open'); } else { if (this.period[0] != undefined) { self.param_search.tour.day = this.period[0].format('DD.MM.YYYY')+','+this.period[1].format('DD.MM.YYYY'); } } }, onAfterRegenerate: function() { self.highligth_date(); }, }); // console.log(self.param_search.tourists.adult); var $button = document.querySelector('#rt-search-people'); //Создаем экземпляр класса диалога var psw = new PeopleSelectorWidget({ $container: document.querySelector('.search-block-people'), onInit: function(adults, children, displayedValue) { self.param_search.tourists.adult = adults; self.param_search.tourists.child = children; $button.innerHTML = displayedValue; }, onChange: function(adults, children, displayedValue) { self.param_search.tourists.adult = adults; self.param_search.tourists.child = children; $button.innerHTML = displayedValue; }, onOpen: function() { self.$host.find('#rt-search-people').addClass('bt-open');}, onClose: function() { self.$host.find('#rt-search-people').removeClass('bt-open'); }, adults: self.param_search.tourists.adult, children: [] }); this.tour.find('#rt-tour-search').on('click',this.proxy(this.tourSearch)); if (this.param_search.tour.tour_id != '') { this.showTourForParams(); this.highligth_get_date(); } if (this.param_search.tour.tour_id == '') { this.showTourForParamsCategory(); } // alert(typeof(this.tour)); }, showTourForParamsCategory: function() { var self = this; this.universalGeography = new CountrySelectorWidget({ $container: $('.search-blocks .dst'), type: 'tours', onChange: function(value) { $('#rt-tour-country').html('
'+ (value.city ? ' ' + value.city.name + ' ' : '') + value.country.name ); self.param_search.tour.country_id = value.country.code; self.param_search.universal.country_id = value.country.code; // alert(); if (value.city) { self.param_search.tour.direction_id = value.city.code; self.param_search.tour.city_avia = value.city.iata; } if (!value.city) { self.param_search.tour.direction_id = 0; } } }); this.universalGeography.setValue({ countryID: this.param_search.tour.country_id, cityID: this.param_search.tour.direction_id, }, function (value) { self.$host.find('.search-blocks .dst label').addClass('rt-label-open'); // alert(); // setTimeout(function() { // self.param_search.universal.day = self.universalCalendar.val()+','+self.universal.find('#rt-search-date-stop').val(); // self.universalSearch(); // },500); }); var $n = ['','ь','и','и','и','ей']; var $tourNights = this.tour.find('#rt-tour-nights-item'); this.tourNightsWidget = new NightsSelectorWidget({ $container: this.tour.find('.rt-tour-nights'), values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], value: {from: 4, to: 4}, maxDiff: 2, onInit: function(from, to) { $sk = 'ей'; if (to <6) { $sk = $n[to]; } $tourNights.html(from + (from !== to ? ' - ' + to : '')+' ноч'+$sk); if (self.param_search.tour.nights == '') { self.param_search.tour.nights = from+','+to; } }, onChange: function(from, to) { $sk = 'ей'; if (to <6) { $sk = $n[to]; } $tourNights.html(from + (from !== to ? ' - ' + to : '')+' ноч'+$sk); self.param_search.tour.nights = from+','+to; }, onOpen: function() { }, onClose: function() { } }); this.tourCalendar.val('01.05.2024'); this.tour.find('#rt-search-date-stop').val('01.05.2024'); this.tourCalendar.periodpicker('change').prev().addClass('rt-label-open'); this.set.avia = 0; this.tour.find('.GTAPlaceholder').html('\
\
Без перелёта
\ '); }, tourInit: function($param) { var self = this; this.get('tourInit',{ country_id:$param.country[0], direction_id:$param.direction[0], }).then(function(data) { if (data.Date.length == 0) {; return false; } self.$host.find('#rt-search-date').periodpicker('setOptions',{ disableDays: data.Date, formatDate: 'DD.MM.YYYY' }); self.tourNightsWidget.setValues(data.Duration); self.tourCalendar.val(data.DateMin) self.tour.find('#rt-search-date-stop').val(data.DateMin) self.tourCalendar.periodpicker('change').prev().addClass('rt-label-open'); }); }, tourSearch: function() { var self = this; // console.log(1); if (this.stopTourSeaarch()) { return false; } this.stat = {}; this.$host.find('.rt-button-searche').html('
'+this.trans('<$ru: Поиск, en: Searching $>')+'
').addClass('buttonSearchProces'); this.stat.tours = 0; this.reset_results(); this.data_form = this.param_search.tourists; this.country_id = this.param_search.tour.country_id; // alert(); this.searching = true; this.showUniversalMaket(); // this.$host.find('a[href="#rt-universal-tours"]').click(); this.$host.find('.rt-universal-left').hide(); this.$host.find('.rt-universal-right').addClass('mini-tours'); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-tours']").parent().addClass('rt-active').siblings().removeClass('rt-active'); this.$host.find('#rt-universal-tours').addClass('rt-active').siblings().removeClass('rt-active'); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-hotelavia']").parent().hide(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-hotel']").parent().hide(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-avia']").parent().hide(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-excursion']").parent().hide(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-transfers']").parent().hide(); this.post('getRequestsTour',this.querySearch()).then(function(data) { if (data.tours.length > 0) { self.searching = false; self.lists.tours = data.tours; if (typeof(data.avia) != 'undefined') { self.lists.avia = data.avia; } self.filters.tours = data.filter.tours; self.show_result_for_all('tours'); self.hide_find_tours(); } else { self.alert('Туров не найдено.'); } self.$host.find('.rt-button-searche').html(self.trans('<$ru: ПОИСК, en: Search $>')).removeClass('buttonSearchProces'); }); }, hide_find_tours: function() { var self = this; this.$host.find('.universal').show(); this.$host.find('.rt-universal').css('margin',0); this.show_filter(); this.$host.find('.rt-universal-filters-info').hide(); this.$host.find('.rt-universal-filters .rt-universal-filter:nth-child(2)').hide(); this.$host.find('.rt-universal-filters .rt-universal-filter:nth-child(3)').hide(); var i = 0; this.$host.find('.rt-tours-table-item').each(function() { i++; if (i > 5) { $(this).hide(); } }); if (i > 5) { this.$host.find('.rt-show-rest-tours').css('display','block'); } }, stopTourSeaarch: function() { // l(this.param_search.direction_id); if (this.param_search.tour.direction_id == '') { this.$host.find('.rt-country-select').addClass('rt-error'); return true; } if (this.param_search.tour.day == '') { this.$host.find('.period_picker_input').addClass('rt-error'); return true; } this.$host.find('.period_picker_input, .rt-country-select').removeClass('rt-error'); return false; }, getParamSearchTour: function() { var $res = this.param_search.tour; $res.tourists = this.param_search.tourists; $res.sessionid = this.param_search.sessionid; if (this.set.avia == 1) { var elem = this.tour.find('#rt-tour-avia'); l(elem.attr('data-value')); var locationObj = JSON.parse(elem.attr('data-value')); $res.avia = locationObj.code+":"+$res.direction_avia; } else { $res.avia = ''; } return $res; }, showTourForParams: function() { var self = this; this.$host.find('.forms_search').hide(); var tour = []; this.set.avia = 0; var $days = this.param_search.tour.day.split(','); var $nights = this.param_search.tour.nights.split(','); this.tourCalendar.val($days[0]); this.tour.find('#rt-search-date-stop').val($days[0]); this.tourCalendar.periodpicker('change').prev().addClass('rt-label-open'); this.tour.find('#rt-tour-search').html('Расчитать'); this.tourSearch(); }, showSearcheUniversal: function() { // console.log(document.location.host); this.action = "universal"; this.setTour = { 'v':'new', 'count':'30', 'page':'1', }; this.$host.find('.input_form_universal').show(); this.$host.find('.universal').show(); this.check_url(); if (this.$host.find('.input_form_universal').html() == "") this.$host.find('.input_form_universal').html(this.render('searchUniversal')); this.addFormUniversal(); this.search_check_param(); }, check_url: function() { var $url = document.location.search.substr(1); var $res = {}; if($url != '') { $url = $url.split('&'); for (var i in $url) { var $temp = $url[i].split('='); $res[$temp[0]] = $temp[1]; } } if (typeof($res.country_id) != 'undefined' && typeof($res.city_id) != 'undefined') { this.url_search = $res; } }, checked_param: function(type) { var res = 'checked'; if (typeof(this.url_search.show) != 'undefined' && this.url_search.show != type) { res = ''; } if (typeof(this.url_search.show) != 'undefined' && 'avia' == type && typeof(this.url_search.departure_iata) != 'undefined') { res = 'checked'; } // alert(); // console.log(typeof(this.url_search.show)); // console.log(res); return res; }, addFormUniversal:function() { if (this.universal) return; var self = this; this.universal = this.$host.find('.input_form_universal'); var first = true; var init = true; this.universalCalendar = this.universal.find('#rt-search-date'); this.universal.find('#rt-tour-avia').GTAutocomplete(this.gt_autocomplete_options); this.iataGoodTravelAction(); $(document).on('gta-init', function(event, data, suggestionValue) { var result = suggestionValue.name + ' (' + suggestionValue.code + '), ' + suggestionValue.country_name; self.universal.find('#rt-tour-avia').GTAutocomplete('change', data).val(result); self.universal.find('#rt-tour-avia').attr('data-value', JSON.stringify(suggestionValue)); }); var $n = ['','ь','и','и','и','ей']; var $tourNights = this.universal.find('#rt-tour-nights-item'); this.tourNightsWidget = new NightsSelectorWidget({ $container: this.universal.find('.rt-tour-nights'), values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30], value: {from: 2, to: 2}, maxDiff: 2, onInit: function(from, to) { $sk = 'ей'; if (to <6) { $sk = $n[to]; } $tourNights.html(from + (from !== to ? ' - ' + to : '')+' ноч'+$sk); if (self.param_search.universal.nights == '') { self.param_search.universal.nights = from+','+to; } }, onChange: function(from, to) { $sk = 'ей'; if (to <6) { $sk = $n[to]; } $tourNights.html(from + (from !== to ? ' - ' + to : '')+' ноч'+$sk); self.param_search.universal.nights = from+','+to; }, onOpen: function() { }, onClose: function() { } }); // this.tourNightsWidget.setValue({from: 5, to: 5},true); this.universalGeography = new CountrySelectorWidget({ $container: $('.search-blocks .dst'), type: 'hotels', onChange: function(value) { $('#rt-tour-country').html('
'+ (value.region && !value.city ? '' + value.region.name + ' ' : '') + (value.city ? ' ' + value.city.name + ' ' : '') + value.country.name ); self.param_search.universal.country_id = value.country.code; // console.log(value); if (value.region) { self.param_search.universal.region_id = value.region.code; self.param_search.universal.city_avia = value.region.iata; self.show_city = value.region.name; } if (value.city) { self.param_search.universal.city_id = value.city.code; self.param_search.universal.city_avia = value.city.iata; self.show_city = value.city.name; } if (!value.city) { self.param_search.universal.city_id = 0; } self.highligth_get_date(); } }); var $now = new rt.Date(); this.universalCalendar.periodpicker({ end: '#rt-search-date-stop', lang: 'ru', cells: [1, 2], hideOnBlur: true, yearsLine: false, fullsizeButton: false, formatDate: 'DD.MM.YYYY', formatDecoreDateWithYear: 'D MMMM', minDate: $now.format('d.m.Y'), i18n: { 'ru' : { 'Select period' : 'Дата вылета', 'Choose period' : '' } }, onAfterShow: function () { $('#rt-search-date').parents('.search-block-item').find('.period_picker_input').removeClass('rt-error'); $('#rt-search-date').parents('.search-block-item').find('label').addClass('rt-label-open'); }, onAfterHide: function () { if(this.startinput.val() == "") { $('#rt-search-date').parents('.search-block-item').find('label').removeClass('rt-label-open'); } else { if (this.period[0] != undefined) { self.param_search.universal.day = this.period[0].format('DD.MM.YYYY')+','+this.period[1].format('DD.MM.YYYY'); self.getNights(this.period[0].format('YYYY/MM/DD'),this.period[1].format('YYYY/MM/DD')); } } }, onAfterRegenerate: function() { self.highligth_date(); }, }); var $button = document.querySelector('#rt-search-people'); //Создаем экземпляр класса диалога var psw = new PeopleSelectorWidget({ $container: document.querySelector('.search-block-people'), onInit: function(adults, children, displayedValue) { self.param_search.tourists.adult = adults; self.param_search.tourists.child = children; $button.innerHTML = displayedValue; }, onChange: function(adults, children, displayedValue) { self.param_search.tourists.adult = adults; self.param_search.tourists.child = children; $button.innerHTML = displayedValue; }, onOpen: function() {self.$host.find('#rt-search-people').addClass('bt-open');}, onClose: function() {self.$host.find('#rt-search-people').removeClass('bt-open'); }, adults: 2, children: [] }); this.universal.find('.rt-button-searche').on('click',this.proxy(this.universalSearch)); if (typeof(this.url_search.night) != 'undefined') { this.tourNightsWidget.setValue({from: this.url_search.night, to: this.url_search.night},false); } if (typeof(this.url_search.adult) != 'undefined') { this.param_search.tourists.adult = this.url_search.adult; } if (typeof(this.url_search.child) != 'undefined') { this.param_search.tourists.child = this.url_search.child.split(','); } if (typeof(this.url_search.date) != 'undefined') { var $firts_date = this.url_search.date; } else { var $firts_date = '30.04.2024'; } if (typeof(this.url_search.departure_iata) != 'undefined') { $.fn.GTAutocomplete.getCodesInfo([ this.url_search.departure_iata], function(codesInfo, suggestionValues) { self.universal.find('#rt-tour-avia').GTAutocomplete('change', codesInfo[self.url_search.departure_iata]); self.universal.find('#rt-tour-avia').data('value','{"code":"'+codesInfo[self.url_search.departure_iata].code+'","name":"'+codesInfo[self.url_search.departure_iata].city_name+'","country_name":"Россия","country_code":"ru"}') self.universal.find('#rt-tour-avia').attr('data-value','{"code":"'+codesInfo[self.url_search.departure_iata].code+'","name":"'+codesInfo[self.url_search.departure_iata].city_name+'","country_name":"Россия","country_code":"ru"}') }); } this.universalCalendar.val($firts_date) this.universal.find('#rt-search-date-stop').val($firts_date) this.universalCalendar.periodpicker('change').prev().addClass('rt-label-open'); if (typeof(this.url_search.country_id) != 'undefined') { this.universalGeography.setValue({ countryID: this.url_search.country_id, cityID: this.url_search.city_id, }, function (value) { self.$host.find('.search-blocks .dst label').addClass('rt-label-open'); if (typeof(self.no_fly) != 'undefined') { self.set.avia = 0; self.universal.find('.GTAPlaceholder .name').html('Без перелёт'); } setTimeout(function() { self.param_search.universal.day = self.universalCalendar.val()+','+self.universal.find('#rt-search-date-stop').val(); self.universalSearch(); },500); }); } else { this.universalGeography.setValue({ countryID: 1, cityID: 214, }, function (value) { self.$host.find('.search-blocks .dst label').addClass('rt-label-open'); }); } // $(document).on('click','.period_picker_box .xdsoft_navigate',function() { // alert(); // }) }, highligth_get_date: function() { var self = this; if (this.param_search.universal.country_id == 1) { var data = { country_id:this.param_search.universal.country_id, city_id:this.param_search.universal.city_id, }; } else { var data = { country_id:this.param_search.universal.country_id, // city_id:this.param_search.universal.city_id, }; } if (this.param_search.universal.country_id.length == 0 && this.param_search.tour.country_id.length > 0) { var data = { country_id: this.param_search.tour.country_id, direction_id: this.param_search.tour.direction_id, tour_id: this.param_search.tour.tour_id, }; } this.get('tourInit',data).then(function(data) { self.dates_tour = data.Date; for (var i in data.tours) { self.dates_tours[data.tours[i].Id] = data.tours[i].Date; } // console.log(self.dates_tours); }); }, highligth_date: function() { $('.period_picker_cell').removeClass('rt-highligth-tour'); for (var i in this.dates_tour) { var d = this.dates_tour[i]; $('.period_picker_cell[data-date="'+d+'"]').addClass('rt-highligth-tour'); } }, highligth_date_only_tour: function(tour_id) { $('.period_picker_cell').removeClass('rt-highligth-tour'); // console.log(tour_id); // console.log(this.dates_tours); if (typeof(this.dates_tours[tour_id]) != 'undefined') { for (var i in this.dates_tours[tour_id]) { var d = this.dates_tours[tour_id][i]; // console.log(d); $('.period_picker_cell[data-date="'+d+'"]').addClass('rt-highligth-tour'); } } }, getNights: function(start,stop) { var start = Date.parse(start); var stop = Date.parse(stop); var day = 3600*24*1000; var nights = ((stop - start)/day); if(nights > 14) { var res = stop - (day*14); var $now = new rt.Date(res); this.universalCalendar.val( $now.format('d.m.Y')).periodpicker('change'); } }, getNightsToTable: function(start_data,stop_data) { start_data = start_data.split('.'); start = start_data[2]+'/'+start_data[1]+'/'+start_data[0]; stop_data = stop_data.split('.'); stop = stop_data[2]+'/'+stop_data[1]+'/'+stop_data[0]; var start = Date.parse(start); var stop = Date.parse(stop); var day = 3600*24*1000; var nights = ((stop - start)/day); // alert(nights); // return math.ceil(nights); return Math.ceil(nights); // return nights; }, stopUniversalSeaarch: function() { this.$host.find('.period_picker_input, .rt-country-select').removeClass('rt-error'); return false; }, universalSearch: function() { var self = this; if (this.stopUniversalSeaarch()) { return false; } this.check_what_search(); if (this.what_search.length == 0 ){ this.alert('Укажите параметры поиска'); this.$host.find('.search-param').show(); return false; } this.stat = {}; this.count_search++; this.universal.find('.search-block').addClass('disabled'); this.$host.find('.rt-disabled-form').show(); this.reset_results(); this.$host.find('.rt-button-searche').html('
ПОИСК
').addClass('buttonSearchProces'); this.buttonSearchProces(); this.$host.find('.universal').html(''); this.$host.find('#order_dialog').hide().html(''); // this.$host.find('.universal').html(''); var $data = this.param_search.universal; this.data_form = this.param_search.tourists; this.country_id = this.param_search.universal.country_id; $data.avia = this.set.avia; this.transform_form_hide(); this.showUniversalMaket(); this.param_search.universal.sessionid +=this.count_search; if (this.set.avia == 1) { this.get('searche_avia_table',this.querySearch()).then(function(data) { self.avia_table = data; if (!self.searching) { self.outputTableDay('all'); } }); this.get('searche_avia_table_one',this.querySearch()).then(function(data) { self.avia_table_one = data; if (!self.searching) { self.outputTableDay('one'); } }); } this.get('getRequests',this.querySearch()).then(function(data) { }); setTimeout(function() { self.abort(); },500); this.search_interval = setInterval(function() { self.check_result_data(); },1000); }, check_what_search: function() { var self = this; this.what_search = []; this.$host.find('.search-param').animate({height: "hide"}, 240); var show_avia = false; this.$host.find('.search-param input:checked').each(function() { var _this = $(this); var type = _this.data('type'); if (self.set.avia == 0 && (type == 'hotelavia' || type == 'avia')) { return; } if (type == 'avia') { show_avia = true; } self.what_search.push(type); }); if (!show_avia) { this.set.avia = 0; } else { this.set.avia = 1; } }, check_result_data: function() { var self = this; var param = { 'sessionid':this.param_search.universal.sessionid, 'request':this.request, }; if (typeof(this.url_search.hotel) != 'undefined') { param.hotel_ind = this.url_search.hotel; param.room_code = this.url_search.room; } this.get('check_result_data',param).then(function(data) { var $opers = ['hotel','avia','tours','excursion','transfers']; var $count = 0; for (var i in $opers) { var $oper = $opers[i]; if (data[$oper].find.length > $count) { if ($oper == 'hotel') { if (self.lists.hotel.length > 20) { self.request[$oper] = 1; } } else { self.request[$oper] = 1; } if ($oper == 'avia') { self.avia_structure = data.avia.structure.there_and_back; //Структура авиабилета self.avia_min_sum = data.avia.min_sum; } self.gateResults(data[$oper]); self.clear_opers_wait($oper); } } if(data.complete) { // console.log(1); // console.log(typeof(data.packet)); // console.log(typeof(data.packet.find)); if (typeof(data.packet.find) != 'undefined' && data.packet.find.length > $count) { // console.log(2); self.gateResults(data.packet); self.clear_opers_wait('packet'); self.check_completed_packet(); } if (self.what_search.indexOf('transfers') != -1) { self.check_only_transfer(); } // console.log(3); self.completed_search(data); // console.log(4); // alert(); } if (self.lists.hotelavia.length > 0) { self.clear_opers_wait('hotelavia'); } }); }, check_only_transfer: function() { this.show_result_for_all('transfers'); this.actions_left_menu('transfers'); if (!this.is_open()) { this.transform_form_show(); this.out_active_data('transfers'); } }, check_completed_packet: function() { if (this.$host.find(".universal").is(":visible") == false && this.$host.find("#order_dialog").is(":visible") == false) { this.transform_form_show(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-packet']").click(); } }, completed_search: function(data) { var self = this; clearInterval(this.search_interval); this.resetSearch(); this.clear_opers_wait('all'); this.filters = data.filter; this.min_price = data.min_price; this.stat = data.stat; // l(self.filters); this.show_filter(); this.showPaginators(); this.outputTableDay('all'); this.outputTableDay('one'); this.scanAviaTable(); if (this.$host.find(".universal").is(":visible") == false && this.lists.hotel.length == 0 && this.lists.tours.length == 0) { this.alert('Туров не найдено. Измените параметры поиска. Подбираются варианты на соседние даты.'); return; } if (this.$host.find(".universal").is(":visible") == false && this.$host.find("#order_dialog").is(":visible") == false) { if (typeof(this.avia_table.count) != "undefined" && this.avia_table.count > 0) { this.confirm('На выбранные даты туров не найдено, но имеются туры на другие даты заезда по данному направлению. Показать?',function() { self.$host.find('#alert').animate({height: "hide"}, 500); self.overlayAlert.hide(); self.show_table_other_date(); }); } else if (typeof(this.avia_table.count) != "undefined" && this.avia_table.count == 0) { this.alert('Туров не найдено. Измените параметры поиска.'); } else { this.alert('Туров не найдено. Измените параметры поиска. Подбираются варианты на соседние даты.'); } // } this.confirm_for_sort_result(); this.festive_dinner(); }, festive_dinner: function() { if (typeof(this.param_search.universal.city_id) =='undefined') { return false; } var uzhins = { '1868328': 'http://rt.plus/?get_shrilanka=1', }; for (var i in uzhins) { if (i == this.param_search.universal.city_id) { this.$host.find('#rt-universal-hotel .rt-sortings').append('Доплаты за праздничный ужин'); } } // this.param_search.universal.city_id }, confirm_for_sort_result: function() { var self = this; var $open_service = this.what_is_open(); if ($open_service == 'hotelavia' || $open_service == 'hotel') { this.confirm('Поиск завершен

Отсортировать результаты по возрастанию цены?',function() { self.$host.find('#alert').animate({height: "hide"}, 500); self.overlayAlert.hide(); self.completed_filter($open_service); setTimeout(function() { // self.completed_filter(($open_service == 'hotelavia' ? 'hotel' : 'hotelavia')); },5000); }); } }, what_is_open: function() { var $service = ''; if (this.$host.find('#rt-universal-hotelavia').is(':visible')) { $service = 'hotelavia'; } if (this.$host.find('#rt-universal-tours').is(':visible')) { $service = 'tours'; } if (this.$host.find('#rt-universal-hotel').is(':visible')) { $service = 'hotel'; } if (this.$host.find('#rt-universal-excursion').is(':visible')) { $service = 'excursion'; } if (this.$host.find('#rt-universal-transfers').is(':visible')) { $service = 'transfers'; } if (this.$host.find('#rt-universal-visa').is(':visible')) { $service = 'visa'; } if (this.$host.find("#order_dialog").is(":visible")) { $service = 'dialog'; } return $service; }, show_table_other_date: function() { this.transform_form_show(); this.$host.find('.rt-universal-left, .rt-sortings, .rt-universal-filters').hide(); this.$host.find('.rt-avia-table-all').addClass('open-table'); this.$host.find('.day3').show(); this.$host.find('.rt-universal-result').css('border','0'); }, transform_form_show: function() { this.clear_menu(); this.$host.find('.universal').show(); if (!this.inside) $('.hidden_for_form').hide(); if (!this.inside) $('.front-page-form').addClass('hidden-bg'); if (this.online != 'online' && !this.inside) this.$host.addClass('rt-form-open'); this.$host.find('.input_form_universal').addClass('container'); if (this.online == 'online') { this.$host.find('.rt-universal').css('margin','0'); } $('.content-wp .slider').hide(); this.show_date_min_price(); }, clear_menu:function() { var self = this; this.$host.find('.rt-universal-filter-block-item').each(function() { var _this = $(this); var type = _this.find('a').attr('href').replace('#rt-universal-',''); if (self.to_what_search(type)) { _this.show(); } else { _this.hide(); } // console.log(type); }); }, to_what_search: function(type) { var res = false; for (var i in this.what_search) { if (type == this.what_search[i]) { res = true; } } return res; }, transform_form_hide: function() { this.$host.find('.universal').hide(); $('.hidden_for_form').show(); $('.front-page-form').removeClass('hidden-bg'); $('.content-wp .slider').show(); this.$host.removeClass('rt-form-open'); this.$host.find('.input_form_universal').removeClass('container'); }, is_open: function() { if (this.$host.find(".universal").is(":visible")) { return true; } return false; }, gateResults: function(data) { for (var i in data.find) { this.lists[data.type].push(data.find[i]); } if (this.set.avia && typeof(this.tour) == 'undefined' && this.to_what_search('hotelavia')) { this.check_hotelsAvia(); } else { if (data.find.length > 0 && this.$host.find(".universal").is(":visible") == false && this.$host.find("#order_dialog").is(":visible") == false) { this.transform_form_show(); if (typeof(this.url_search.show) == 'undefined') { this.out_active_data(data.type); } } } this.show_result_for_all(data.type); this.actions_left_menu(data.type); }, check_tour_for_avia: function() { for (var i in this.lists.tours) { var $list = this.lists.tours[i]; var $key = $list.start+'-'+$list.night; if(this.param_search.avia_for_tour.indexOf($key) == -1 ) { this.param_search.avia_for_tour.push($key); } } // l(this.param_search.avia_for_tour); }, trans: function(text) { var lang = this.lang; text = text.replace(new RegExp('<\\$ *(.+?, ?)?'+lang+': ?(.*?)(, ?[a-z]{2}:.*?)?\\$>', 'ig'), '$2') return text; }, show_filter: function() { var $name = { 'dates':this.trans('<$ru: Даты вылета, en: Departure dates$>'), 'chekin':this.trans('<$ru: Дата заезда, en: Arrival date $>'), 'stars':'Категория отеля', 'status':this.trans('<$ru: Наличие мест, en: Seat availability $>'), 'alf':'По названию', 'name':this.trans('<$ru: По названию, en: Name $>'), 'otkuda_type':'Откуда', 'type_excurions':'Вид экскурсии', 'cityname':'Город', 'kuda_type':'Куда', 'sale':'Спецпредложение', 'hotelprofiles':'Профиль лечения', 'meal':this.trans('<$ru: Питание, en: Meals $>'), 'accommodation':this.trans('<$ru: Тип проживания, en: Accommodation type $>'), 'hotels':this.trans('<$ru: Размещение, en: Accommodation $>'), 'duration':'Ночи', 'owrt':'Туда и обратно', }; var $active_filter = ['hotel','hotelavia','tours','excursion','transfers','packet']; for (var y in $active_filter ){ var $res = '' var $oper = $active_filter[y]; for (var i in this.filters[$oper] ){ if (this.filters[$oper][i].length > 0 || this.searching) { $res += this.render('universaal_filters',{ 'name':$name[i], 'type':$oper, 'filter':i, 'list':this.filters[$oper][i], 'searching':this.searching, }); } } if (this.searching) { $res += '
Идёт загрузка предложений...
'; } else { $res += '
Найдено '+this.stat[$oper]+' предложений
'; } this.$host.find('#rt-universal-'+$oper+' .rt-universal-filters').html($res); if (!this.searching) { this.action_filter($oper); } } }, action_filter: function($oper) { var self = this; var $filters = this.$host.find('#rt-universal-'+$oper+' .rt-universal-filters'); $filters.find('.rt-universal-filter-block input, .rt-checkbox-line').on('change',function(){ self.settings[$oper].page = 1; self.show_input_filter($oper); }); $filters.find('.rt-universal-filter-block .rt-filter-input').on('keyup',function(){ if ($(this).val().length > 2) { self.settings[$oper].page = 1; self.show_input_filter($oper); } }); }, show_input_filter: function($oper) { var self = this; var $block = this.$host.find('a[href="#rt-universal-'+$oper+'"]').parent(); $block.find('.rt-filter-selected').remove(); var $res = ''; this.filters_selected[$oper].filters = {}; if (($oper == 'hotelavia' || $oper == 'hotel' ) && this.$host.find('#rt-universal-'+$oper+' .rt-filter-input').val().length > 2) { self.filters_selected[$oper].filters.hotelname = this.$host.find('#rt-universal-'+$oper+' .rt-filter-input').val(); $res += ''+this.$host.find('#rt-universal-'+$oper+' .rt-filter-input').val()+''; } this.$host.find('#rt-universal-'+$oper+' input:checked').each(function() { var $f = $(this).attr('src:filter'); var $t = $(this).attr('src:title'); var $name = $(this).val(); if (typeof($t) != 'undefined') { $name = $t; } $res += ''+$name+''; if (typeof(self.filters_selected[$oper].filters[$f]) == 'undefined') { self.filters_selected[$oper].filters[$f] = []; } self.filters_selected[$oper].filters[$f].push($(this).val()); }); $($res).appendTo($block); $block.find('.rt-filter-selected').on('click',function() { if ($(this).attr('src:val') == 'hotelname') { self.$host.find('#rt-universal-'+$oper+' .rt-filter-input').val(''); } else { self.$host.find('#'+$(this).attr('src:val')).prop('checked', false); } self.show_input_filter($oper); }); this.completed_filter($oper); }, completed_filter: function($oper) { var self = this; this.show_loader(); this.post('completed_filter',{ 'sessionid':this.param_search.universal.sessionid, 'oper':$oper, 'params':this.filters_selected[$oper], }).then(function(data) { self.lists[$oper] = data.find; if (typeof(data.stat) != 'undefined' && data.stat > 0 ) { self.stat[$oper] = data.stat; } else { self.stat[$oper] = 0; } self.show_stat($oper); self.showPaginator($oper); self.show_result_for_all_find($oper); setTimeout(function(){ self.hide_loader(); },500); }); }, show_loader: function() { this.$host.find('.rt-universal').addClass('rt-loader'); }, hide_loader: function() { this.$host.find('.rt-universal').removeClass('rt-loader'); }, show_stat: function($oper) { var $res = 'Найдено '+this.stat[$oper]+' предложений'; this.$host.find('#rt-universal-'+$oper+' .rt-universal-filters-info').text($res);; }, null_opers: function($oper) { var $link = this.$host.find('.rt-universal-filter-block-item a[href="#rt-universal-'+$oper+'"]'); $link.parent().addClass('rt-empty'); $link.off(); }, check_hotelsAvia: function() { $all = []; // for (var i in this.result.hotel) { // if (this.result.avia[i] != undefined) { // for (var y in this.result.hotel[i]) { // $all.push(this.result.hotel[i][y]); // } // } // } if (this.lists.hotel.length > 0 && this.lists.avia.length) { for (var y in this.lists.hotel) { $all.push(this.lists.hotel[y]); } } this.lists.hotelavia = $all; if ($all.length > 0) { this.show_result_for_all('hotelavia'); this.actions_left_menu('hotelavia'); } }, show_result_for_all: function($type) { this.showSortings($type); var $res_page = this.$host.find('#rt-universal-'+$type+' .rt-res > div').length; if ($res_page >= this.settings[$type].setPage) { return false; } this.show_result_for_all_find($type); if ($type == 'hotelavia' ) { if ($('#order_dialog').is(':visible')) { } else { this.transform_form_show(); } } }, showSortings: function($type) { var self = this; var $sorts = this.$host.find('#rt-universal-'+$type+' .rt-sortings'); $sorts.html(this.render('sortings')); $sorts.find('span.tobr').on('click', function(e){ if (self.searching) { self.alert('Производится поиск. Пожалуйста подождите.'); return; } $(this).addClass('active').siblings().removeClass('active'); // self.sort($(this).attr('param'),$type); var $pr = ''; var icon = $(this).find('.sorticon'); if (icon.hasClass('sorticondown')) { icon.removeClass('sorticondown'); icon.addClass('sorticonup'); } else { icon.addClass('sorticondown'); icon.removeClass('sorticonup'); $pr = 'r'; } self.filters_selected[$type].sort = $pr+$(this).attr('param'); self.completed_filter($type); // addClass((typeof(this.sort_direction) != 'undefined' && this.sort_direction) ? 'sorticondown' : 'sorticonup'); } ); $sorts.find('.convert-valute span').on('click', function(e){ $(this).addClass('active').siblings().removeClass('active'); self.$host.find('#rt-universal-'+$type+' .rt-course-RUR').hide(); self.$host.find('#rt-universal-'+$type+' .rt-course-USD').hide(); self.$host.find('#rt-universal-'+$type+' .rt-course-EUR').hide(); self.$host.find('#rt-universal-'+$type+' .rt-course-GBP').hide(); self.$host.find('#rt-universal-'+$type+' .rt-course-'+$(this).attr('param')).show(); // addClass((typeof(this.sort_direction) != 'undefined' && this.sort_direction) ? 'sorticondown' : 'sorticonup'); if ($type == 'hotel' || $type == 'hotelavia') { self.recalc_button_hotel(); } } ); }, check_sum_avia: function() { var $res = false; if ( this.lists.avia.length > 0) { if (this.avia_min_sum < this.lists.avia[0].price) { $res = true; } } return $res; }, sum_min_avia: function() { var $res = 0; if ( this.lists.avia.length > 0) { $res = parseInt(this.lists.avia[0].price) - parseInt(this.avia_min_sum); } return $res; }, show_result_for_all_find: function($type) { var $list = this.lists[$type]; var $render_param = { data:$list, max:0, sum:0, avia:($type == 'hotelavia' ? 1 : 0), courses:this.courses }; if ($type == 'avia') { $render_param.structure = this.avia_structure; } if ($type == 'hotelavia' || $type == 'hotel') { $render_param.min_sum = this.avia_min_sum; } var packet = false; if ($type == 'tours' && typeof($list[0].flight) != 'undefined') { // alert(); packet = true; } this.$host.find('#rt-universal-'+$type+' .rt-res').html( this.render('rt_universal_'+($type == 'hotelavia' ? 'hotel' : (packet ? 'packet' : $type)),$render_param ) ) if ($type == 'hotel') { this.action_universal_hotel('hotel'); } if ($type == 'hotelavia') { this.action_universal_hotel('hotelavia'); } if ($type == 'excursion') { this.action_universal_excursion(); } if ($type == 'tours') { this.action_universal_tour(packet); } if ($type == 'packet') { this.action_universal_packet(); } if ($type == 'avia') { this.action_universal_avia(); } if ($type == 'transfers') { this.action_universal_transfers(); } if ( typeof(this.url_search.show) != "undefined" && this.url_search.show != "" && this.lists[this.url_search.show].length > 0 ) { this.out_active_data(this.url_search.show); // this.$host.find('a[href="#rt-universal-'+this.url_search.show+'"]').click(); // this.url_search.show = ''; } }, out_active_data: function(type) { this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-"+type+"']").parent().addClass('rt-active').siblings().removeClass('rt-active'); this.$host.find('#rt-universal-'+type).addClass('rt-active').siblings().removeClass('rt-active'); }, showPaginators: function() { for (var i in this.stat) { this.showPaginator(i); } }, showPaginator: function($type) { var self = this; var all = this.stat[$type]; var count = this.settings[$type].setPage; var $pagins = this.$host.find('#rt-universal-'+$type+' .rt-paginator'); $pagins.hide(); var $pages = Math.ceil(all/count); $pagins.html(this.render('paginators',{ 'page':this.settings[$type].page, 'pages':$pages , })); if ($pages > 1) { $pagins.show(); } $pagins.find('.rt-paginator-page').on('click',function() { $(this).addClass('active').siblings().removeClass('active'); self.settings[$type].page = $(this).text(); self.filters_selected[$type].page = $(this).text() self.completed_filter($type); self.scrollAnimate('#rt-universal-'+$type+' .rt-sortings'); }); $pagins.find('.rt-paginator-prev').on('click',function() { if (parseInt(self.settings[$type].page) - 1 > 0) { self.scrollAnimate('#rt-universal-'+$type+' .rt-sortings'); self.settings[$type].page--; self.filters_selected[$type].page = self.settings[$type].page; self.completed_filter($type); } }); $pagins.find('.rt-paginator .rt-paginator-next').on('click',function() { if (parseInt(self.settings[$type].page) + 1 < 20) { self.scrollAnimate('#rt-universal-'+$type+' .rt-sortings'); self.settings[$type].page++; self.filters_selected[$type].page = self.settings[$type].page; self.completed_filter($type); } }); }, action_universal_excursion: function() { this.$host.find('#rt-universal-excursion select').selectric(); var self = this; this.$host.find('#rt-universal-excursion .rt-button-order').on('click',function() { var $date = $(this).parents('.rt-universal-hotels-prices').find('select').val(); self.show_order_block(); self.add_order_excursion($(this),$date); self.show_order_calc(); self.action_order_cart(); }); this.$host.find('#rt-universal-excursion .rt-universal-excursion-title, #rt-universal-excursion .rt-universal-excursion-link').on('click',function() { if (self.searching) { self.alert('Производится поиск. Пожалуйста подождите.'); return; } var $oper = $(this).attr('src:oper'); self.showOrderHolder(self.render('order')); self.get('excursion_info',{excursion_id:$(this).attr('src:id'),sessionid: self.sid}).then(function(data) { self.scrollAnimate('.input_form_universal'); self.order_holder.find('#passport').html(self.render('excursion_info',data)); }); return false; }); }, check_double_cart: function($type) { var $res = false; for (var i in this.cart) { if ($type == "hotel" && typeof(this.cart[i].room) != "undefined" ) { $res = true; } if ($type == "hotelavia" && typeof(this.cart[i].room) != "undefined" ) { $res = true; } if ($type == "avia" && typeof(this.cart[i].origin) != "undefined" ) { $res = true; } if ($type == "hotelavia" && typeof(this.cart[i].origin) != "undefined" ) { $res = true; } if ( $type == "tour" && ( typeof(this.cart[i].hotels) != "undefined" // || typeof(this.cart[i].oper) != "transfers" // || typeof(this.cart[i].oper) != "excursion" // || typeof(this.cart[i].room) != "undefined" ) ) { $res = true; } } return $res; }, check_double_cart_tour: function() { var $res = 'У Вас заказан экскурсионный пакет'; return $res; }, action_universal_hotel: function(t) { var self = this; var $block = this.$host.find('#rt-universal-'+t); $block.find('.rt-universal-hotels-room').on('click',function() { var $room = $(this).parents('.rt-universal-hotels-item').find('.rt-universal-hotels-room'); $room.removeClass('rt-selected'); $(this).addClass('rt-selected'); var $room_id = $(this).attr('src:room_id'); var pr = $(this).find('.r_price span:visible').html(); $(this).parents('.rt-universal-hotels-item').find('.rt-button-order .p_price').html(pr); $(this).parents('.rt-universal-hotels-item').find('.rt-button-order').attr('src:room',$room_id); }); $block.find('.plusPrice').on('click',function() { $(this).parent().find('.rt-universal-hotels-hide_room').animate({height: "show"}, 500); $(this).hide(); $(this).parent().find('.minusPrice').show(); }); $block.find('.minusPrice').on('click',function() { $(this).parent().find('.rt-universal-hotels-hide_room').animate({height: "hide"}, 500); $(this).hide(); $(this).parent().find('.plusPrice').show(); }); $block.find('.rt-universal-hotels-item .rt-button-order').on('click',function() { if (self.check_double_cart(t)) { if (t == 'hotel') { self.alert('У Вас заказан отель.'); } else { self.alert('У Вас заказан отель или авиаперелёт.'); } return false; } self.show_order_block(); self.add_order_hotel($(this),t); self.action_order_cart(); }); $block.find('.rt-universal-hotels-title').on('click',function() { if (self.searching) { self.alert('Производится поиск. Пожалуйста подождите.'); return; } var $oper = $(this).attr('src:oper'); self.get('hotel_info',{hotel_id:$(this).attr('src:id'),hotel_oper:$(this).attr('src:oper'),sessionid: self.sid}).then(function(data) { self.scrollAnimate('.input_form_universal'); if ($oper == 'zeltsoft') { self.HotelInfo(data); } else { self.HotelInfoOffer(data); } }); }); this.recalc_button_hotel(); }, action_universal_tour: function(packet) { var self = this; this.$host.find('#rt-universal-tours .rt-button-order').on('click',function() { if (self.check_double_cart('tour')) { self.alert(self.check_double_cart_tour()); return false; } if (packet && !self.check_double_cart('avia')) { self.cart.push(self.lists.avia[0]); } self.show_order_block(); self.add_order_tour($(this)); self.show_order_calc(); self.action_order_cart(); // self.$host.find('.rt-order_button .rt-button-cart').hide(); self.check_button_cart(); }); this.$host.find('.rt-tours-table-item__TourName a').on('click',function() { var $res = ''; self.showOrderHolder(self.render('order')); self.get('tour_info',{tour_id:$(this).attr('tour:id'),sessionid:self.sid}).then(function(data) { self.order_holder.find('#passport').html(self.render('tour_description',{data:data})); }); return false; }); this.$host.find('.rt-tours-table-item__HotelName .rt-hotel-block').on('click',function() { self.get('hotel_info',{hotel_id:$(this).attr('src:id'),hotel_oper:'zeltsoft'}).then(function(data) { self.HotelInfo(data); }); }); this.$host.find('.rt-show-rest-tours').on('click',function() { self.$host.find('.rt-tours-table-item').fadeIn(); $(this).remove(); return false; }); this.$host.find('.rt-tours-table-item__CheckInDate input').each(function() { // $(this).hide(); var tour_name = $(this).parents('.rt-tours-table-item').find('.rt-tours-table-item__HotelName .rt-hotel-block').text(); var now = new rt.Date(); var tour_id = $(this).data('tour_id'); $(this).periodpicker({ lang: 'ru', cells: [1, 2], hideOnBlur: true, yearsLine: false, norange: true, fullsizeButton: false, formatDate: 'DD.MM.YYYY', formatDecoreDateWithYear: 'D MMMM', minDate: now.format('d.m.Y'), i18n: { 'ru' : { 'Select period' : 'Доступные даты заезда', 'Choose period' : '', 'Choose date' : 'Доступные даты заезда тура: '+tour_name, 'Select date' : 'Доступные даты заезда тура: '+tour_name, } }, onAfterShow: function () { }, onAfterHide: function () { }, onAfterRegenerate: function() { self.highligth_date_only_tour(tour_id); }, }); }); }, check_button_cart: function() { if (this.lists.excursion.length == 0 && this.lists.transfers.length == 0) { this.$host.find('.rt-order_button .rt-button-cart').hide(); } }, action_universal_packet: function() { var self = this; this.$host.find('#rt-universal-packet .rt-button-order').on('click',function() { if (self.check_double_cart('tour')) { self.alert(self.check_double_cart_tour()); return false; } self.show_order_block(); self.add_order_packet($(this)); self.show_order_calc(); self.action_order_cart(); self.$host.find('.rt-order_button .rt-button-cart').hide(); }); this.$host.find('#rt-universal-packet .rt-tours-table-item__TourName a').on('click',function() { var $res = ''; self.showOrderHolder(self.render('order')); self.get('tour_info',{tour_id:$(this).attr('tour:id'),sessionid:self.sid}).then(function(data) { self.order_holder.find('#passport').html(self.render('tour_description',{data:data})); }); return false; }); this.$host.find('#rt-universal-packet .rt-tours-table-item__HotelName .rt-hotel-block').on('click',function() { self.get('hotel_info',{hotel_id:$(this).attr('src:id'),hotel_oper:'zeltsoft'}).then(function(data) { self.HotelInfo(data); }); }); }, action_universal_transfers: function() { var self = this; this.$host.find('#rt-universal-transfers .rt-button-order').on('click',function() { self.show_order_block(); self.add_order_transfers($(this)); self.action_order_cart(); self.show_order_calc(); }); }, show_order_block: function() { // history.pushState(null, null, '#order-block'); this.hide_message(); if (this.$host.find('.rt-filter-selected__avia').length > 0) { this.$host.find('.rt-filter-selected__avia').remove(); } this.online_cart = []; this.showOrderHolder(this.render('order')); this.add_order_block(); this.add_order_tourists(); if (this.set.avia == 1) { // this.add_order_avia(); } this.actions_order(); this.show_cart_save(); this.scrollAnimate('.hotel_search_form'); }, show_order_calc: function() { var $cart = []; var $avia = 0; var self = this; for (var i in this.online_cart) { if (typeof(this.online_cart[i].origin) != 'undefined') { $avia = 1; } $cart.push(this.online_cart[i]); } for (var i in this.cart) { if (typeof(this.cart[i].origin) != 'undefined') { $avia = 1; } $cart.push(this.cart[i]); } var $itogo = 0; var $itogo_agency = 0; for(var i in $cart) { if (typeof($cart[i].hotel) != 'undefined' && $avia == 1) { $itogo += parseInt($cart[i].priceavia.prices.rur); $itogo_agency += parseInt($cart[i].priceavia.price_to_pay); } else { $itogo += parseInt($cart[i].prices.rur); $itogo_agency += parseInt($cart[i].price_to_pay); } } this.order_holder.find('.rt-order_calc').html(this.render('order_calc',{cart:$cart, itogo:$itogo,itogo_agency:$itogo_agency,avia:$avia})); var $agency_block = this.order_holder.find('.rt-order_calc_agency_prices'); var $button = this.order_holder.find('.rt-order_calc_agency'); if (this.order_for != 'agent') { $agency_block.remove(); $button.remove(); } }, add_order_transfers: function($_this) { var $code = $_this.attr('src:id'); var $list = this.lists.transfers[$code]; $list.sid = this.sid; this.online_cart.push($list); var $avia = this.render('order_transfers',$list); $($avia).appendTo(this.order_holder.find('.rt-order_input')); }, action_order_cart: function() { this.check_cart_transfers(); if (this.set.avia == 0 || this.check_avia()) { this.order_holder.find('.rt-add-tour-flight').hide(); } var self = this; this.order_holder.find('.rt-delet-cart').on('click',function() { var $type = $(this).attr('src:type'); var $code = $(this).attr('src:i'); if ($type == 'cart') { self.delete_products_cart($code); } else { self.delete_products_online_cart($code); } $(this).parent().remove(); if (self.cart.length == 0 && self.online_cart == 0) { self.$host.find('#close_order_dialog a').click(); self.$host.find('.rt-cart').hide(); } }); var $cart = this.$host.find('.rt-cart'); var $price = 0; if (this.cart.length == 0) { $cart.hide(); } else { $cart.show(); } this.order_holder.find('.rt-add-tour-flight').on('click',function() { $_this = $(this); $_this.html('
Производится поиск
'); var $key = $_this.attr('src:key'); $key = $key.split('-'); var param = { 'day':$key[0], 'nights':$key[1], }; self.order_add_to_cart(); self.add_avia_for_tour(param); }); }, check_cart_transfers: function() { $res = []; var $y = 1; for (var i in this.online_cart) { if (this.online_cart[i].oper == 'transfers') { $res.push(this.online_cart[i]); } } for (var i in this.cart) { if (this.cart[i].oper == 'transfers') { $res.push(this.cart[i]); } } if ($res.length > 0) { console.log($res); this.order_holder.find('.data_order_transfer').html(this.render('data_order_transfer',{data:$res})); var $day = this.param_search.universal.day.split(','); // l($day); this.order_holder.find('.rt-date').mask('o9.m9.ne99').val($day[0]); this.order_holder.find('.rt-date.back').mask('o9.m9.ne99').val($day[1]); this.order_holder.find('.rt-time-hour, .rt-time-min').mask('99'); } }, delete_products_cart: function($i) { delete this.cart[$i]; var $cart = []; for (var i in this.cart) { $cart.push(this.cart[i]); } this.cart = $cart; // this.show_cart_save(); }, delete_products_online_cart: function($type) { $cart = []; for (var i in this.online_cart) { var $add = false; if ($type == 'hotel' && typeof(this.online_cart[i].hotel) == 'undefined') { $add = true; } if ($type == 'avia' && typeof(this.online_cart[i].origin) == 'undefined') { $add = true; } if ($type == 'tour' && typeof(this.online_cart[i].hotels) == 'undefined') { $add = true; } if ($type == 'excursion' && typeof(this.online_cart[i].date) == 'undefined') { $add = true; } if ($add) { $cart.push(this.online_cart[i]); } } this.online_cart = $cart; // this.show_cart_save(); }, icon_currency: function(currency) { var $res = currency; if (currency == 'rur') { $res = '₽'; } if (currency == 'usd') { $res = '$'; } if (currency == 'eur') { $res = '€'; } if (currency == 'gbp') { $res = '£'; } return $res; }, checkTour: function() { var $res = false; return $res; for (var i in this.cart) { if (typeof(this.cart[i].hotels) != 'undefined') { $res = true; } } for (var i in this.online_cart) { if (typeof(this.online_cart[i].hotels) != 'undefined') { $res = true; } } return $res; }, check_avia: function() { var $res = false; for (var i in this.cart) { if (typeof(this.cart[i].origin) != 'undefined') { $res = true; } } for (var i in this.online_cart) { if (typeof(this.online_cart[i].origin) != 'undefined') { $res = true; } } return $res; }, actions_order: function() { if (this.checkTour()) { this.order_holder.find('.rt-order_button .rt-button-cart').hide(); } var self = this; this.order_holder.find(".rt-order_menu_item a").on('click', function(e){ e.preventDefault(); $(this).parent().addClass('rt-active').siblings().removeClass('rt-active'); self.order_holder.find('.rt-order_block_menu').hide(); self.order_holder.find($(this).attr('href')).show(); }); this.order_holder.find('.rt-order_button .rt-button-cart').on('click',function() { self.order_add_to_cart(); self.show_cart_save(); self.order_holder.find('#close_order_dialog a').click(); self.show_message('Выберите дополнительные услуги','rt-message-green'); self.transition_service(); }); this.order_holder.find('.rt-order_button_complete .rt-button-cart').on('click',this.proxy(this.booking)); }, transition_service: function() { if (this.lists.excursion.length > 0) { this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-excursion']").click(); return true; } if (this.lists.transfers.length > 0) { this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-transfers']").click(); return true; } }, booking: function() { var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", //метод для кодировки в base64 на javascript encode: function(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0 input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, //метод для раскодировки из base64 decode: function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // метод для кодировки в utf8 _utf8_encode: function(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, //метод для раскодировки из urf8 _utf8_decode: function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }; var self = this; var $button = this.order_holder.find('.rt-order_button_complete .rt-button-cart'); var $bg = this.order_holder.find('.rt-order-wait'); var $tourist = {}; var $error = false; this.order_holder.find('#rt-order-tourists input').removeClass('rt-error'); this.order_holder.find('#rt-order-tourists input, #rt-order-tourists select').each(function() { var str = $(this).attr('name'); if (str != 'rt-phone' && str != 'rt-email' ) { $name = str.substr(0, str.length - 3); if ($(this).val() == '') { $(this).addClass('rt-error'); $error = true; } if ($tourist[$name] == undefined) { $tourist[$name] = []; } $tourist[$name].push($(this).val()); } }); var $transfers = {}; this.order_holder.find('.data_order_transfer_item input, .data_order_transfer_item textarea').removeClass('rt-error'); this.order_holder.find('.data_order_transfer_item input, .data_order_transfer_item textarea').each(function() { var str = $(this).attr('name'); $name = str.substr(0, str.length - 3); if ($(this).val() == '') { $(this).addClass('rt-error'); $error = true; } if ($transfers[$name] == undefined) { $transfers[$name] = []; } $transfers[$name].push($(this).val()); }); if ($error) { return false; } this.order_add_to_cart(); var $p = { 'cart':this.cart, 'sessionid':this.sid, 'rt-email':this.order_holder.find('#rt-email').val(), 'rt-phone':this.order_holder.find('#rt-phone').val(), 'rt-comment':this.order_holder.find('#rt-comment').val(), 'tourist':$tourist, 'transfers':$transfers, }; var $req = Base64.encode(JSON.stringify($p)); var $data = { 'service':'operators', 'apiKey':'rosstour.ru', 'method':'booking', 'format':'json', // 'format':'php', 'version':this.version, 'data': $req, }; $button.html('Производится бронирование'); // $bg.show(); this.order_holder.addClass('rt-loader'); var actionUrl = 'rt_plus'; // if (this.cart.tour.length > 0) actionUrl = 'incoming_new'; var url = 'online2.rt.plus'; if (this.purchase_url != '') { url = this.purchase_url; } if (document.location.host == 'online2.rt.plus') { url = 'online2.rt.plus'; } $.ajax({ type: "POST", url: "http://api.rt.plus/gate/", dataType: "json", data: $data }).done(function( data ) { if (typeof(data.data) != 'undefined') { data = data.data; } // console.log(data); // return; if (data.error == '') { document.location.href = '//'+url+'/searchForm/process/'+actionUrl+'.php?rt-session-id='+data.sessionid; // document.location.href = 'http://online2.rt.plus/searchForm/process/incoming_hotel_new.php?rt-session-id=MOW62211A01'; } else if (data.error == 'avia') { self.alert('Произошла ошибка бронирования авиаперелёта, проверьте паспортные данные или выберите другой вариант перелёта.'); } else { self.alert('Ошибка бронирования'); } // sel $bg.hide(); if (data.error != '') { setTimeout(function() { $button.html('Забронировать'); self.order_holder.removeClass('rt-loader'); },500); } }); }, order_add_to_cart: function() { for (var i in this.online_cart) { this.cart.push(this.online_cart[i]); } this.online_cart = []; // this.order_holder.find('.rt-order_input, .rt-order_button').hide(); this.save_tourists_data(); }, save_tourists_data: function() { var self = this; this.tourists_data = {}; this.order_holder.find('.passport_data_input input').each(function() { var $id = $(this).attr('id'); var $val = $(this).val(); self.tourists_data[$id] = $val; }); // console.log(this.tourists_data); }, price_avia_order: function(price,avia,currency) { if (this.check_avia()) { return avia.prices[currency]; } return price; }, show_cart_save: function() { // this.order_holder.find('.rt-order_save').show(); var $res = ''; for (var i in this.cart) { var $temp = JSON.stringify(this.cart[i]); var $temp2 = JSON.parse($temp); $temp2.i_code = i; if(this.cart[i].hotel != undefined) { $res += this.render('order_hotel',$temp2); } if(this.cart[i].origin != undefined) { $res += this.render('order_avia',$temp2); } if(this.cart[i].hotels != undefined) { $res += this.render('order_tour',$temp2); } if(this.cart[i].date != undefined && this.cart[i].oper == 'excursion') { $res += this.render('order_excursion',$temp2); } if(this.cart[i].oper == 'transfers') { $res += this.render('order_transfers',$temp2); } } this.order_holder.find('.rt-order_input').html($res); // $($res).appendTo(this.order_holder.find('.rt-order_input')); this.action_order_avia(); this.widget_cart(); // alert(); }, widget_cart: function() { var $cart = this.$host.find('.rt-cart'); var $price = 0; if (this.cart.length == 0) { $cart.hide(); } else { $cart.show(); } $cart.find('ul li').hide(); // this.order_holder.find('.rt-order_save').show(); for (var i in this.cart) { if(this.cart[i].hotel != undefined) { $cart.find('.rt-cart-info-hotel').show(); } if(this.cart[i].origin != undefined) { $cart.find('.rt-cart-info-avia').show(); } if(this.cart[i].hotels != undefined) { $cart.find('.rt-cart-info-tours').show(); } if(this.cart[i].date != undefined && this.cart[i].oper == 'excursion') { $cart.find('.rt-cart-info-excursion').show(); } if(this.cart[i].oper == 'transfers') { $cart.find('.rt-cart-info-transfer').show(); } if(this.cart[i].hotel != undefined && this.check_avia()) { $price += parseInt(this.cart[i].priceavia.prices.rur); } else { $price += parseInt(this.cart[i].prices.rur); } } $cart.find('.rt-cart-button b').html($price+' ₽'); // this.action_order_avia(); // this.action_order_cart(); }, add_order_block: function() { this.order_holder.find('#passport').html(this.render('passport_block')); }, add_order_tourists: function() { var $adult = this.data_form.adult; var $child = 0; var $inf = 0; var $form = ''; for (var i in this.data_form.child) { var $age = this.data_form.child[i]; if ($age > 12) { $adult++; } if ($age <= 12 && $age >= 2) { $child++; } if ($age < 2) { $inf++; } } var $rf = ['1','8','6','31','48']; $show_rf = true; if($rf.indexOf(this.country_id) == -1 ) { $show_rf = false; } if (this.set.avia == 1) { $form += this.render('avia_order_part',{adult: $adult, child: $child, inf: $inf,tag:1, show_rf: $show_rf,all:parseInt($inf)+parseInt($child)+parseInt($adult)}); } else { $form += this.render('order_part',{adult:this.data_form.adult, child:this.data_form.child}) } $form += this.render('action_order'); this.order_holder.find('#rt-order-tourists').html($form); this.get_tourists_data(); if (this.set.avia == 1) this.aviaOrdersOptions(); if (this.set.avia == 0) this.applyMask(); // console.log(this.set.avia); // action_order }, get_tourists_data: function() { for (var i in this.tourists_data) { if (this.order_holder.find('#'+i).length > 0) { this.order_holder.find('#'+i).val(this.tourists_data[i]); } } }, add_order_tour: function($_this) { var $code = $_this.attr('src:id'); var $key = $_this.attr('src:key'); var $list = this.lists.tours[$code]; $list.sid = this.sid; this.online_cart.push($list); var $tour = this.render('order_tour',$list); $($tour).prependTo(this.order_holder.find('.rt-order_input')); }, add_order_packet: function($_this) { var $code = $_this.attr('src:id'); var $key = $_this.attr('src:key'); var $list = this.lists.packet[$code]; $list.sid = this.sid; this.online_cart.push($list); var $tour = this.render('order_packet',$list); $($tour).appendTo(this.order_holder.find('.rt-order_input')); var $avia = this.render('order_avia',$list.flight); $($avia).appendTo(this.order_holder.find('.rt-order_input')); this.order_holder.find('.rt-delet-cart').remove(); this.order_holder.find('.rt-order_avia_cost').remove(); this.order_holder.find('.footer .content').remove(); }, add_order_avia: function(code) { var $code = code; var $list = this.lists.avia[$code]; this.online_cart.push($list); // if (typeof(to_cart) != "undefined") { // } var $avia = this.render('order_avia',$list); $($avia).appendTo(this.order_holder.find('.rt-order_input')); this.action_order_avia(); }, add_order_excursion: function($_this,$date) { var $code = $_this.attr('src:id'); var $list = this.lists.excursion[$code]; $list.select_date = $date; $list.sid = this.sid; this.online_cart.push($list); var $ex = this.render('order_excursion',$list); $($ex).appendTo(this.order_holder.find('.rt-order_input')); }, add_order_hotel: function($_this,t) { var self = this; var $room = $_this.attr('src:room'); var $code = $_this.attr('src:id'); var $key = $_this.attr('src:key'); var $avia = $_this.attr('src:avia'); var $list = this.lists[t][$code]; // var $list = this.result.hotel[$key][$code]; var $param = { hotel:$list.name+" "+$list.category, priceavia:$list.room[$room].priceavia, start:$list.start, night:$list.night, id:$list.id, roomid:$list.room[$room].code, info:$list.room[$room].info.replace('\r\n','
'), oper:$list.oper, city:this.show_city, room:$list.room[$room].name, meal:$list.room[$room].meal, currency:$list.room[$room].currency, prices:$list.room[$room].prices, price_to_pay:$list.room[$room].price_to_pay, commission:$list.room[$room].commission, }; // console.log($list); if ($avia == 1) { var $avia_res = this.render('order_avia',this.lists.avia[0]); this.online_cart.push(this.lists.avia[0]); $($avia_res).appendTo(this.order_holder.find('.rt-order_input')); this.action_order_avia(); } var $hotel = this.render('order_hotel',$param); $($hotel).appendTo(this.order_holder.find('.rt-order_input')); if (this.order_for == 'agent') { } var $cancel = { oper:$list.oper, sessionid:this.sid, session:$list.sessionid, // session2:2, start:$list.start, night:$list.night, id:$list.id, roomid:$list.room[$room].code, }; this.get('cancellation',$cancel).then(function(data) { self.order_holder.find('.rt-order_input .rt-order_hotel_cancel').html(self.render('cancelation',data)); if (typeof(data.comission) != 'undefined') { if (typeof(data.comission.comission_agent) != 'undefined') { $param.commission = data.comission.comission_agent; $param.price_to_pay = $list.room[$room].pricemin - $list.room[$room].pricemin/100* data.comission.comission_agent; if (typeof(data.comission.info) != 'undefined') { $param.info = data.comission.info.replace('\r\n','
'); } else { $param.info = ''; } } if (typeof(data.comission.comission_agent) == 'undefined') { $param.commission = 0; $param.price_to_pay = $list.room[$room].prices.rur; } } $param.cancellation = data; $param.sid = self.sid; self.online_cart.push($param); self.show_order_calc(); }); }, recalc_button_hotel: function() { this.$host.find('.rt-universal-hotels-item').each(function() { $sum = $(this).find('.rt-selected .r_price span:visible').html(); $(this).find('.rt-universal-hotels-prices .p_price').html($sum); }); }, show_info_fly: function(key) { var $res = ''; return $res; }, cost_hotel_avia: function(key,cost,currency) { var $find_avia = this.lists.avia[0]; if (typeof(currency) != "undefined") { var $avia = $find_avia.prices[currency]; } else { var $avia = $find_avia.prices[$find_avia.currency]; } var $res = parseInt($avia)+parseInt(cost); return $res; }, convert_price: function(price,valute) { var $res = price; if (valute != "rur") { $res = $res / this.courses[valute]; $res = $res.toFixed(2); } return $res; }, sklon_nights: function(to) { var $n = ['ей','ь','и','и','и','ей']; var $sk = 'eй'; if (to <6) { $sk = $n[to]; } return 'ноч'+$sk; }, clear_opers_wait: function(oper) { var $object_css = { 'tours':'#rt-universal-tours', 'hotelavia':'#rt-universal-hotelavia', 'hotel':'#rt-universal-hotel', 'avia':'#rt-universal-avia', 'excursion':'#rt-universal-excursion', 'transfers':'#rt-universal-transfers', 'packet':'#rt-universal-packet', }; if ('all' == oper) { this.$host.find('.rt-universal-filter li').removeClass('rt-searching'); } else { this.$host.find('.rt-universal-filter a[href="'+$object_css[oper]+'"]').parent().removeClass('rt-searching'); this.$host.find('.rt-universal-filter a[href="'+$object_css[oper]+'"]').parent().show(); } }, querySearch: function(oper) { if(typeof(this.tour) == 'undefined') { var $res = this.param_search.universal; } else { var $res = this.param_search.tour; } $res.tourists = this.param_search.tourists; // $res.oper = oper; // $res.nights = param.nights; // $res.day = param.day; // console.log(this.set.avia ); if (this.set.avia == 1) { var elem = this.universal.find('#rt-tour-avia'); var locationObj = JSON.parse(elem.attr('data-value')); $res.avia = locationObj.code+":"+$res.city_avia; } else { $res.avia = ''; } // alert($res.avia); this.sid = this.param_search.universal.sessionid; this.param_search.tour.sessionid = this.sid; this.param_search.universal.avia = $res.avia; // $res.sessionid = this.sid; $res.what_search = this.what_search; return $res; }, actions_left_menu: function(oper) { var self = this; this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-"+oper+"']").off(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-"+oper+"']").parent().removeClass('rt-empty'); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-"+oper+"']").on('click', function(e){ e.preventDefault(); $(this).parent().addClass('rt-active').siblings().removeClass('rt-active'); self.$host.find($(this).attr('href')).addClass('rt-active').siblings().removeClass('rt-active'); self.recalc_button_hotel(); }); }, showUniversalMaket: function() { var self = this; this.$host.find('.universal').html(this.render('showUniversalMaket')).hide(); this.$host.find('.rt-cart-button').on('click', function() { self.show_order_block(); self.action_order_cart(); self.show_order_calc(); }); this.$host.find('.rt-clear-cart').on('click', function() { self.cart = []; self.$host.find('.rt-cart').hide(); }); if (this.set.avia == 0 && typeof(this.tour) == 'undefined') { this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-hotel']").parent().addClass('rt-active').siblings().removeClass('rt-active'); this.$host.find('#rt-universal-hotel').addClass('rt-active').siblings().removeClass('rt-active'); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-hotelavia']").parent().hide(); this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-avia']").parent().hide(); this.recalc_button_hotel(); } this.get_visa(); this.show_filter(); this.widget_cart(); this.show_inform_tour(); }, show_inform_tour:function() { if (this.param_search.universal.country_id == 1) { return false; } var $res = '
'+this.trans('<$ru: Для выбора экскурсионного пакета, по интересующему Вас направлению, воспользуйтесь фильтром "город", en: To select an excursion package, in the direction of interest to you, use the filter "city" $>')+'
'; this.$host.find('#rt-universal-tours .rt-universal-filters').before($res); }, get_visa: function() { var self = this; if (this.param_search.universal.country_id == 1) { this.$host.find(".rt-universal-filter-block-item a[href='#rt-universal-visa']").parent().hide(); return false; } this.actions_left_menu('visa'); this.get('visa',{country_id: this.param_search.universal.country_id}).then(function(data) { self.$host.find('#rt-universal-visa').html(self.render('show_visa',{'visas':data})); if (self.$host.find('.rt-visa-selects') == 0) { return false; } self.$host.find('.rt-visa-selects').selectric(); self.$host.find('.rt-visa-selects').on('change', function() { self.$host.find('.rt-visas-block').hide(); self.$host.find('.rt-visas-city-'+$(this).val()).show(); }); }); }, similarSlider: function() { var slideWrap = $('.similar-wrap'); if (slideWrap.length === 0) return; var nextLink = $('.next-slide'); var prevLink = $('.prev-slide'); var slideWidth = $('.similar-open').outerWidth(true); // var newLeftPos = slideWrap.position().left - slideWidth; var newLeftPos = -80; // $('.similar-opens').height($('.similar-open').outerHeight(true)); //Костыльчик nextLink.click(function(){ if( nextLink.attr('name') == 'next' ) { nextLink.removeAttr('name'); var slideWrap = $(this).parent().find('.similar-wrap'); var newNextPos = newLeftPos; slideWrap.animate({left: newNextPos}, 500, function(){ slideWrap .find('.similar-open:first') .appendTo(slideWrap) .parent() .css({'left': 0}); }); setTimeout(function(){ nextLink.attr('name','next') }, 600); } }); prevLink.click(function(){ if( prevLink.attr('name') == 'prev' ) { prevLink.removeAttr('name'); var slideWrap = $(this).parent().find('.similar-wrap'); slideWrap .css({'left': newLeftPos}) .find('.similar-open:last') .prependTo(slideWrap) .parent() .animate({left: 0}, 500); setTimeout(function(){ prevLink.attr('name','prev') }, 600); } }); }, iataGoodTravelAction: function() { var self = this; this.$host.find('.rt-avia-search-input').on('gta-click', function(event, data, suggestionValue) { var result = (suggestionValue.name == 'Без перелёта' ? suggestionValue.name : suggestionValue.name + ' (' + suggestionValue.code + '), ' + suggestionValue.country_name); if (suggestionValue.name == 'Без перелёта') { self.set.avia = 0; self.$host.find('#rt-search-param-hotelavia').prop('checked',false); self.$host.find('#rt-search-param-avia').prop('checked',false); } else { self.set.avia = 1; self.$host.find('#rt-search-param-hotelavia').prop('checked',true); self.$host.find('#rt-search-param-avia').prop('checked',true); } $(this).val(result); $(this).attr('data-value', JSON.stringify(suggestionValue)); var $label = $(this).prev(); $label.addClass('rt-label-open'); }); this.$host.find('.rt-avia-search-input').on('gta-exit', function() { var suggestionValue, result; if ( $(this).attr('data-value') ) { try{ suggestionValue = JSON.parse($(this).attr('data-value')); result = (suggestionValue.name == 'Без перелёта' ? suggestionValue.name : suggestionValue.name + ' (' + suggestionValue.code + '), ' + suggestionValue.country_name); $(this).val(result); } catch(e){ console.error('нераспарсило', e); } } }); this.$host.find('.rt-avia-search-input').on('focus',function() { var $label = $(this).prev(); $label.addClass('rt-label-open'); }).on('blur', function() { var $label = $(this).prev(); var $this = $(this); if ($this.val() == '') { $label.removeClass('rt-label-open'); } }); }, notification: function(data) { var doc = $(data).parent().parent().parent().find('.rt-doctype').val(); var str = ['I','X','M','L','V','C','D']; if (doc == "BIRTHDAY_NOTIFICATION") { var val = $(data).val().replace(/_/g, '');; if (val.length == 1) if (str.indexOf(val.toUpperCase()) == '-1') { $(data).val(''); alert('В свидетельстве о рождении первые цифры пишутся римские. Пример: I, X, V и тд.'); } } }, aviaOrdersOptions: function() { var self = this; this.order_holder.find('.rt-series').on('keyup', function(){ self.notification($(this)); }); if (1 == 1) { this.order_holder.find('.rt-fio-avia').mask('a?aaaaaaaaaaaaaaaaaaaaaaa'); this.order_holder.find('.rt-series').mask("9999999999"); } else { this.order_holder.find('.rt-fio-avia').mask('b?bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); this.order_holder.find('.rt-series').mask("9999999999"); } // if (this.avia_item.carrier != "SU") this.order_holder.find('.rt-patronymic').remove(); this.order_holder.find('.rt-citizen').hide(); this.order_holder.find('.date').mask('o9.m9.ne99'); this.order_holder.find('.rt-doctype').change(function() { var $_block = $(this).parents('.rt-order-data-avia'); if ($(this).val() == 'INTERNAL') { $_block.find('.rt-citizen').hide(); $_block.find('.date_text').text('Дата выдачи'); $_block.mask("9999999999"); } if ($(this).val() == 'FOREIGN') { $_block.find('.rt-citizen').hide(); $_block.find('.date_text').text('Дата окончания'); $_block.find('.rt-series').mask("999999999"); } if ($(this).val() == 'BIRTHDAY_NOTIFICATION') { $_block.find('.rt-citizen').hide(); $_block.find('.date_text').text('Дата выдачи'); $_block.find('.rt-series').mask("*?****************"); } if ($(this).val() == 'PASSPORT') { $_block.find('.rt-citizen').show(); $_block.find('.date_text').text('Дата окончания'); $_block.find('.rt-series').mask("d?ddddddddddddddddddd"); } }); this.order_holder.find('.rt-doctype').change(); this.order_holder.find('.rt-data-date').on('blur',function() { var date = $(this).val(); var type = $(this).attr('src:type'); var error = false; if ( date == '') { return false; } var $age = self.getAge(date); if (isNaN($age)) { return false; } if (type == 'adult' && $age < 12) { error = true; } if (type == 'child' && ( $age >= 12 || $age < 2 )) { error = true; } if (type == 'inf' && $age >=2 ) { error = true; } if (error) { $(this).val(''); self.alert('Неверный возраст'); } }); this.applyMask(); }, load_avia_params: function($form) { var self = this; $form.html(this.render('rt_avia_params',{ type:$('.rt_avia_params').length, })); $form.find('.airlinesSelectorContainer').GTAirlinesSelector(); var $avia_search_dates = $form.find('.rt-avia-src, .rt-avia-dst'); $avia_search_dates.periodpicker({ lang: 'ru', cells: [1, 2], norange: true, hideAfterSelect: true, hideOnBlur: true, yearsLine: false, fullsizeButton: false, formatDate: 'DD.MM.YYYY', formatDecoreDateWithYear: 'D MMMM', minDate: '27.04.2024', i18n: { 'ru' : { 'Select period' : 'Дата вылета', 'Choose period' : '' } }, }); if (this.lists.avia.length > 0) { var $origin = this.lists.avia[0].origin; var $start = $origin[0][0].date_from; var $stop = $origin[1][($origin[1].length - 1)].date_from; $form.find('.rt-avia-src').val( $start); $form.find('.rt-avia-dst').val($stop); } else { var $day = this.param_search.universal.day.split(','); var $nights = this.param_search.universal.nights.split(','); var $stop = new rt.Date($day[0],'d.m.Y'); $stop.addDays(parseInt($nights[0])); $form.find('.rt-avia-src').val($day[0]); $form.find('.rt-avia-dst').val($stop.format('d.m.Y')); } $avia_search_dates.periodpicker('change'); $form.find('.rt-search-avia').on('click',function() { self.search_avia($form); }); $form.find('.rt-aviaclass').selectric(); }, action_universal_avia: function() { if (this.$host.find('#rt-universal-avia .rt-avia-params').text() == '') { this.load_avia_params(this.$host.find('#rt-universal-avia .rt-avia-params')); } var self = this; this.$host.find('#rt-universal-avia .rt-button-order').on('click',function() { if (self.check_double_cart('avia')) { self.alert('У Вас заказан авиаперелёт.'); return false; } self.show_order_block(); self.add_order_avia($(this).attr('src:id')); self.action_order_cart(); self.show_order_calc(); }); this.action_avia_slider(); }, action_avia_slider: function() { $('.similar-open').on('click',function() { var $_this = $(this); var $parent = $_this.parents('.rt-avia-similar'); $_this.addClass('active').siblings().removeClass('active'); var $id = $_this.attr('src:sim'); $parent.find('.ticket').addClass('rt-hide'); $parent.find('.ticket-'+$id).removeClass('rt-hide'); }); this.similarSlider(); }, search_avia: function($form) { $form.parent().find('.tickets').addClass('rt-blur'); $form.addClass('rt-blur'); $form.find('.rt-search-avia').html('
ПОИСК
'); var self = this; var noco = $form.find('input[name="rt-noconnect"]:checked').val(); if (noco == undefined) noco = 1; else noco = 0; var $param = { 'city':this.param_search.universal.avia, 'day':$form.find('.rt-avia-src').val()+','+$form.find('.rt-avia-dst').val(), 'filter_carrier':$form.find('.airlinesSelectorContainer').data('gta-value'), 'class':$form.find('.rt-aviaclass').val(), 'noconnect':noco, 'tourists':this.param_search.tourists, }; this.search_avia_request($param, $form); }, search_avia_request: function($param, $form) { var self = this; this.get('request_avia',$param).then(function(data) { self.replace_data_avia(data); if (typeof($form) != 'undefined') { $form.find('.rt-search-avia').text('ПОДОБРАТЬ'); $form.parent().find('.tickets').removeClass('rt-blur'); $form.removeClass('rt-blur'); } else { //Выводим результат для первого поиска туров self.edit_avia('Добавить авиаперелёт'); } }); }, replace_data_avia: function(data) { if (data.find.length == 0) { this.alert('По данному запросу перелётов не найдено'); return; } this.avia_structure = data.structure.there_and_back; this.avia_min_sum = data.min_sum; this.lists.avia = data.find; this.show_result_for_all_find('avia'); if (this.$host.find("#order_dialog").is(":visible")) { this.edit_avia_find(0); } }, action_order_avia: function() { var self = this; this.order_holder.find('.rt-replacement-flight').on('click',function() { self.order_add_to_cart(); $(this).hide(); self.edit_avia('Заменить авиаперелёт'); }); }, edit_avia: function(title) { this.edit_history('#edit-avia'); var self = this; this.edit_fly = true; var $sum = 0; for (var i in this.cart) { if (typeof(this.cart[i].origin) != 'undefined') { $sum = this.cart[i].prices.rur; } } this.order_holder.find('.rt-order_avia_edit').hide(); this.order_holder.find('.rt-order_input, .rt-order_button, #rt-order-tourists, .rt-order_calc, .rt-order_button_complete').hide(); this.order_holder.find('.rt-order_avia_edit').html(this.render('rt_order_avia_edit',{title:title})); this.load_avia_params(this.order_holder.find('.rt-order_avia_edit-param')); this.edit_avia_find($sum); this.order_holder.find('.rt-order_avia_edit').animate({height: "show"}, 500); this.order_holder.find('.avia_edit_back').on('click',this.proxy(this.edit_avia_close)); }, edit_avia_find: function($sum) { var self = this; var data = { data:this.lists.avia, structure:this.avia_structure, sum:$sum }; this.order_holder.find('.rt-order_avia_edit-res').html(this.render('rt_universal_avia',data)); this.action_avia_slider(); this.order_holder.find('.rt-order_avia_edit .rt-button-order').on('click',function() { var $id = $(this).attr('src:id'); var $send = [] for (var i in self.cart) { if (typeof(self.cart[i].origin) == 'undefined') { $send.push(self.cart[i]); } } $send.push(self.lists.avia[$id]); self.cart = $send; self.edit_avia_close(); }); }, edit_avia_close: function() { this.show_cart_save(); this.show_order_calc(); this.action_order_cart(); this.order_holder.find('.rt-order_avia_edit').html(''); this.scrollAnimate('.hotel_search_form'); this.order_holder.find('.rt-order_input, .rt-order_button, #rt-order-tourists, .rt-order_calc, .rt-order_button_complete').show(); this.edit_history('#order-block'); }, add_avia_for_tour: function(data) { var $start = data.day; var $stop = new rt.Date($start,'d.m.Y'); $stop.addDays(parseInt(data.nights)); var $param = { 'city':this.param_search.universal.avia, 'day':$start+','+$stop.format('d.m.Y'), 'filter_carrier':'', 'class':0, 'noconnect':1, 'tourists':this.param_search.tourists, }; // this.get('searche_avia_table',this.querySearch()).then(function(data) { // self.tour_avia_table = data; // if (!self.searching) { // self.outputTableDay('all'); // } // }); // this.get('searche_avia_table_one',this.querySearch()).then(function(data) { // self.tour_avia_table_one = data; // if (!self.searching) { // self.outputTableDay('one'); // } // }); this.search_avia_request($param); console.log(data); }, outputTableDay: function(type) { var self = this; if (type == 'all') { if (typeof(this.avia_table.table) == 'undefined') { return; } var tabday = this.avia_table.table.day; var tabdaystruc = this.avia_table.table.struc; } else { if (typeof(this.avia_table_one.table) == 'undefined') { return; } var tabday = this.avia_table_one.table.day; var tabdaystruc = this.avia_table_one.table.struc; } if (tabday == null) { this.$host.find('.rt-avia-table-'+type).hide(); return; } this.$host.find('.rt-searching-avia').remove(); //Вычисление отсортированного массива уникальных цен var prices = []; var min_sum = {}; var night = this.param_search.universal.nights.split(','); night = night[0]; //Получение уникальных цен for (var thereIndex in tabday) { for (var backIndex in tabday[thereIndex]) { var sum = tabday[thereIndex][backIndex][0]; if (prices.indexOf(sum) === -1) prices.push(sum); } } for (var td in tabdaystruc) { var $d1 = tabdaystruc[td][0]; var $d2 = tabdaystruc[td][1]; if (typeof(tabday[$d1]) != 'undefined') { if (typeof(tabday[$d1][$d2]) != 'undefined') { if (typeof(tabday[$d1][$d2][0]) != 'undefined') { var sum = tabday[$d1][$d2][0]; min_sum[$d1] = sum; } } } } //Цвета для раскраски таблицы var priceColorScheme = { min: '#EAFFCF', mid: '#FFFFFF', max: '#FFEFF5' }; //Лучшая цена var bestPrice;; //Объект: {цена1:цвет1, цена1:цвет1} var pricesColor = {}; this.avia_table_min_sum[type] = min_sum; //Если цена одна, то таблица белая if (prices.length === 1) { pricesColor[prices[0]] = priceColorScheme.mid; bestPrice = null; } else { //Сортировка цен по возрастанию prices.sort(function(a, b) { return a - b; }); //Лучшая цена для звездочки bestPrice = prices[0]; //Инициализируем генератор градиентов var rainbow = new Rainbow(); //Устанавливаем цвета градиента rainbow.setSpectrum(priceColorScheme.min, priceColorScheme.mid, priceColorScheme.mid, priceColorScheme.max); //Устанавливаем диапазон rainbow.setNumberRange(0, prices.length - 1); //Заполняем объект цена -> цвет for (var priceIndex = 0; priceIndex < prices.length; priceIndex++) { pricesColor[prices[priceIndex]] = '#' + rainbow.colourAt(priceIndex); } } if (type == 'all') { var dayto = this.avia_table.table.dayArr[0]; var dayback = this.avia_table.table.dayArr[1]; var airName = this.avia_table.airlines; } else { var dayto = this.avia_table_one.table.dayArr[0]; var dayback = this.avia_table_one.table.dayArr[1]; var airName = this.avia_table_one.airlines; } var $render = this.render('tableDay', { 'data': tabday, 'to': dayto, 'from': dayback, 'airName': airName, 'avia_min_sum': this.avia_min_sum, 'pricesColor': pricesColor, 'bestPrice': bestPrice, 'sum': 0, // 'self': this }); //табличка для туров var $render_hotel = this.render('tableDay', { 'data': tabday, 'to': dayto, 'from': dayback, 'airName': airName, 'pricesColor': pricesColor, 'avia_min_sum': this.avia_min_sum, 'bestPrice': bestPrice, 'sum': this.min_price.hotel, // 'self': this }); $render = '
'+(type == 'all' ? "Все перелёты" : "Перелёты без пересадок")+'
'+$render; this.$host.find('#rt-universal-avia .rt-avia-table .rt-avia-table-'+type).html($render); this.$host.find('#rt-universal-avia .rt-avia-table').show(); $render_hotel = '
'+(type == 'all' ? "Туры с вылетом на соседние даты" : "Туры с вылетом на соседние даты, без пересадок.")+'
'+$render_hotel; this.$host.find('#rt-universal-hotelavia .rt-avia-table .rt-avia-table-'+type).html($render_hotel); this.$host.find('#rt-universal-hotelavia .rt-avia-table').show(); this.$host.find('.rt-avia-table .rt-avia-table-'+type+' .hasData').click(function() { // Ссыока на ячейку start var $cell = $(this); self.start_seacrh_to_table($cell.attr('src:to'),self.getNightsToTable($cell.attr('src:to'),$cell.attr('src:from'))); }); this.$host.find('.rt-avia-table .rt-avia-table-'+type+' .rt-avia-table-title').on('click',function(){ $(this).parent().toggleClass('open-table'); var table = $(this).next(); if (table.is(':visible')) { table.hide(); } else { table.show(); } }); this.show_date_min_price(); }, calcFinalPrice: function(sum,dop,to,from) { var result = { //sum - цена с учетом комиссий //formatted - форматированная цена "12 345" //tax - сбор агента }; if (dop != 0) { var night = this.getNightsToTable(to,from); sum = parseInt(sum) + (parseInt(dop)*night); } result.sum = sum; //Форматирование '12 345' result.formatted = this.formatPrice(result.sum); if (dop != 0) { result.formatted = night+' '+this.sklon_nights(night)+'
от '+result.formatted; } return result; }, //Форматирует число 12345 в '12 345' formatPrice: function(price) { return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' '); }, show_date_min_price: function(price) { if ( this.$host.find('.lowerPriceAlertAvia').length > 0 || this.lists.avia.length == 0 ) { return; } var $min = this.lists.avia[0].price; var self = this; for (var i in this.avia_table_min_sum.all) { if (this.avia_table_min_sum.all[i] < $min) { $min = this.avia_table_min_sum.all[i]; } } for (var i in this.avia_table_min_sum.all) { if (this.avia_table_min_sum.all[i] == $min) { break; } } if ($min == this.lists.avia[0].price) { return; } var $res = '
Заезд c '+i+' дешевле на '+(parseInt(this.lists.avia[0].price - this.avia_table_min_sum.all[i]))+' рублей
'; this.$host.find('#rt-universal-hotelavia .rt-res').before($res); this.$host.find('#rt-universal-hotelavia .lowerPriceAlertAvia button').on('click',function(e) { if (self.searching) { self.alert('Производится поиск. Пожалуйста подождите.'); return; } var start = $(this).data('start'); e.preventDefault(); self.start_seacrh_to_table(start); }); }, start_seacrh_to_table: function(start,night) { var self = this; clearInterval(this.search_interval); this.resetSearch(); if (typeof(night) != 'undefined') { this.tourNightsWidget.setValue({from: night, to: night},false); } this.universalCalendar.val(start) this.universal.find('#rt-search-date-stop').val(start); this.param_search.universal.day = start+','+start; this.universalCalendar.periodpicker('change'); setTimeout(function() { self.universalSearch(); },500); }, scanAviaTable: function() { var self = this; var $table_all = this.$host.find('#rt-universal-hotelavia .rt-avia-table-all'); $table_all.find('.bestPrice').remove(); this.$host.find('#rt-universal-hotelavia .rt-avia-table-one .hasData').each(function() { var $to = $(this).attr('src:to').replace(".","").replace(".",""); var $from = $(this).attr('src:from').replace(".","").replace(".",""); var $class='.ts'+$to+'-'+$from; $table_all.find($class ).prepend(''); $table_all.find($class ).attr('title','Есть прямой перелёт'); }); this.$host.find('#rt-universal-hotelavia .rt-avia-table-one .bestPrice').remove(); this.$host.find('#rt-universal-hotelavia .rt-avia-table-one .hasData').attr('title','Есть прямой перелёт').prepend(''); }, orderOther: function(id) { this.showOrderHolder(this.render('order')); id = id.replace(/[^0-9]/g, ''); id = parseInt(id); this.getOrderOther(id); this.getCitySearch(); }, showOverlay: function(){ this.overlay.height(rt.$(document).height()); this.overlay.show(); }, showOverlayOffice: function(){ this.overlayOffice.height(rt.$(document).height()); this.overlayOffice.show(); }, showOverlayAlert: function(){ this.overlayAlert.height(rt.$(document).height()); this.overlayAlert.show(); }, showOverlaySelect: function(){ this.overlaySelect.height(rt.$(document).height()); this.overlaySelect.show(); }, disableControls: function(){ if(this.disabled) return; this.disabled = this.hotel_search_form.find('input, select').not(':disabled'); this.disabled.prop('disabled', true); this.$host.find('.services-info').addClass('disabled'); this.hotel_search_form.find('select').selectric('refresh'); this.hotel_search_form.find('.tourHotel-block').css({'opacity':'0.5'}); this.hotel_search_form.find('.jq_flyInput').css({'opacity':'0.5'}); }, enableControls: function(){ if(this.disabled && this.disabled.length) this.disabled.prop('disabled', false); this.disabled = false; this.$host.find('.services-info').removeClass('disabled'); this.hotel_search_form.find('select').selectric('refresh'); this.hotel_search_form.find('.tourHotel-block').css({'opacity':'1'}); this.hotel_search_form.find('.jq_flyInput').css({'opacity':'1'}); }, nightvalue: function() { var d = this.$host.find('.start #rt-hotel-start').val().split('.'); var start = Date.parse(d[2] + '/' + d[1] + '/' + d[0]); var d = this.$host.find('.stop #rt-hotel-stop').val().split('.'); var stop = Date.parse(d[2] + '/' + d[1] + '/' + d[0]); var day = 3600*24*1000; var nights = ((stop - start)/day); this.nights.setValue(nights); }, recalculateEnd: function(day){ if (day == undefined) day = 4; day = parseInt(day); var nextWeek = new rt.Date(new Date); nextWeek.addDays(day); nextWeek = nextWeek.format('d.m.Y'); return nextWeek; }, recalculateEndSatrt: function(z){ if (isNaN(z)) { z = 7; this.nights.setValue(z); } var d = this.$host.find('.start #rt-hotel-start').val().split('.'); var start = Date.parse(d[2] + '/' + d[1] + '/' + d[0]); var nextWeek = new rt.Date(start); nextWeek.addDays(parseInt(z)); nextWeek = nextWeek.format('d.m.Y'); this.$host.find('.stop #rt-hotel-stop').val(nextWeek) }, getCourses: function() { var self = this; this.get('courses').then(function(data){ self.courses = data; }); }, buttonSearchProces: function() { var self = this; var $text = this.$host.find('.buttonSearchProces').html(); this.$host.find('.rt-button-searche').off(); this.$host.find('.buttonSearchProces').hover(function() { $(this).html('СТОП'); }, function() { $(this).html($text); }); this.$host.find('.buttonSearchProces').on('click',function() { self.aborts(); clearInterval(self.search_interval); self.resetSearch(); }); }, resetSearch: function() { // this.enableControls(); this.$host.find('.rt-button-searche').html('ПОИСК').removeClass('buttonSearchProces').unbind('mouseenter mouseleave click'); this.$host.find('.rt-button-searche').on('click', this.proxy(this.universalSearch)); this.$host.find('.rt-disabled-form').hide(); this.$host.find('.search-block').removeClass('disabled'); this.load_opers = 0; this.searching = false; }, show_message: function(txt,classes) { this.$host.find('.rt-form-messages').html(txt).show(); if (typeof(classes) != 'undefined' && classes != '') { this.$host.find('.rt-form-messages').addClass(classes); } }, hide_message: function(txt) { this.$host.find('.rt-form-messages').html('').hide(); }, search: function(){ this.$host.find('.message').html(''); this.$host.find('.hotels').html(''); this.$host.find('.rt-paginator').remove(); this.$host.find('div.buttonSearch').html('
Поиск
').addClass('buttonSearchProces'); this.buttonSearchProces(); if (this.tourID !='') this.$host.find('div.buttonSearch').html('
расчёт
').addClass('buttonSearchProces'); this.disableControls(); if (this.action == "hotel") this.searchHotel(); if (this.action == "transfer") this.searchTransfer(); if (this.action == "excursion") this.searchExcursion(); if (this.action == "avia") this.searchAvia(); if (this.action == "tour") this.tourSearch(); if (this.action == "catalog") this.catalogSearch(); }, disabledFormPeople: function() { this.$host.find('.adult select').prop('disabled', true); this.$host.find('.children select').prop('disabled', true); this.$host.find('.ages select').prop('disabled', true); this.$host.find('.hotel_search_form select').selectric('refresh'); }, enableFormPeople: function() { if (this.cart.tourist == undefined) { this.$host.find('.adult select').prop('disabled', false); this.$host.find('.children select').prop('disabled', false); this.$host.find('.ages select').prop('disabled', false); this.$host.find('select').selectric('refresh'); } }, addresCorrect: function(data) { for(var i = 0; i < data.length; i++){ if (data[i].address != null) { data[i].address = data[i].address.replace('"',''); data[i].address = data[i].address.replace('"',''); } if (data[i].phone != "" && data[i].phone != null) { //data[i].phone = data[i].phone.replace('"',''); //data[i].phone = data[i].phone.replace('"',''); } } return data; }, addSorts: function(){ var self = this; var sorts = this.render('sorts'); this.sorts_holder = this.$host.find('div.vfob p.hotels_sorts').eq(0); this.sorts_holder.html(sorts); this.sorts_holder.find('.ts-map > span.tobr').on('click', function(e){ $(this).removeClass('active'); self.sort(rt.$(this).attr('param')); } ); this.sorts_holder.find('.ts-map button').on('click', function(e){ if (self.sorts_holder.find(".ts-map button").html() == "Показать карту") { self.$host.find(".vfob_maps").show(); if (self.$host.find(".vfob_maps").html() == '') self.filterMaps(); self.sorts_holder.find(".ts-map button").html('Скрыть карту'); } else { self.$host.find(".vfob_maps").hide(); self.sorts_holder.find(".ts-map button").html('Показать карту'); } }); this.sorts_holder.find('.convert-valute-bl span').on('click', function(e){ rt.$(e.target).siblings().removeClass('active').addClass('noactive'); rt.$(e.target).removeClass('noactive').addClass('active'); self.changeCurrency(rt.$(e.target).attr('param')); }); this.sorts_holder.find('.convert-valute-bl span[param="'+this.currency.getValue()+'"]').siblings().removeClass('active').addClass('noactive'); this.sorts_holder.find('.convert-valute-bl span[param="'+this.currency.getValue()+'"]').removeClass('noactive').addClass('active'); }, addPager: function(){ var self = this; this.emptyPager(); var pager_data = {'page': parseInt(self.page)-1, 'pages': self.pages}; var paginator = this.render('paginator', pager_data); this.$host.find('.tableResult .result_hotel_item').after(paginator); this.$host.find('.rt-paginator a.nav').each(function(index){ if($(this).hasClass('prev')){ $(this).on('click', function(){ self.toPage(parseInt(self.page)-1); return false; }); } else if($(this).hasClass('next')){ $(this).on('click', function(){ self.toPage(parseInt(self.page)+1); return false; }); } else{ var page = $(this).attr('href').replace(/[^0-9]/,''); if(page) $(this).on('click', function(){ self.toPage(page); return false; }); } }); }, getAge: function(born){ born = born.split('.'); born = new Date(parseInt(born[2]), parseInt(born[1]), parseInt(born[0])); var current = new Date(); var difference = current.getTime() - born.getTime(); difference = new Date(difference); return difference.getFullYear()-1970; }, showError: function(){ this.animation_counter = 6; this.animateError(this.order_errors, 6, 1); this.order_error_messages = []; this.color = 1; }, animateError: function(data, counter, color){ var self = this; if(!counter){ return false; } counter--; var i; if(color){ for(i=0; i < data.age.length; i++){ rt.$(data.age[i]).addClass('input_error'); } for(i=0; i < data.empty.length; i++) { rt.$(data.empty[i]).addClass('input_error'); } color = 0; } else{ for(i=0; i < data.age.length; i++){ rt.$(data.age[i]).removeClass('input_error'); } for(i=0; i < data.empty.length; i++){ rt.$(data.empty[i]).removeClass('input_error'); } color=1; } window.setTimeout(function(){ self.animateError(data, counter, color); }, 500); }, getCitySearch: function() { var self = this; if (this.listCity != undefined) return false; this.getApi().get('geo', 'IpInfo', {ip:this.ip}).then(function(dataIp){ self.getApi().get('geo', 'listCityFranOffice', {version: '2'}).then(function(data){ var subdomain = ''; self.listCity = data; self.getAddCity = dataIp.city; /*for (var i in data) if (data[i].name == dataIp.city) subdomain = i; if (subdomain != '') { var action = $('#rt-orderform').attr('action'); action = action.replace('ross-tur.ru',subdomain+'.ross-tur.ru'); $('#rt-orderform').attr({action:action}); }*/ }); }); }, showOffice: function() { var self = this; this.showOfficeTooltip(self.render('showOffice',{city:this.listCity,check:self.getAddCity})); this.showOfficeInCity(); this.office_holder.find('select').change(); }, showOfficeInCity: function(list_item) { var self = this; var city = this.office_holder.find('select option:selected').text(); this.office_holder.find('select').change(function() { self.getApi().get('geo', 'listFranOfficeInCity', {version: '2',id:$(this).val()}).then(function(data){ self.office_holder.find('.officeInCity').html(self.render('showOfficeInCity',{data:data.office})); self.office_holder.find('.officeInCity li').on('click', function(){ self.get('sendFranch', { email:$(this).attr('data:email'), data:city+', '+$(this).attr('data:office'), email_tur:$('#rt-email').val(), phone_tur:$('#rt-phone').val(), post:self.sid, version:self.version, }).then(function(dataOp){ self.alert('Отправлено в офис'); self.office_holder.find('#close_office_dialog a').click(); self.order_holder.find('#close_order_dialog a').click(); }); }); }); }); }, setPages: function(all){ this.pages = Math.ceil(all/20); }, setPagesOrder: function(all){ return Math.ceil(all/20); }, toPageForMaps: function(page,i){ $(".rt-paginator td a").each(function() { if($(this).text() == page) {$(this).click(); return;} }); $('html,body').animate({scrollTop:$('#rt-result-'+i).offset().top-30},500); $('#rt-result-'+i).animate({opacity:0},800,function(){$('#rt-result-'+i).animate({opacity:1},800);}); $('#rt-result-'+i+'-name').animate({opacity:0},800,function(){$('#rt-result-'+i+'-name').animate({opacity:1},800);}); }, emptyPager: function(){ this.$host.find('.rt-paginator').remove(); }, sortRoomsResults: function(item){ var number; item.rooms_sorted = [[], false, false]; for(var i in item.room){ number = this.suggestRoom(item.room[i]); if(number === false){ continue; } if(number){ while(item.rooms_sorted[number]===false) { number++; } } item.rooms_sorted[number].push(item.room[i]); } return item; }, loadShow: function() { this.$host.find('.rt-load').show(); }, loadHide: function() { this.$host.find('.rt-load').hide(); }, getListItemOfHotelTitle: function(button){ var id = $(button).attr('src:id'); id = parseInt(id); return this.list[id]; }, order: function(list_item){ this.showOrderHolder(this.render('order')); this.getHotelInfo(list_item); }, edit_history: function(hash) { if (typeof(hash) != 'undefined') { history.pushState(null, null, hash); } }, showOrderHolder: function(content){ var self = this; // this.showOverlay(); this.order_holder = rt.$('#order_dialog'); this.order_holder.html(content); // history.pushState(null, null, '#order-block'); this.edit_history('#order-block'); this.bindOrderDialogCloseActoion(); this.$host.find('.hotel_search_form').hide(); this.$host.find('.universal').animate({height: "hide"}, 500); this.order_holder.animate({height: "show"}, 500); }, showOrderTooltip: function(content){ text = ('
'); this.order_holder = rt.$('#hotel-tooltip'); this.order_holder.html(text); this.order_holder.show(); this.bindOrderCloseActoion(); var t = $(content).position().top, l = $(content).position().left; this.order_holder.css({'top':t+515,'left':l+70,'width':260}); }, showOfficeTooltip: function(content){ var self = this; this.showOverlayOffice(); this.office_holder = rt.$('#hotel-office-tooltip'); this.office_holder.html(content); var top = rt.$(window).scrollTop(), l = $('.hotel_search_form').position().left; var width = $('.hotel_search_form').width(); var margin = (width-500)/2; this.office_holder.css({'top': (top+250)+'px','left':l}); if (margin > 0) this.$host.find('#hotel-office-tooltip').css('margin-left', margin+'px'); this.office_holder.animate({height: "show"}, 500); this.office_holder.find('#close_office_dialog a').on('click', function(){ self.office_holder.animate({height: "hide"}, 500); self.overlayOffice.hide(); return false; }); }, bindOrderCloseActoion: function(){ var self = this; this.order_holder.find('#close_order_dialog a').on('click', function(){ self.order_holder.empty(); self.order_holder.hide(); self.overlay.hide(); return false; }); }, bindOrderDialogCloseActoion: function(){ var self = this; this.order_holder.find('#close_order_dialog a').on('click', function(){ self.$host.find('.hotel_search_form').show(); self.$host.find('.universal').animate({height: "show"}, 500); self.order_holder.animate({height: "hide"}, 500); self.widget_cart(); self.overlay.hide(); self.edit_history(''); // alert(typeof(self.tour)); if (typeof(self.tour) != 'undefined') { self.cart = []; } return false; }); window.addEventListener('popstate', function(e) { if (window.location.hash.toString() == '#edit-avia') { e.preventDefault(); // self.edit_avia_close(); return false; } if (window.location.hash.toString() == '#order-block') { e.preventDefault(); self.order_holder.find('#close_order_dialog a').click(); // self.edit_avia_close(); return false; } if (window.location.hash.toString() == '') { // e.preventDefault(); // self.order_holder.find('#close_order_dialog a').click(); // self.edit_avia_close(); // return false; } }); }, countAllSelectedRoomsPrice: function(list_item, currency){ var index = this.list.indexOf(list_item); var sum = 0; for(var i=0; i < list_item.room.length; i++){ //if(this.$host.find('.result_hotel_item > .rt-result').eq(index).find('.iroom .checkbox__item input[roomcode="'+list_item.room[i].roomcode+'"]:checked').length){ //sum = parseInt(sum) + parseInt(list_item.room[i].priceinothercurrency[currency]); sum = parseInt(sum) + parseInt(list_item.room[i].price); //} } if (this.set.avia == 1 && list_item.avia == '') { sum = parseInt(sum) + parseInt(this.avia_item.sum); } if (list_item.avia == 'included') { for (var i in list_item.add) { sum = parseInt(sum) + parseInt(list_item.add[i].sum); } } return Math.round(sum, 2); }, applyMask: function() { $('input[name^="rt-tourist-born"], input[name^="rt-born-pasport-deistvitelendo"]').mask('o9.m9.ne99'); $('#rt-phone').mask('+7 (999) 999 9999'); //$.mask.definitions['h'] = "[A-Fa-f0-9А-Яа-я]"; if (this.country_id == 1) { $('.passport_data_input .rt-fio').mask('bb?bbbbbbbbbbbbbbbbbb'); } else { $('.passport_data_input .rt-fio').mask('aa?aaaaaaaaaaaaaaaaaa'); } if (this.param_search.universal.country_id == 1) { // $('.passport_data_input .rt-serial').mask('hh?hhhh'); // $('.passport_data_input .rt-number').mask('hhhhh?hhhh'); } else { // $('.passport_data_input .rt-serial').mask('hh?hhhh'); // $('.passport_data_input .rt-number').mask('hhhhh?hhhh'); } }, show_order_for: function() { var self = this; if (this.order_for == 'agent') { this.$host.find('#show_order_for').html('
'); this.$host.find('.tourist-contact-item').hide(); } if (this.order_for == 'tourist') { this.passport.find('#show_order_for').html(this.render('order_for',{action: this.order_for})); this.passport.find('#show_order_for #order_for').tabs(); this.$host.find('#order_for #iAmTourist').append(this.render('iAmTourist')); this.$host.find('#order_for #iAmAgent').append(this.render('iAmAgent')); } if (this.order_for == 'agency_tourist') { this.$host.find('#show_order_for').html(this.render('agency_tourist')); } this.$host.find('#show_order_for #rt-button-office').on('click', function() { self.confirmOrder('office') }); this.$host.find('#show_order_for #rt-button-tourist').on('click', function() { self.confirmOrder('tourist'); }); this.$host.find('#show_order_for #rt-button-agency_tourist').on('click', function() { self.confirmOrder('agency_tourist'); }); this.$host.find('#show_order_for #rt-button-agency').on('click', function(e){ self.confirmOrder('agency'); return false; }); }, selection: function() { var self = this; this.showOverlaySelect(); this.$host.find('#selection').html(this.render('selection')); var top = rt.$(window).scrollTop(); var l = $('.hotel_search_form').position().left; var width = $('.hotel_search_form').width(); var margin = (width-500)/2; this.$host.find('#selection').css('top', (top+250)+'px'); this.$host.find('#selection').css('left', l+'px'); if (margin > 0) this.$host.find('#selection').css('margin-left', margin+'px'); this.$host.find('#selection').animate({height: "show"}, 500); this.selectionAction(); this.$host.find('#selection #close_selection').on('click', function() { self.$host.find('#selection').animate({height: "hide"}, 500); self.overlaySelect.hide(); return false; }); }, selectionAction: function() { var self = this; this.$host.find('#selection #iAmTourist, #selection #iAmAgent').on('click', function() { self.$host.find('#selection .selection_action').html(''); self.$host.find('#selection .selection_action').hide(); self.$host.find('#selection .selection_action').html(self.render($(this).attr('id'))); self.$host.find('#selection .selection_action').animate({height: "show"}, 500); self.selectionAction(); }); this.$host.find('#selection #rt-button-office').on('click', function() { self.showOffice('list') }); this.$host.find('#selection #rt-button-tourist').on('click', function() { self.confirmOrder('tourist'); }); this.$host.find('#selection #rt-button-agency').on('click', function(e){ self.confirmOrder('agency'); return false; }); }, startSearchForParam: function(action) { this.set.start = this.hotel_item.CityId; if (action == 'searchExcursion') { this.$host.find('.excursion_begin #rt-Exhotel-start').val(this.hotel_item.start); this.$host.find('.excursion_end #rt-Exhotel-stop').val(this.hotel_item.stop); } this.$host.find('div.buttonSearch').click(); if (action == 'searchTransfer') { this.$host.find('.tansfer_start #rt-Trhotel-start').val(this.hotel_item.start); } this.$host.find('div.buttonSearch').click(); }, filterMaps: function() { this.$host.find(".vfob_maps").html(this.render('filterMaps',{hotel: this.list})); this.map_container = 'map'; this.showMaps(); }, filterMeal: function() { var meal =""; this.$host.find('.hotel_filter .meal input').each(function(){ if ($(this).prop("checked")) meal += $(this).val()+"-"; }); return meal; }, filterConfirm: function() { var confirm =""; this.$host.find('.hotel_filter .confirm input').each(function(){ if ($(this).prop("checked")) confirm += $(this).val()+"-"; }); return confirm; }, filterStar: function() { var star =""; this.$host.find('.hotel_filter .stars input').each(function(){ if ($(this).prop("checked")) star += $(this).val()+"-"; }); return star; }, filterService: function() { var service =""; this.$host.find('.hotel_filter .service input').each(function(){ if ($(this).prop("checked")) service += $(this).val()+"-"; }); return service; }, filterHotelName: function() { return this.$host.find('.hotel_filter .hotelname input').val(); }, filterListAlf: function(letter){ this.$host.find('.hotel_filter .alf label').css({'color':'#D81910','border-bottom':'0 solid #D81910'}); var self = this; var listAlf = []; var y = 0; if (letter == 'Все') { listAlf = this.list_double; l(letter); } else { for (var i in this.list_double) { name = this.list_double[i].name; if (name[0] == letter) { listAlf[y] = this.list_double[i]; y++; } } } this.list = listAlf; this.setPages(listAlf.length); this.enableControls(); this.getHotels(); this.setSortActive('price'); //this.filterMaps(); this.$host.find('.hotel_filter .alf label').each(function() { if ($(this).text() == letter) {$(this).css({'color':'#999','border-bottom':'1px solid #D81910','margin-bottom':0});} }); }, sort: function(sort,$type){ var span; if(typeof(this.sort_direction)=='undefined') this.sort_direction = false; if(typeof(this.sortprop) == 'undefined') this.sortprop = 'price'; if(this.sortprop == sort){ this.sort_direction = !this.sort_direction; } else this.sort_direction = false; this.sortprop = sort; this.sortList($type); this.show_result_for_all_find($type); }, scrollAnimate: function(e) { $('html,body').animate({ scrollTop: $(e).offset().top }, 800); }, sortList: function($type){ var direction = this.sort_direction ? -1 : 1; var prop; switch(this.sortprop){ case 'name': prop = 'name'; break; case 'star': prop = 'starname'; break; case 'Name': prop = 'Name'; break; case 'CheckInDate': prop = 'CheckInDate'; break; case 'Duration': prop = 'Duration'; break; case 'Price': prop = 'PriceItogo'; break; case 'HotelName': prop = 'HotelName'; break; case 'RoomType': prop = 'RoomType'; break; case 'MealType': prop = 'MealType'; break; case 'price': default: prop = 'price'; break; } if (prop == 'Duration' || prop == 'Price' || prop == 'price') { var sortFunction = function(a, b){ if(parseInt(a[prop]) < parseInt(b[prop])) return -1*direction; if(parseInt(a[prop]) > parseInt(b[prop])) return direction; return 0; }; } else { var sortFunction = function(a, b){ if(a[prop] < b[prop]) return -1*direction; if(a[prop] > b[prop]) return direction; return 0; }; } // l('doshlo '+$type); // l(sortFunction); this.lists[$type].sort(sortFunction); }, }); })(rosstour);