<hr class="my-4 text-muted">
<table class="table table-borderless table-hover align-middle">
    <tbody>
        <?php foreach($incomes as $inc): ?>
        <tr>
            <td style="width: 50px;"><div class="bg-success-subtle text-success rounded p-2 text-center"><i class="fa-solid fa-plus"></i></div></td>
            <td>
                <div class="fw-bold text-dark"><?= htmlspecialchars($inc->source) ?></div>
                <small class="text-muted"><?= date('M d, Y', strtotime($inc->date_received)) ?></small>
            </td>
            <td class="text-end fw-bold text-success">+<?= number_format($inc->amount, 2) ?></td>
            <td class="text-end">
                <a href="<?= BASE_URL ?>/finance/edit/finance_incomes/<?= $inc->id ?>" class="text-secondary me-2"><i class="fa-solid fa-pen"></i></a>
                <a href="<?= BASE_URL ?>/finance/delete/finance_incomes/<?= $inc->id ?>" class="text-danger" onclick="return confirm('تأكيد الحذف؟');"><i class="fa-solid fa-trash"></i></a>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<!-- Pagination for Income -->
<?php if (isset($incomePagination) && $incomePagination['total_pages'] > 1): ?>
<nav aria-label="Income pagination">
  <ul class="pagination pagination-sm justify-content-center mt-3">
    <li class="page-item <?= ($incomePagination['current_page'] <= 1) ? 'disabled' : '' ?>">
      <a class="page-link" href="javascript:void(0)" onclick="fetchPaginatedTransactions('income', <?= $incomePagination['current_page'] - 1 ?>)">السابق</a>
    </li>
    <li class="page-item disabled">
      <span class="page-link text-muted fw-bold">صفحة <?= $incomePagination['current_page'] ?> من <?= $incomePagination['total_pages'] ?></span>
    </li>
    <li class="page-item <?= ($incomePagination['current_page'] >= $incomePagination['total_pages']) ? 'disabled' : '' ?>">
      <a class="page-link" href="javascript:void(0)" onclick="fetchPaginatedTransactions('income', <?= $incomePagination['current_page'] + 1 ?>)">التالي</a>
    </li>
  </ul>
</nav>
<?php endif; ?>
