- Created new directories and index files for controls, factory, and views. - Added .htaccess files for URL rewriting in layout and images directories. - Included a logo image in the layout/images directory. - Implemented load_prices.php to load ticket prices from the database into settings. - Developed admin panel settings page for enabling ticket sales. - Created tickets management page in the admin panel to display and edit ticket prices. - Added upgrade.php for database migrations, including creating the ticket_prices table and adding weekend price column.
368 lines
13 KiB
PHP
368 lines
13 KiB
PHP
<?php
|
|
if (isset($_POST['selected_date'])) {
|
|
$selected_date = $_POST['selected_date'];
|
|
$selected = DateTime::createFromFormat('d-m-Y', $selected_date);
|
|
$today = new DateTime();
|
|
|
|
$interval = $today->diff($selected);
|
|
$days_diff = (int)$interval->format('%r%a');
|
|
|
|
$is_weekend = in_array($selected->format('N'), ['6', '7']);
|
|
|
|
function date_price($item, $days_diff, $is_weekend = false) {
|
|
$base = $is_weekend ? ($item['price_weekend'] ?? $item['price']) : $item['price'];
|
|
|
|
if($days_diff == 0) {
|
|
$price = $base + $item['dynamic_prices']['day0'];
|
|
return $price . ' zł';
|
|
}
|
|
elseif ($days_diff == 1 || $days_diff == 2) {
|
|
$price = $base + $item['dynamic_prices']['day1_2'];
|
|
return $price . ' zł';
|
|
}
|
|
elseif ($days_diff >= 3 && $days_diff <= 7) {
|
|
$price = $base + $item['dynamic_prices']['day3_7'];
|
|
return $price . ' zł';
|
|
}
|
|
else {
|
|
return $base . ' zł';
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/pl.js"></script>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
|
|
|
<div class="tickets_calendar container" >
|
|
<form id="dateForm" method="POST">
|
|
<div class="_title">Wybierz datę przyjazdu:</div>
|
|
<input type="text" id="flatpickr" name="selected_date" value="<?= isset($_POST['selected_date']) ? htmlspecialchars($_POST['selected_date']) : ''; ?>" style="display: none;" >
|
|
</form>
|
|
</div>
|
|
|
|
<? if (isset($_POST['selected_date'])) : ?>
|
|
<div class="tickets container">
|
|
|
|
<!-- <div class="sale-box">
|
|
<h2>Do 31 marca ceny na wszystkie bilety <span>-20%</span></h2>
|
|
</div> -->
|
|
|
|
<!-- Bilety indywidualne (ulgowy + normalny w parach) -->
|
|
<?php
|
|
$ulgowe = $this->settings['bilety-ulgowe'];
|
|
$normalne = $this->settings['bilety-normalne'];
|
|
$count = max(count($ulgowe), count($normalne));
|
|
?>
|
|
<div class="ticket-container">
|
|
<div class="title-container">
|
|
<h2 class="title">Bilety indywidualne</h2>
|
|
<p class="description">ulgowy (do 140cm) / normalny (od 140cm)</p>
|
|
</div>
|
|
<?php for ($i = 0; $i < $count; $i++) : ?>
|
|
<?php if (isset($ulgowe[$i])) : $item = $ulgowe[$i]; ?>
|
|
<div class="ticket">
|
|
<div class="ticket-description ticket-description--<?= $this->settings['tickets'][$item]['color']; ?>">
|
|
<h3 class="ticket__name"><?= $this->settings['tickets'][$item]['name']; ?></h3>
|
|
<p class="description">bilet całodniowy</p>
|
|
<? if($this->settings['tickets'][$item]['alert']) : ?>
|
|
<p class="ticket-alert"><?= $this->settings['tickets'][$item]['alert']; ?></p>
|
|
<? endif; ?>
|
|
</div>
|
|
<h3 class="price">
|
|
<?php echo date_price($this->settings['tickets'][$item], $days_diff, $is_weekend); ?>
|
|
</h3>
|
|
<div class="ticket-quantity">
|
|
<button class="add button" ticket_id="<?= $item; ?>">Dodaj do koszyka</button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (isset($normalne[$i])) : $item = $normalne[$i]; ?>
|
|
<div class="ticket">
|
|
<div class="ticket-description ticket-description--<?= $this->settings['tickets'][$item]['color']; ?>">
|
|
<h3 class="ticket__name"><?= $this->settings['tickets'][$item]['name']; ?></h3>
|
|
<p class="description">bilet całodniowy</p>
|
|
<? if($this->settings['tickets'][$item]['alert']) : ?>
|
|
<p class="ticket-alert"><?= $this->settings['tickets'][$item]['alert']; ?></p>
|
|
<? endif; ?>
|
|
</div>
|
|
<h3 class="price">
|
|
<?php echo date_price($this->settings['tickets'][$item], $days_diff, $is_weekend); ?>
|
|
</h3>
|
|
<div class="ticket-quantity">
|
|
<button class="add button" ticket_id="<?= $item; ?>">Dodaj do koszyka</button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endfor; ?>
|
|
</div>
|
|
|
|
<? if($selected >= DateTime::createFromFormat('d-m-Y', '28-06-2025')): ?>
|
|
<!-- Bilet ALL OPEN -->
|
|
<div class="ticket-container">
|
|
<div class="title-container">
|
|
<h2 class="title">Bilet ALL OPEN</h2>
|
|
<p class="description">bilety do wszystkich parków</p>
|
|
</div>
|
|
|
|
<? foreach($this -> settings['bilety-all-open'] as $key => $item) : ?>
|
|
<? $pattern = "/All Open -/"; ?>
|
|
<div class="ticket">
|
|
<div class="ticket-description ticket-description--<?= $this -> settings['tickets'][$item]['color']; ?>">
|
|
<!-- <h3 class="ticket__name"><?= explode( '-', $this -> settings['tickets'][$item]['name'])[1]; ?></h3> -->
|
|
<h3 class="ticket__name"><?= preg_replace($pattern, '', $this -> settings['tickets'][$item]['name']); ?></h3>
|
|
<p class="description">bilet całodniowy</p>
|
|
</div>
|
|
<h3 class="price">
|
|
<?php
|
|
echo date_price(
|
|
$this -> settings['tickets'][$item],
|
|
$days_diff
|
|
);
|
|
?>
|
|
</h3>
|
|
<div class="ticket-quantity">
|
|
<button class="add button" ticket_id="<?= $item; ?>">Dodaj do koszyka</button>
|
|
</div>
|
|
</div>
|
|
<? endforeach; ?>
|
|
</div>
|
|
<? endif; ?>
|
|
|
|
<? if($selected >= DateTime::createFromFormat('d-m-Y', '28-06-2025')): ?>
|
|
<div class="ticket-container">
|
|
<div class="title-container">
|
|
<h2 class="title">Bilety rodzinne</h2>
|
|
<p class="description">bilety dla rodzin</p>
|
|
</div>
|
|
<? foreach($this -> settings['bilety-rodzinne'] as $key => $item) : ?>
|
|
<div class="ticket">
|
|
<div class="ticket-description ticket-description--<?= $this -> settings['tickets'][$item]['color']; ?>">
|
|
<h3 class="ticket__name"><?= $this -> settings['tickets'][$item]['name']; ?></h3>
|
|
<p class="description">bilet całodniowy</p>
|
|
</div>
|
|
<h3 class="price">
|
|
<?php
|
|
echo date_price(
|
|
$this -> settings['tickets'][$item],
|
|
$days_diff
|
|
);
|
|
?>
|
|
</h3>
|
|
<div class="ticket-quantity">
|
|
<button class="add button" ticket_id="<?= $item; ?>">Dodaj do koszyka</button>
|
|
</div>
|
|
</div>
|
|
<? endforeach; ?>
|
|
</div>
|
|
<? endif; ?>
|
|
|
|
<div class="ticket-container">
|
|
<div class="title-container">
|
|
<h2 class="title">Karnety</h2>
|
|
<p class="description">Na cały sezon</p>
|
|
</div>
|
|
<? foreach($this -> settings['karnety'] as $key => $item) : ?>
|
|
<div class="ticket">
|
|
<div class="ticket-description ticket-description--<?= $this -> settings['tickets'][$item]['color']; ?>">
|
|
<h3 class="ticket__name"><?= $this -> settings['tickets'][$item]['name']; ?></h3>
|
|
<!-- <p class="description">bilet całodniowy</p> -->
|
|
</div>
|
|
<h3 class="price">
|
|
<?php
|
|
echo date_price(
|
|
$this -> settings['tickets'][$item],
|
|
$days_diff,
|
|
$is_weekend
|
|
);
|
|
?>
|
|
</h3>
|
|
<div class="ticket-quantity">
|
|
<button class="add button" ticket_id="<?= $item; ?>">Dodaj do koszyka</button>
|
|
</div>
|
|
</div>
|
|
<? endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<? endif; ?>
|
|
|
|
<div class="bottom-info">
|
|
<div class="bottom-info__description container">
|
|
<p>KASA NIE ZWRACA PIENIĘDZY ZA NIEWYKORZYSTANE ATRAKCJE ZE WZGLĘDU NA ZŁĄ POGODĘ, NAGŁĄ AWARIĘ TECHNICZNĄ ORAZ
|
|
OGRANICZONĄ PRZEPUSTOWOŚĆ DANYCH ATRAKCJI.</p>
|
|
<p>Przed zakupem biletu do Kompleksu Turystycznego BRZEZÓVKA należy zapoznać się z
|
|
<a style="color: #72b81b;" href="/tickets/regulamin/">regulaminem</a>, oraz <a style="color: #72b81b;" href="/tickets/regulamin_biletow_prezentowych/">regulaminem biletów prezentowych</a>.</p>
|
|
</div>
|
|
<div class="bottom-info__background "></div>
|
|
</div>
|
|
<div class="shopping-cart-container">
|
|
<div class="shopping-cart">
|
|
<div class="basket"><i class="fa-solid fa-ticket"></i></div>
|
|
<div class="quantity">
|
|
<p>Bilety</p>
|
|
</div>
|
|
<ul class="tickets__list">
|
|
<?php
|
|
$summary = 0;
|
|
$tickets = 0;
|
|
|
|
foreach ($this->cart as $ticket_id => $combinations) :
|
|
foreach ($combinations as $key => $value) :
|
|
$summary_ticket = $value['ticket_price'] * $value['quantity'];
|
|
$summary += $summary_ticket;
|
|
$tickets = $tickets + $value['quantity'];
|
|
|
|
?>
|
|
<li class="ticket">
|
|
<p class="ticket__description">
|
|
<?= $this->settings['tickets'][$ticket_id]['name'] . ' <span>x' . $value["quantity"] . '</span>' ?>
|
|
</p>
|
|
<p class="ticket__price">cena: <span><?= $summary_ticket ?> zł</span> </p>
|
|
<button class="ticket__button" data-ticket-id="<?= $ticket_id ?>" data-combination-key="<?= $key ?>">x</button>
|
|
</li>
|
|
<?php
|
|
endforeach;
|
|
endforeach;
|
|
?>
|
|
</ul>
|
|
<div class="sum-section">
|
|
<p>Łączna suma:</p>
|
|
<p class="sum"><?= $summary ?> zł</p>
|
|
</div>
|
|
<a href="/tickets/basket_view/" class="buy-btn">Kup teraz</a>
|
|
<button class="off-btn">x</button>
|
|
</div>
|
|
<input type="hidden" name="tickets" value="<?= $tickets ?>">
|
|
</div>
|
|
|
|
<div class="mobile-cart-btn">
|
|
<span><?php echo $tickets; ?></span>
|
|
<div class="mobile-cart-btn--img">
|
|
<img src="/layout/images/shopping-basket.svg" alt="">
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
let lastValue = null;
|
|
|
|
setInterval(function () {
|
|
const input = $('.shopping-cart-container input[name="tickets"]');
|
|
if (!input.length) return;
|
|
|
|
const currentValue = input.val();
|
|
if (currentValue !== lastValue) {
|
|
$('.mobile-cart-btn span').html(currentValue);
|
|
lastValue = currentValue;
|
|
|
|
if(currentValue == 0){
|
|
$('.mobile-cart-btn').removeClass('hide');
|
|
$('.shopping-cart-container').removeClass('shopping-cart-container--active');
|
|
}
|
|
}
|
|
}, 300);
|
|
});
|
|
|
|
|
|
$(function() {
|
|
$('body').on('click', '.mobile-cart-btn', function() {
|
|
if($('span', this).text() != 0){
|
|
$(this).addClass('hide');
|
|
$('.shopping-cart-container').addClass('shopping-cart-container--active');
|
|
}
|
|
})
|
|
})
|
|
|
|
$(function() {
|
|
$('body').on('click', '.shopping-cart .off-btn', function() {
|
|
$('.shopping-cart-container').removeClass('shopping-cart-container--active');
|
|
$('.mobile-cart-btn').removeClass('hide');
|
|
});
|
|
|
|
//add
|
|
$('body').on('click', '.add', function() {
|
|
var ticket_id = $(this).attr('ticket_id');
|
|
var date = $('#flatpickr').val();
|
|
var $btn = $(this);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
cache: false,
|
|
url: '/tickets/ticket_add/',
|
|
data: {
|
|
ticket_id: ticket_id,
|
|
date: date,
|
|
},
|
|
beforeSend: function() {},
|
|
success: function(data) {
|
|
response = jQuery.parseJSON(data);
|
|
$('.shopping-cart-container').html(response.shopping_cart);
|
|
|
|
// animacja przycisku
|
|
$btn.addClass('added');
|
|
setTimeout(function() { $btn.removeClass('added'); }, 600);
|
|
|
|
// bounce koszyka
|
|
var $cartBtn = $('.mobile-cart-btn');
|
|
$cartBtn.addClass('cart-bounce');
|
|
setTimeout(function() { $cartBtn.removeClass('cart-bounce'); }, 600);
|
|
}
|
|
});
|
|
|
|
});
|
|
//remove
|
|
$('body').on('click', '.ticket__button', function() {
|
|
var ticket_id = $(this).attr('ticket_id');
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
cache: false,
|
|
url: '/tickets/ticket_remove/',
|
|
data: {
|
|
ticket_id: ticket_id
|
|
},
|
|
beforeSend: function() {},
|
|
success: function(data) {
|
|
response = jQuery.parseJSON(data);
|
|
$('.shopping-cart-container').html(response.shopping_cart);
|
|
|
|
if (response.cart_count = 0)
|
|
$('.shopping-cart').removeClass('shopping-cart--active');
|
|
|
|
console.log($('.shopping-cart'));
|
|
|
|
|
|
}
|
|
});
|
|
});
|
|
});
|
|
//
|
|
const shoppingCart = document.querySelector(".shopping-cart");
|
|
document.addEventListener('onChange', () => {
|
|
let list = document.querySelectorAll(".ticket");
|
|
let subtract = document.querySelector(".subtract");
|
|
subtract.addEventListener("click", () => {
|
|
if (list.length === 0) {
|
|
shoppingCart.classList.remove("shopping-cart--active");
|
|
}
|
|
})
|
|
})
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var dates = [ "19-05-2025", "20-05-2025", "21-05-2025", "22-05-2025", "23-05-2025", "26-05-2025", "27-05-2025", "28-05-2025", "29-05-2025", "30-05-2025", "02-06-2025", "03-06-2025", "04-06-2025", "05-06-2025", "06-06-2025", "09-06-2025", "10-06-2025", "11-06-2025", "12-06-2025", "13-06-2025", "16-06-2025", "17-06-2025", "18-06-2025", "20-06-2025", "23-06-2025", "24-06-2025", "25-06-2025", "26-06-2025", "27-06-2025" ];
|
|
flatpickr("#flatpickr", {
|
|
inline: true,
|
|
dateFormat: "d-m-Y",
|
|
disableMobile: true,
|
|
minDate: "today",
|
|
locale: "pl",
|
|
theme: "material_blue",
|
|
disable: dates,
|
|
onChange: function(selectedDates, dateStr, instance) {
|
|
document.getElementById('dateForm').submit();
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|