<?php
require_once 'header.php';

$pdo = db();
$stmt = $pdo->query("SELECT * FROM companies");
$companies = $stmt->fetchAll();

?>

<h2>Manage Companies</h2>

<table class="table table-striped">
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Created At</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($companies as $company): ?>
            <tr>
                <td><?php echo htmlspecialchars($company['id']); ?></td>
                <td><?php echo htmlspecialchars($company['name']); ?></td>
                <td><?php echo htmlspecialchars($company['created_at']); ?></td>
                <td>
                    <a href="#" class="btn btn-primary btn-sm">Edit</a>
                    <a href="#" class="btn btn-danger btn-sm">Delete</a>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<?php
require_once 'footer.php';
?>