<?php
if (!auth_can('invoices.view')) return;
$db = Database::getInstance();
$overdueCount = (int)$db->fetchColumn("SELECT COUNT(*) FROM invoices WHERE status='overdue' AND is_deleted=0");
$overdueAmount = (float)$db->fetchColumn("SELECT COALESCE(SUM(balance_due),0) FROM invoices WHERE status='overdue' AND is_deleted=0");
?>
<div class="card border-danger h-100">
    <div class="card-body">
        <div class="d-flex justify-content-between">
            <div>
                <h6 class="text-muted mb-1"><?= lang('finance.overdue_invoices') ?></h6>
                <h3 class="mb-0"><?= $overdueCount ?></h3>
                <small class="text-danger"><?= money($overdueAmount) ?></small>
            </div>
            <div class="align-self-center"><i class="fas fa-exclamation-triangle fa-2x text-danger opacity-50"></i></div>
        </div>
    </div>
</div>