<div class="row g-3 mb-4">
    <div class="col-md-3"><div class="card border-primary h-100"><div class="card-body"><h6 class="text-muted mb-1">Total</h6><h3 class="mb-0"><?= number_format($stats['total'] ?? 0) ?></h3></div></div></div>
    <div class="col-md-3"><div class="card border-warning h-100"><div class="card-body"><h6 class="text-muted mb-1">Received</h6><h3 class="mb-0"><?= number_format($stats['received'] ?? 0) ?></h3></div></div></div>
    <div class="col-md-3"><div class="card border-info h-100"><div class="card-body"><h6 class="text-muted mb-1">Deposited</h6><h3 class="mb-0"><?= number_format($stats['deposited'] ?? 0) ?></h3></div></div></div>
    <div class="col-md-3"><div class="card border-danger h-100"><div class="card-body"><h6 class="text-muted mb-1">Bounced</h6><h3 class="mb-0"><?= number_format($stats['bounced'] ?? 0) ?></h3></div></div></div>
</div>
<div class="card mb-3"><div class="card-body">
    <div class="row g-2 align-items-end" data-filter-table="checks-table">
        <div class="col-md-3">
            <select name="status_filter" class="form-select form-select-sm" onchange="DataTableHelper.reload('checks-table')">
                <option value=""><?= lang('common.all') ?></option>
                <option value="received">Received</option><option value="deposited">Deposited</option>
                <option value="cleared">Cleared</option><option value="bounced">Bounced</option>
            </select>
        </div>
        <div class="col-md-3 ms-auto text-end">
            <?php if (auth_can('installments.create')): ?>
            <a href="/advanced-finance/checks/create" class="btn btn-primary btn-sm"><i class="fas fa-plus me-1"></i><?= lang('adv_finance.register_check') ?></a>
            <?php endif; ?>
        </div>
    </div>
</div></div>
<div class="card"><div class="card-body">
    <table id="checks-table" class="table table-striped w-100"
           data-url="/advanced-finance/checks/datatable"
           data-columns='[{"data":"check_number","title":"Check #"},{"data":"bank_name","title":"Bank"},{"data":"drawer_name","title":"Drawer"},{"data":"amount","title":"Amount"},{"data":"check_date","title":"Check Date"},{"data":"member_name","title":"Member"},{"data":"status_badge","title":"Status","orderable":false},{"data":"id","title":"Actions","orderable":false,"searchable":false}]'>
        <thead><tr><th>Check #</th><th>Bank</th><th>Drawer</th><th>Amount</th><th>Check Date</th><th>Member</th><th>Status</th><th>Actions</th></tr></thead>
    </table>
</div></div>
<?php $__view->push('scripts') ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    DataTableHelper.init('checks-table', {
        columnDefs: [{targets: -1, render: function(data) { return '<a href="/advanced-finance/checks/' + data + '" class="btn btn-sm btn-outline-primary"><i class="fas fa-eye"></i></a>'; }}]
    });
});
</script>
<?php $__view->endPush() ?>