- 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.
133 lines
4.4 KiB
PHP
133 lines
4.4 KiB
PHP
<?php
|
|
$tickets = $this->tickets;
|
|
$exclude = ['ticket-protection', 'gift-price'];
|
|
|
|
// Sortowanie: pary ulgowy/normalny obok siebie
|
|
$seen_bases = [];
|
|
foreach ($tickets as $tid => $t) {
|
|
if (in_array($tid, $exclude)) continue;
|
|
$base = preg_replace('/-(ulgowy|normalny)$/', '', $tid);
|
|
if (!in_array($base, $seen_bases)) {
|
|
$seen_bases[] = $base;
|
|
}
|
|
}
|
|
$ordered = [];
|
|
foreach ($seen_bases as $base) {
|
|
if (isset($tickets[$base . '-ulgowy']))
|
|
$ordered[$base . '-ulgowy'] = $tickets[$base . '-ulgowy'];
|
|
if (isset($tickets[$base . '-normalny']))
|
|
$ordered[$base . '-normalny'] = $tickets[$base . '-normalny'];
|
|
if (!isset($tickets[$base . '-ulgowy']) && !isset($tickets[$base . '-normalny']) && isset($tickets[$base]))
|
|
$ordered[$base] = $tickets[$base];
|
|
}
|
|
$tickets = $ordered;
|
|
?>
|
|
<div id="tickets-prices">
|
|
<div class="container">
|
|
<div class="tickets-orders">
|
|
<h1>Cennik biletow</h1>
|
|
<div style="overflow-x:auto;">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Bilet</th>
|
|
<th>Cena PN-PT</th>
|
|
<th>Cena SB-ND</th>
|
|
<th>Doplata: dzis</th>
|
|
<th>Doplata: 1-2 dni</th>
|
|
<th>Doplata: 3-7 dni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($tickets as $tid => $t) : ?>
|
|
<?php if (in_array($tid, $exclude)) continue; ?>
|
|
<tr>
|
|
<td>
|
|
<?= htmlspecialchars($t['name']); ?>
|
|
<br><small class="text-muted"><?= htmlspecialchars($tid); ?></small>
|
|
</td>
|
|
<td>
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[<?= $tid; ?>][price]"
|
|
value="<?= $t['price'] ?? ''; ?>">
|
|
</td>
|
|
<td>
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[<?= $tid; ?>][price_weekend]"
|
|
value="<?= $t['price_weekend'] ?? ''; ?>">
|
|
</td>
|
|
<td>
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[<?= $tid; ?>][day0]"
|
|
value="<?= $t['dynamic_prices']['day0'] ?? ''; ?>">
|
|
</td>
|
|
<td>
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[<?= $tid; ?>][day1_2]"
|
|
value="<?= $t['dynamic_prices']['day1_2'] ?? ''; ?>">
|
|
</td>
|
|
<td>
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[<?= $tid; ?>][day3_7]"
|
|
value="<?= $t['dynamic_prices']['day3_7'] ?? ''; ?>">
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php $tp = $this->tickets['ticket-protection'] ?? null; ?>
|
|
<?php if ($tp) : ?>
|
|
<h3 class="mt-4">Doplaty</h3>
|
|
<div class="row mb-3" style="max-width:400px;">
|
|
<label class="col-8 col-form-label"><?= htmlspecialchars($tp['name']); ?></label>
|
|
<div class="col-4">
|
|
<input type="number" step="0.01" min="0" class="form-control"
|
|
name="tickets[ticket-protection][price]"
|
|
value="<?= $tp['price'] ?? ''; ?>">
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<button type="button" class="btn btn-t1" id="save-prices">Zapisz ceny</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('#save-prices').on('click', function() {
|
|
var postData = {};
|
|
$('input[name^="tickets["]').each(function() {
|
|
postData[$(this).attr('name')] = $(this).val();
|
|
});
|
|
|
|
$.ajax({
|
|
url: '/apanel/tickets_save/',
|
|
type: 'POST',
|
|
data: postData,
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
if (res.status === 'ok') {
|
|
$.alert({
|
|
title: 'Sukces',
|
|
content: 'Ceny zapisano',
|
|
});
|
|
} else {
|
|
$.alert({
|
|
title: 'Blad',
|
|
content: res.message || 'Wystapil blad',
|
|
});
|
|
}
|
|
},
|
|
error: function() {
|
|
$.alert({
|
|
title: 'Blad',
|
|
content: 'Nie udalo sie zapisac cen',
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|