Files
bilety.brzezovka.pl/load_prices.php
Jacek Pyziak 238c9ecaed Add initial files and database migration for ticket pricing system
- 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.
2026-02-23 00:17:46 +01:00

30 lines
1.1 KiB
PHP

<?php
// Ladowanie cen biletow z bazy danych do $settings['tickets']
// Wymaga: $mdb (Medoo), $settings['tickets'] (struktura z config.php)
$_dbStmt = $mdb->query('SELECT * FROM ticket_prices');
$_dbPrices = [];
if ($_dbStmt) {
foreach ($_dbStmt->fetchAll(\PDO::FETCH_ASSOC) as $_row) {
$_dbPrices[$_row['ticket_id']] = $_row;
}
}
foreach ($settings['tickets'] as $tid => &$_ticket) {
if (isset($_dbPrices[$tid])) {
$_r = $_dbPrices[$tid];
$_ticket['price'] = (float) ($_r['price'] ?? 0);
$_ticket['price_weekend'] = (float) ($_r['price_weekend'] ?? 0);
$_ticket['dynamic_prices'] = [
'day0' => (float) ($_r['dynamic_price_day0'] ?? 0),
'day1_2' => (float) ($_r['dynamic_price_day1_2'] ?? 0),
'day3_7' => (float) ($_r['dynamic_price_day3_7'] ?? 0),
];
} else {
$_ticket['price'] = $_ticket['price'] ?? 0;
$_ticket['price_weekend'] = $_ticket['price_weekend'] ?? 0;
$_ticket['dynamic_prices'] = $_ticket['dynamic_prices'] ?? ['day0' => 0, 'day1_2' => 0, 'day3_7' => 0];
}
}
unset($_ticket, $_dbStmt, $_dbPrices, $_r);