<?php
// Quick test to insert a commission and verify report works
require_once 'config.php';

// Insert test commission for sale 412 with officer 1
$sale_id = 412;
$officer_id = 1;
$commission = 0.03; // 1% of 3.00

// Check if this commission already exists
$check = $conn->query("SELECT id FROM sales_commissions WHERE sale_id = $sale_id AND sales_officer_id = $officer_id");

if ($check->num_rows == 0) {
    $conn->query("INSERT INTO sales_commissions (sale_id, sales_officer_id, commission_amount) 
                 VALUES ($sale_id, $officer_id, $commission)");
    echo "✅ Test commission created for Sale #$sale_id";
} else {
    echo "Test commission already exists";
}

// Also create one for sale 404 (5450.00) - bigger amount
$sale_id_2 = 404;
$commission_2 = 54.50; // 1% of 5450

$check2 = $conn->query("SELECT id FROM sales_commissions WHERE sale_id = $sale_id_2 AND sales_officer_id = $officer_id");

if ($check2->num_rows == 0) {
    $conn->query("INSERT INTO sales_commissions (sale_id, sales_officer_id, commission_amount) 
                 VALUES ($sale_id_2, $officer_id, $commission_2)");
    echo "<br>✅ Test commission created for Sale #$sale_id_2 (Rs. $commission_2)";
}

echo "<hr>";
echo "Now check the <a href='reports/commissions.php'>Sales Commissions Report</a>";
echo "<br>Filter for December 2025 and Officer 'test' - you should see the commissions now!";
?>
