function podsumowanie(){ $('.podsumowanie').load( "ajax.php?operacja=podsumowanie", { } ); blad_html_old = $(".blad").html(); $('.blad').load( "ajax.php?operacja=blad", {}, function(){ blad_html_new = $(".blad").html(); if(blad_html_old != blad_html_new && blad_html_new.length > 4){ $('html, body').animate({scrollTop: $('#a-blad').offset().top}, 500); } }); } function glowne_info_daty(){ $('#trigger-data').load( "ajax.php?operacja=ustaw_daty", { }, function(){ glowne_info_oferta(0); //glowne_info_pokoj(); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wez_daty"} }) .done(function( msg ) { ustaw_daterange(msg.data_przyjazd, msg.data_wyjazd); }); }); } function glowne_info_oferta(id_oferta){ $('.oferta').load( "ajax.php?operacja=ustaw_oferta", { id_oferta: id_oferta }, function(){ podsumowanie(); glowne_info_pokoj(); }); } function glowne_info_oferta_zmien_data(id_oferta){ $('.oferta').load( "ajax.php?operacja=ustaw_oferta_zmien_data", { id_oferta: id_oferta }, function(){ //podsumowanie(); //glowne_info_pokoj(); glowne_info_daty(); // $.ajax({ // type: "GET", url: "ajax.php", dataType: 'json', // data: { operacja: "wez_daty"} // }) // .done(function( msg ) { // //ustaw_daterange(msg.data_przyjazd, msg.data_wyjazd); // glowne_info_daty(); // $('#modal-label').html('Zmiana daty pobytu'); // $('#modal-footer').hide(); // $('#modal-body').html('Data przyjazdu została dopasowana do oferty'); // $('#modal').modal('show'); // }); }); $('#modal-label').html('Zmiana daty pobytu'); $('#modal-footer').show(); $('#modal-body').html('
Data przyjazdu została dopasowana do oferty
'); $('#modal-footer').html('Zamknij'); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); return false; } function glowne_info_pokoj(){ $('.pokoj').load( "ajax.php?operacja=glowne_info_pokoj", { }, function(){ }); } function analytics_ga(page){ console.log(page); gtag('config', 'UA-2810694-7', {'page_path': page}); } function scroll(anchor){ $('html, body').animate({scrollTop: $('#'+anchor).offset().top}, 500); } function ustaw_daty(data_przyjazd, data_wyjazd, rodzaj){ analytics_ga('/wybor-data.html'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "daty", data_przyjazd: data_przyjazd, data_wyjazd: data_wyjazd, rodzaj: rodzaj } }) .done(function( msg ) { if(msg.oferta == 'usun'){ $('#modal-label').html('Zmiana daty pobytu'); $('#modal-footer').hide(); $('#modal-body').html(msg.komunikat); $('#modal-body').removeClass('modal-body-footer'); $('#modal').modal('show'); } else if(msg.oferta == 'zostaw'){ $('#modal-label').html('Zmiana daty pobytu'); //$('#modal-footer').hide(); $('#modal-footer').html('Zamknij'); $('#modal-body').html(msg.komunikat); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); } //podsumowanie(); glowne_info_daty(); scroll('a-daty'); }); } function ustaw_daty_czysc_oferta(data_przyjazd, data_wyjazd){ $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "daty_czysc_oferta", data_przyjazd: data_przyjazd, data_wyjazd: data_wyjazd } }) .done(function( msg ) { //podsumowanie(); glowne_info_daty(); scroll('a-daty'); }); } function ustaw_daterange(startDate, endDate){ $('#trigger-data-przyjazd').daterangepicker({ "autoApply": true, locale: { format: 'YYYY-MM-DD', opens: 'center', firstDay: 1, //"applyLabel": "Zatwierdź", //"cancelLabel": "Anuluj", "daysOfWeek": [ "Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob" ], "monthNames": [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ], }, singleDatePicker: false, startDate: startDate, endDate: endDate, minDate: '2024-04-27', //isInvalidDate: function(date) { //return (date.day() == 0 || date.day() == 6); //}, }, function(start, end, label) { //przy takich samych datach dodaj jeden dzien if(start.format('YYYY-MM-DD') == end.format('YYYY-MM-DD')){ end = end.add(1, "days"); } ustaw_daty(start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'), 'P'); }); $('#trigger-data-wyjazd').daterangepicker({ "autoApply": true, locale: { format: 'YYYY-MM-DD', opens: 'center', firstDay: 1, //"applyLabel": "Zatwierdź", //"cancelLabel": "Anuluj", "daysOfWeek": [ "Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob" ], "monthNames": [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ], }, singleDatePicker: false, startDate: startDate, endDate: endDate, minDate: '2024-04-27', //isInvalidDate: function(date) { //return (date.day() == 0 || date.day() == 6); //}, }, function(start, end, label) { //przy takich samych datach dodaj jeden dzien if(start.format('YYYY-MM-DD') == end.format('YYYY-MM-DD')){ end = end.add(1, "days"); } ustaw_daty(start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'),'W'); }); $('input[name="daterangepicker_start"]').change(function(){ //console.log('tet'); }); $('#trigger-data-przyjazd').on('show.daterangepicker', function(ev, picker) { //console.log('przyjazd'); $('.datepicker-naglowek').html('Data przyjazdu'); }); $('#trigger-data-wyjazd').on('show.daterangepicker', function(ev, picker) { picker.clearEndData(); $('.datepicker-naglowek').html('Data wyjazdu'); }); } $(function() { ustaw_daterange('2024-04-27', '2024-04-29'); $('body').on('click', '.wybierz-oferta', function(){ analytics_ga('/lista-oferta.html'); $('#modal-label').html('Wybierz ofertę'); $('#modal-footer').hide(); $('#modal-footer').html('Zamknij'); $('#modal-body').html(''); $('#modal-body').removeClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "oferta_lista"} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-body').html(msg.oferta_lista); } }); return false; }); $('#modal').on('click','.oferta-lista-wybierz', function(){ var id_oferta = $(this).data('id'); glowne_info_oferta(id_oferta); $('#modal').modal('hide'); analytics_ga('/wybor-oferta.html?oferta='+oferta_lista[id_oferta]); scroll('a-pokoj'); return false; }); $('#modal').on('click','.oferta-lista-wybierz-zmien-data', function(){ var id_oferta = $(this).data('id'); glowne_info_oferta_zmien_data(id_oferta); //$('#modal').modal('hide'); analytics_ga('/wybor-oferta.html?oferta='+oferta_lista[id_oferta]); scroll('a-pokoj'); return false; }); $('body').on('click','.oferta-szczegoly', function(){ var id_oferta = $(this).data('id'); $('#modal-label').html(''); $('#modal-footer').html(''); $('#modal-footer').show(); $('#modal-body').html(''); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "oferta_info", id_oferta:id_oferta} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-label').html(msg.oferta_nazwa); $('#modal-body').html(msg.oferta_opis); $('#modal-footer').html(msg.oferta_footer); analytics_ga('/szczegoly-oferta.html?oferta='+msg.oferta_nazwa); } }); return false; }); $('body').on('click', '.wybierz-pokoj', function(){ analytics_ga('/lista-pokoj.html'); $('#modal-label').html('Wybierz pokój'); $('#modal-footer').hide(); $('#modal-body').html(''); $('#modal-footer').html('Zamknij'); $('#modal-body').removeClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby_start"} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-body').html(msg.body); $('#modal-footer').html(msg.footer); $('#modal-footer').show(); } }); return false; }); $('body').on('click', '.wybierz-osoby-start', function(){ analytics_ga('/wybor-ilosci-osoby.html'); var ilosc_osob = $('#select_ilosc_osob').val(); var ilosc_osob_bez_pakietu = $('#select_ilosc_osob_bez_pakietu').val(); var ilosc_osob_d1 = $('#select_ilosc_osob_d1').val(); var ilosc_osob_d2 = $('#select_ilosc_osob_d2').val(); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby_start_sprawdz_ilosc", ilosc_osob:ilosc_osob, ilosc_osob_bez_pakietu:ilosc_osob_bez_pakietu, ilosc_osob_d1:ilosc_osob_d1, ilosc_osob_d2:ilosc_osob_d2 } }) .done(function( msg ) { if(msg.error == 1){ $('#ilosc_osob_blad').fadeIn(); $('#ilosc_osob_blad').html(msg.msg); $('#modal').animate({scrollTop: 0}, 500); $('#modal-footer').show(); } else { $('#ilosc_osob_blad').hide(); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby_pokoj", ilosc_osob:ilosc_osob, ilosc_osob_bez_pakietu:ilosc_osob_bez_pakietu, ilosc_osob_d1:ilosc_osob_d1, ilosc_osob_d2:ilosc_osob_d2 } }) .done(function( msg ) { if(msg.error == 1){ $('#modal-body').html(msg.pokoj_lista); $('#modal-footer').html(msg.footer); $('#modal-footer').show(); } else{ $('#modal-body').html(msg.pokoj_lista); $('#modal-footer').html(msg.footer); $('#modal-footer').show(); } }); } }); return false; }); $('body').on('click', '.wybierz-osoby-pokoj', function(){ analytics_ga('/lista-pokoj.html'); $('#modal-label').html('Wybierz pokój'); $('#modal-footer').hide(); $('#modal-body').html(''); $('#modal-footer').html('Zamknij'); $('#modal-body').removeClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby_pokoj"} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-body').html(msg.pokoj_lista); $('#modal-footer').html(msg.footer); $('#modal-footer').show(); } }); return false; }); $('#modal').on('click','.pokoj-lista-wybierz', function(){ var id_pokoj_wybrany = $(this).data('id'); analytics_ga('/wybor-pokoj.html?pokoj='+pokoj_lista[id_pokoj_wybrany]); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "ustaw_pokoj", id_pokoj_wybrany:id_pokoj_wybrany} }) .done(function( msg ) { if(msg.error){ } else{ glowne_info_pokoj(); var klucz = msg.klucz; $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby", klucz:klucz} }) .done(function( msg_osoby ) { $('#modal-label').html(msg_osoby.label); $('#modal-body').html(msg_osoby.body); $('#modal-footer').html(msg_osoby.footer); $('#modal-footer').show(); $('#modal-body').addClass('modal-body-footer'); }); } }); return false; }); $('body').on('click', '.wybierz-pokoj-osoby', function(){ analytics_ga('/wybor-pokoj-osoby.html'); var klucz = $(this).data('id'); var dodatki = $('.dodatki :input').serializeArray(); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "sprawdz_pokoj_ilosc_osob", klucz:klucz, dodatki:dodatki } }) .done(function( msg ) { if(msg == 'za_duzo'){ $('#ilosc_osob_blad').fadeIn(); $('#ilosc_osob_blad').html('Zadeklarowano za dużo osób'); $('#modal').animate({scrollTop: 0}, 500); } else if(msg == 'za_malo'){ $('#ilosc_osob_blad').fadeIn(); $('#ilosc_osob_blad').html('Wybierz ilość osób w pokojach'); $('#modal').animate({scrollTop: 0}, 500); } else if(msg == 'za_malo_pakiet'){ $('#ilosc_osob_blad').fadeIn(); $('#ilosc_osob_blad').html('W każdym pokoju musi być przynajmniej jedna osoba korzytająca z pakietu'); $('#modal').animate({scrollTop: 0}, 500); } else { $('#ilosc_osob_blad').hide(); $('#modal').modal('hide'); glowne_info_pokoj(); podsumowanie(); } }); return false; }); $('body').on('click', '.pokoj-lista-edycja', function(){ analytics_ga('/wybor-pokoj-osoby.html'); var klucz = $(this).data('id'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "wybierz_osoby", klucz:klucz} }) .done(function( msg_osoby ) { $('#modal-label').html(msg_osoby.label); $('#modal-body').html(msg_osoby.body); $('#modal-footer').html(msg_osoby.footer); $('#modal-footer').show(); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); }); return false; }); $('body').on('click', '.pokoj-lista-usun', function(){ if(confirm('Ten pokój zostanie usunięty')){ analytics_ga('/usun-pokoj.html'); var klucz = $(this).data('id'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "usun_pokoj", klucz:klucz} }) .done(function( ) { glowne_info_pokoj(); podsumowanie(); $('.wybierz-pokoj').trigger('click'); }); } return false; }); $('body').on('click','.pokoj-szczegoly', function(){ var id_pokoj = $(this).data('id'); $('#modal-label').html(''); $('#modal-footer').html(''); $('#modal-footer').show(); $('#modal-body').html(''); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "pokoj_info", id_pokoj:id_pokoj} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-label').html(msg.pokoj_nazwa); $('#modal-body').html(msg.pokoj_opis); $('#modal-footer').html(msg.pokoj_footer); analytics_ga('/szczegoly-pokoj.html?pokoj='+msg.pokoj_nazwa); } }); return false; }); $('body').on('click','.regulamin-szczegoly', function(){ analytics_ga('/szczegoly-regulamin.html'); var id_oferta = $(this).data('id'); //console.log(id_oferta); $('#modal-label').html(''); $('#modal-footer').html(''); $('#modal-footer').show(); $('#modal-body').html(''); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "warunki_rezerwacji", id_oferta: id_oferta} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-label').html(msg.regulamin_nazwa); $('#modal-body').html(msg.regulamin_opis); //$('#modal-footer').html(msg.oferta_footer); } }); return false; }); $('body').on('click','.covid-szczegoly', function(){ analytics_ga('/szczegoly-covid.html'); $('#modal-label').html(''); $('#modal-footer').html(''); $('#modal-footer').show(); $('#modal-body').html(''); $('#modal-body').addClass('modal-body-footer'); $('#modal').modal('show'); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "certyfikat_covid"} }) .done(function( msg ) { if(msg.error){ } else{ $('#modal-label').html(msg.covid_nazwa); $('#modal-body').html(msg.covid_opis); //$('#modal-footer').html(msg.oferta_footer); } }); return false; }); $('body').on('click', '.data-czysc-oferta-anuluj', function(){ $('#modal').modal('hide'); return false; }); $('body').on('click', '.data-czysc-oferta-akceptuj', function(){ analytics_ga('/wybor-data.html'); data_przyjazd = $('#data_przyjazd').val(); data_wyjazd = $('#data_wyjazd').val(); $.ajax({ type: "GET", url: "ajax.php", dataType: 'json', data: { operacja: "daty_czysc_oferta", data_przyjazd: data_przyjazd, data_wyjazd: data_wyjazd } }) .done(function( msg ) { glowne_info_daty(); scroll('a-daty'); $('#modal').modal('hide'); }); return false; }); $('body').on('click', '.modal-naglowek-tr, .dodatki-tr', function(){ id = $(this).data('id'); if($('.dodatki-lista-'+id).is(':visible')){ $('.dodatki-lista-'+id).fadeOut(); $('.dodatki-angle-'+id).removeClass('dodatki-angle-rotate'); } else { $('.dodatki-lista-'+id).fadeIn(); $('.dodatki-angle-'+id).addClass('dodatki-angle-rotate'); } }); //podsumowanie------------------- $('.zaplac-submit').click(function(){ $('#form-podsumowanie').submit(); return false; }); function faktura_dane_init(){ if( $('#faktura_vat').is(':checked') ){ $('#faktura-dane').fadeIn(); } else { $('#faktura-dane').fadeOut(); } } faktura_dane_init(); $('#faktura_vat').click(function(){ faktura_dane_init(); }); //podsumowanie------------------- $("#modal").on("hidden.bs.modal", function () { $('#modal-body').removeClass('modal-body-footer'); }); $('body').on('click', '.modal-scroll', function(){ $("#modal").animate({scrollTop: 0}, 500); }); });