Files
bilety.brzezovka.pl/autoload/factory/class.Apanel.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

89 lines
1.9 KiB
PHP

<?php
namespace factory;
class Apanel {
static public function check_delivery( $basket )
{
$add_delivery = false;
foreach ( $basket as $key => $val )
{
if ( strpos( $val['name'], 'Bilet prezentowy' ) !== false )
{
$add_delivery = true;
break;
}
}
if ( !$add_delivery )
{
foreach ( $basket as $key => $val )
{
if ( $val['product_id'] == 999999 )
{
unset( $basket[$key] );
}
}
}
return $basket;
}
static public function recalculate_ticket_protection( $basket ) {
if ( !\S::get_session( 'ticket_protection' ) )
return $basket;
$quantity = 0;
foreach ( $basket as $key => $val ) {
if( $val['product_id'] != 0 and $val['product_id'] != 999999 ) {
$quantity += $val['quantity'];
}
}
if ( $quantity > 0 )
{
foreach ( $basket as $key => $val ) {
if ( $val['product_id'] == 0 ) {
unset( $basket[$key] );
}
}
}
else
{
foreach ( $basket as $key => $val ) {
if ( $val['product_id'] == 0 ) {
unset( $basket[$key] );
}
}
}
return $basket;
}
static public function getSetting($key, $default = null)
{
global $mdb;
try {
$mdb->pdo->exec("CREATE TABLE IF NOT EXISTS site_settings (
setting_key VARCHAR(100) PRIMARY KEY,
setting_value TEXT
)");
} catch (\Exception $e) {}
$stmt = $mdb->pdo->prepare("SELECT setting_value FROM site_settings WHERE setting_key = :key LIMIT 1");
$stmt->execute([':key' => $key]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
return $row ? $row['setting_value'] : $default;
}
static public function saveSetting($key, $value)
{
global $mdb;
$stmt = $mdb->pdo->prepare("REPLACE INTO site_settings (setting_key, setting_value) VALUES (:key, :val)");
$stmt->execute([':key' => $key, ':val' => $value]);
}
}