<?php
// Application Constants
define('APP_NAME', 'KasirMurah.biz.id');
define('APP_VERSION', '1.0.0');

// Dynamic APP_URL - Auto-detect from current request
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';

// Get the public directory path - find 'public' folder in the URL path
$request_uri = $_SERVER['REQUEST_URI'] ?? '/';
$script_path = $_SERVER['SCRIPT_NAME'] ?? '/index.php';

// Extract public folder path
if (strpos($script_path, '/public/') !== false) {
    $public_path = substr($script_path, 0, strpos($script_path, '/public/') + 7);
    $public_path = rtrim($public_path, '/');
} else {
    // Fallback
    $public_path = '/kasirmurah/public';
}

define('APP_URL', $protocol . $host . $public_path);
define('APP_PATH', dirname(dirname(__FILE__)));

// Subscription Plans
define('SUBSCRIPTION_MONTHLY', 50000); // 50rb
define('SUBSCRIPTION_YEARLY', 500000); // 500rb (10 months = 1 year)
define('SUBSCRIPTION_TRIAL_DAYS', 1);

// Payment Status
define('PAYMENT_PENDING', 'pending');
define('PAYMENT_REVIEWING', 'reviewing');
define('PAYMENT_PAID', 'paid');
define('PAYMENT_FAILED', 'failed');
define('PAYMENT_EXPIRED', 'expired');

// Subscription Status
define('SUB_ACTIVE', 'active');
define('SUB_INACTIVE', 'inactive');
define('SUB_TRIAL', 'trial');
define('SUB_EXPIRED', 'expired');

// Session timeout (30 minutes)
define('SESSION_TIMEOUT', 1800);

// Session Name
define('SESSION_NAME', 'pos_saas_session');

// Pagination
define('ITEMS_PER_PAGE', 20);

// Date Format
define('DATE_FORMAT', 'Y-m-d');
define('DATETIME_FORMAT', 'Y-m-d H:i:s');
