<?php
/**
 * Enterprise HRM ERP System - Configuration File
 * No hard-coded values - all settings loaded from database
 */

// Prevent direct access
if (!defined('HRM_ACCESS')) {
    die('Direct access not allowed');
}

// Database Configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'iooneyco_account');
define('DB_PASS', 'f}49[OyPYuJ[PSro');
define('DB_NAME', 'iooneyco_account');
define('DB_CHARSET', 'utf8mb4');

// Application Configuration
define('APP_NAME', 'Enterprise HRM ERP');
define('APP_VERSION', '1.0.0');
define('BASE_PATH', dirname(__DIR__));

// Auto-detect BASE_URL based on server environment
// Works on both XAMPP (localhost) and cPanel (live hosting)
if (!defined('BASE_URL')) {
    // Method 1: Calculate from document root and actual file path
    $documentRoot = str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT'] ?? ''));
    $projectRoot = str_replace('\\', '/', dirname(__DIR__));
    
    $baseUrl = '';
    
    if ($documentRoot && strpos($projectRoot, $documentRoot) === 0) {
        // Installation is inside document root
        $baseUrl = str_replace($documentRoot, '', $projectRoot);
        $baseUrl = str_replace('\\', '/', $baseUrl);
        $baseUrl = rtrim($baseUrl, '/');
    } else {
        // Fallback: Use script directory (more reliable for some cPanel setups)
        $scriptName = $_SERVER['SCRIPT_NAME'] ?? '';
        if ($scriptName) {
            // Get directory of index.php or current script
            $scriptDir = dirname($scriptName);
            $baseUrl = ($scriptDir === '/' || $scriptDir === '.') ? '' : rtrim($scriptDir, '/');
        }
    }
    
    // Ensure BASE_URL is set (empty string for root installation)
    define('BASE_URL', $baseUrl);
}

// Session Configuration
define('SESSION_NAME', 'HRM_SESSION');
define('SESSION_LIFETIME', 3600); // Will be overridden by database setting

// Security Configuration
define('PASSWORD_MIN_LENGTH', 8);
define('PASSWORD_REQUIRE_UPPERCASE', true);
define('PASSWORD_REQUIRE_LOWERCASE', true);
define('PASSWORD_REQUIRE_NUMBER', true);
define('PASSWORD_REQUIRE_SPECIAL', true);

// File Upload Configuration
define('UPLOAD_DIR', BASE_PATH . '/uploads');
define('UPLOAD_MAX_SIZE', 5242880); // 5MB
define('ALLOWED_IMAGE_TYPES', ['image/jpeg', 'image/png', 'image/gif']);

// Error Reporting (disable in production)
define('DEBUG_MODE', true);
if (DEBUG_MODE) {
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
} else {
    error_reporting(0);
    ini_set('display_errors', 0);
}

// Timezone
date_default_timezone_set('UTC'); // Will be overridden by database setting

