<?php
// Direct test file
require_once __DIR__.'/../vendor/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';

// Handle request
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

// Override to show chart of accounts
echo '<h1>Accounting Test Page</h1>';
echo '<p>Chart of Accounts Page (Direct Access)</p>';

$accounts = [
    (object) ['id' => 1, 'code' => '1001', 'name' => 'Cash', 'type' => 'Asset', 'balance' => 50000, 'status' => 'Active'],
    (object) ['id' => 2, 'code' => '2001', 'name' => 'Loan', 'type' => 'Liability', 'balance' => 200000, 'status' => 'Active'],
];

echo '<table border="1">';
echo '<tr><th>Code</th><th>Name</th><th>Type</th><th>Balance</th></tr>';
foreach($accounts as $account) {
    echo "<tr>";
    echo "<td>{$account->code}</td>";
    echo "<td>{$account->name}</td>";
    echo "<td>{$account->type}</td>";
    echo "<td>{$account->balance}</td>";
    echo "</tr>";
}
echo '</table>';

$response->send();
$kernel->terminate($request, $response);
