first commit
This commit is contained in:
294
templates/tickets/basket-view.php
Normal file
294
templates/tickets/basket-view.php
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php if(empty($_SESSION['basket'])){
|
||||
header ('location: /tickets/main_view/');
|
||||
exit;
|
||||
} else {
|
||||
$basket = \S::get_session('basket');
|
||||
|
||||
$giftKeys = array_filter(array_keys($basket), function ($key) {
|
||||
return strpos($key, "gift-price") !== false;
|
||||
});
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="basket_page">
|
||||
<div class="basket_content">
|
||||
<div class="container">
|
||||
<div class="box_01">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h3>BILETY</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>CENA</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>WARTOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>ZMIENIĆ ILOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>USUŃ</h3>
|
||||
</th>
|
||||
</tr>
|
||||
<?php foreach ($this->cart as $ticket_id => $combinations) : ?>
|
||||
<?php foreach ($combinations as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><?= $this->settings['tickets'][$ticket_id]['name']; ?> (x<?= $value["quantity"]; ?>)</td>
|
||||
<td><?= $value['ticket_price']; ?> zł</td>
|
||||
<td><?= $value['ticket_price'] * $value["quantity"]; ?> zł</td>
|
||||
<td>
|
||||
<?php if ( $ticket_id != 'gift-price' and $ticket_id != 'ticket-protection' ):?>
|
||||
<button class="btn_t1 add" ticket_id="<?= $ticket_id; ?>" combination_key="<?= $key; ?>">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</button>
|
||||
<button class="btn_t1 subtract" ticket_id="<?= $ticket_id; ?>" combination_key="<?= $key; ?>">
|
||||
<i class="fa-solid fa-minus"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ( $ticket_id != 'gift-price' ):?>
|
||||
<button class="btn_t1 delete" ticket_id="<?= $ticket_id; ?>" combination_key="<?= $key; ?>">
|
||||
<i class="fa-solid fa-trash-can"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<div class="basket_protection">
|
||||
<a href="/tickets/basket_view/ticket_protection=true" class="ticket_protection">Dodaj ochronę kupującego (5 zł / bilet)</a>
|
||||
<div class="basket_protection__text">
|
||||
<p>Wszystkie bilety zostaną objęte ochroną kupującego. Pozwoli Ci to na zmianę terminu biletu.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_02">
|
||||
<form action="/tickets/basketFormHandler/" method="POST">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-xs-12 basket_user_data">
|
||||
<div class="basket_user_data__wrapper">
|
||||
<h2>TWOJE DANE</h2>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="name" class="col-lg-4 col-form-label">Imię*</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="surname" class="col-lg-4 col-form-label">Nazwisko*</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="surname" name="surname" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="email" class="col-lg-4 col-form-label">Email*</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="zip_code" class="col-lg-4 col-form-label">Kod pocztowy<span class="form-vat-option">*</span></label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="zip_code" name="zip_code">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="city" class="col-lg-4 col-form-label">Miejscowość<span class="form-vat-option">*</span></label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="city" name="city">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="street" class="col-lg-4 col-form-label">Ulica<span class="form-vat-option">*</span></label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="street" name="street">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($giftKeys)) : ?>
|
||||
<div class="form-group row mb-lg-2" id="gift_address_box">
|
||||
<label for="gift_address" class="col-lg-4 col-form-label">Dane do wysyłki biletu prezentowego*</label>
|
||||
<div class="col-lg-8">
|
||||
<textarea rows="5" type="text" class="form-control" id="gift_address" name="gift_address" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="vat" class="col-lg-4 form-check-label"><strong>Chcę otrzymać fakturę VAT</strong></label>
|
||||
<div class="col-lg-8">
|
||||
<input type="checkbox" class="form-check-input" id="vat" name="vat">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-vat-box">
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="company_name" class="col-lg-4 col-form-label">Nazwa firmy*</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="company_name" name="company_name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="nip" class="col-lg-4 col-form-label">NIP*</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" id="nip" name="nip">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="regulamin" required>
|
||||
<label class="form-check-label" for="regulamin">
|
||||
*akceptuję postanowienia <a href="/tickets/regulamin/">regulaminu</a>, oraz <a href="/tickets/regulamin_biletow_prezentowych/">regulaminu biletów prezentowych</a>.
|
||||
</label>
|
||||
<div class="invalid-feedback">
|
||||
Musisz wyrazić zgodę przed przesłaniem.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-xs-12 basket_summary">
|
||||
<div class="basket_summary__wrapper">
|
||||
<h2>Suma:</h2>
|
||||
<?php
|
||||
$finalPrice = 0;
|
||||
foreach ( ( $this -> cart ) as $data => $value )
|
||||
{
|
||||
foreach ( $value as $key => $val )
|
||||
{
|
||||
$price = $val['ticket_price'];
|
||||
$quantity = $val['quantity'];
|
||||
|
||||
$finalPrice += $price * $quantity;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p><?= $finalPrice; ?> zł</p>
|
||||
<button class="buy-btn" type="submit">Płacę</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// add
|
||||
$('body').on('click', '.add', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
var data_combination_key = $(this).attr('combination_key');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/tickets/ticket_add/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
diffdays: data_combination_key,
|
||||
basket_step_1: true
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01').html(response.basket_form);
|
||||
$('.box_02 .basket_summary').html(response.basket_summary);
|
||||
}
|
||||
});
|
||||
});
|
||||
// subtract
|
||||
$('body').on('click', '.subtract', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
var data_combination_key = $(this).attr('combination_key');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/tickets/ticket_subtract/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
diffdays: data_combination_key,
|
||||
basket_step_1: true,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01').html(response.basket_form);
|
||||
$('.box_02 .basket_summary').html(response.basket_summary);
|
||||
giftAddressHandler()
|
||||
if (response.cart_count <= 0) {
|
||||
window.location.replace("/tickets/main_view/");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
//remove
|
||||
$('body').on('click', '.delete', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
var data_combination_key = $(this).attr('combination_key');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/tickets/ticket_remove/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
diffdays: data_combination_key,
|
||||
basket_step_1: true
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01').html(response.basket_form);
|
||||
$('.box_02 .basket_summary').html(response.basket_summary);
|
||||
giftAddressHandler()
|
||||
if (response.cart_count <= 0) {
|
||||
window.location.replace("/tickets/main_view/");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// vat
|
||||
$('body').on('click', '#vat', function() {
|
||||
if(this.checked) {
|
||||
$('.form-vat-box').slideDown()
|
||||
$('#nip').prop("required", true)
|
||||
$('#company_name').prop("required", true)
|
||||
$('#zip_code').prop("required", true)
|
||||
$('#city').prop("required", true)
|
||||
$('#street').prop("required", true)
|
||||
$('.form-vat-option').css("opacity", "1")
|
||||
} else {
|
||||
$('.form-vat-box').slideUp()
|
||||
$('#nip').prop("required", false)
|
||||
$('#company_name').prop("required", false)
|
||||
$('#zip_code').prop("required", false)
|
||||
$('#city').prop("required", false)
|
||||
$('#street').prop("required", false)
|
||||
$('.form-vat-option').css("opacity", "0")
|
||||
}
|
||||
})
|
||||
|
||||
function giftAddressHandler() {
|
||||
let hasGift = false;
|
||||
|
||||
$('.box_01 table tr button[ticket_id]').each(function(index, button) {
|
||||
const ticketId = $(button).attr('ticket_id');
|
||||
if (ticketId.includes('gift') && ticketId !== 'gift-price') {
|
||||
hasGift = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (hasGift) {
|
||||
} else {
|
||||
$('#gift_address_box').remove()
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user