<?php
/**********************
 * DATABASE CLASS *
 **********************/
class Database {
    private $host = "localhost";
    private $db_name = "nasrcity_antibiotic_management";
    private $username = "nasrcity_nasrcity";
    private $password = "Nasrcity2024";
    public $conn;

    public function getConnection() {
        $this->conn = null;

        try {
            $this->conn = new PDO(
                "mysql:host={$this->host};dbname={$this->db_name};charset=utf8",
                $this->username,
                $this->password
            );
            $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch(PDOException $exception) {
            error_log("Database connection error: " . $exception->getMessage());
            // Don't die silently - throw exception so callers can handle it
            throw new Exception("حدث خطأ في الاتصال بقاعدة البيانات. يرجى المحاولة لاحقاً.");
        }

        return $this->conn;
    }
}

/**********************
 * APP CONFIG *
 **********************/
define('DB_HOST', 'localhost');
define('DB_NAME', 'nasrcity_antibiotic_management');
define('DB_USER', 'nasrcity_nasrcity');
define('DB_PASS', 'Nasrcity2024');

define('APP_NAME', 'نظام إدارة المضادات الحيوية');
define('APP_VERSION', '1.0.0');

define('UPLOAD_PATH', 'uploads/');
define('MAX_FILE_SIZE', 5242880); // 5MB

// Set timezone to Cairo, Egypt
date_default_timezone_set('Africa/Cairo');

