<?php
// admin/payment-calculate-test2.php - تست تک‌تک توابع

session_start();
require_once '../config/database.php';
require_once '../includes/db.php';
require_once '../includes/auth.php';
require_once '../includes/functions.php';

if (!isLoggedIn()) {
    die('لطفاً وارد شوید.');
}

echo "✅ 1. فایل لود شد<br>";

// ===== تست تابع getTaxSettings =====
try {
    $tax = getTaxSettings();
    echo "✅ 2. getTaxSettings: ";
    if ($tax) {
        echo "موفق - مالیات: " . ($tax['tax_percent'] ?? 0) . "%<br>";
    } else {
        echo "ناموفق (نتیجه خالی)<br>";
    }
} catch (Exception $e) {
    echo "❌ خطا در getTaxSettings: " . $e->getMessage() . "<br>";
}

// ===== تست تابع getSalaryAmount =====
try {
    $salary = getSalaryAmount(1, 'theoretical');
    echo "✅ 3. getSalaryAmount: ";
    if ($salary) {
        echo "موفق - مبلغ هر ساعت: " . ($salary['amount_per_hour'] ?? 0) . "<br>";
    } else {
        echo "ناموفق (نتیجه خالی)<br>";
    }
} catch (Exception $e) {
    echo "❌ خطا در getSalaryAmount: " . $e->getMessage() . "<br>";
}

// ===== تست تابع getDegreeName =====
try {
    $degree = getDegreeName(1);
    echo "✅ 4. getDegreeName: $degree<br>";
} catch (Exception $e) {
    echo "❌ خطا در getDegreeName: " . $e->getMessage() . "<br>";
}

// ===== تست تابع getCourseTypeName =====
try {
    $type = getCourseTypeName('theoretical');
    echo "✅ 5. getCourseTypeName: $type<br>";
} catch (Exception $e) {
    echo "❌ خطا در getCourseTypeName: " . $e->getMessage() . "<br>";
}

// ===== تست تابع formatPrice =====
try {
    $price = formatPrice(500000);
    echo "✅ 6. formatPrice: $price<br>";
} catch (Exception $e) {
    echo "❌ خطا در formatPrice: " . $e->getMessage() . "<br>";
}

echo "<br>🎉 تست کامل شد!";
?>