
<?php $__env->startSection('title', 'Latest Paid Installments'); ?>

<?php $__env->startPush('styles'); ?>
    
    <link rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>

<style>
    :root{
        --primary:#e53935;
        --bg:#f5f5f5;
    }

    .inst-bg{
        background:var(--bg);
    }

    .inst-card{
        border-radius:12px;
        box-shadow:0 10px 24px rgba(15,23,42,.08);
        border:1px solid #e5e7eb;
        background:#fff;
    }

    .inst-header-title{
        font-weight:600;
        font-size:1rem;
    }

    .inst-header-sub{
        font-size:.8rem;
        color:#6b7280;
    }

    .badge-status{
        border-radius:999px;
        padding:.25rem .6rem;
        font-size:.7rem;
        font-weight:600;
        display:inline-flex;
        align-items:center;
        gap:.25rem;
    }
    .badge-status .dot{
        width:.45rem;
        height:.45rem;
        border-radius:999px;
    }

    .badge-paid{
        background:#ecfdf3;
        color:#15803d;
    }
    .badge-paid .dot{ background:#22c55e; }

    .table-inst th{
        font-size:.75rem;
        text-transform:uppercase;
        letter-spacing:.05em;
        color:#9ca3af;
        border-bottom:1px solid #e5e7eb!important;
        white-space:nowrap;
    }
    .table-inst td{
        font-size:.8rem;
        border-bottom:1px solid #f3f4f6!important;
        vertical-align:middle;
    }

    .btn-soft-primary{
        background:#eff6ff;
        color:#1d4ed8;
        border:1px solid #bfdbfe;
        border-radius:999px;
        font-size:.78rem;
        padding:.28rem .6rem;
    }
    .btn-soft-primary:hover{
        background:#1d4ed8;
        color:#fff;
        border-color:#1d4ed8;
    }

    .btn-soft-secondary{
        background:#f9fafb;
        color:#374151;
        border:1px solid #e5e7eb;
        border-radius:999px;
        font-size:.78rem;
        padding:.28rem .6rem;
    }
    .btn-soft-secondary:hover{
        background:#e5e7eb;
        border-color:#d1d5db;
    }

    .inst-header-stack{
        display:flex;
        justify-content:space-between;
        align-items:center;
        gap:.5rem;
        flex-wrap:wrap;
    }

    @media (max-width:768px){
        .inst-header-stack{
            align-items:flex-start;
        }
    }
</style>

<div class="inst-bg py-3 py-md-4">
    <div class="container-fluid">

        
        <div class="inst-header-stack mb-3">
            <div>
                <div class="inst-header-title d-flex align-items-center gap-2">
                    <i class="bi bi-cash-stack text-danger fs-5"></i>
                    <span>Latest paid installments</span>
                </div>
                <div class="inst-header-sub">
                    মোট <?php echo e($installments->total()); ?> টি paid installment (সর্বশেষ প্রথম)
                </div>
            </div>

            <div class="d-flex flex-wrap gap-2">
                
                <a href="<?php echo e(url()->previous()); ?>"
                   class="btn-soft-secondary d-inline-flex align-items-center gap-1">
                    <i class="bi bi-arrow-left"></i>
                    <span class="d-none d-sm-inline">Back</span>
                </a>
            </div>
        </div>

        <?php if(session('success')): ?>
            <div class="alert alert-success border-0 shadow-sm py-2 px-3 mb-3">
                <i class="bi bi-check-circle-fill me-1"></i>
                <?php echo e(session('success')); ?>

            </div>
        <?php endif; ?>

        <div class="card inst-card">
            <div class="card-body">

                <div class="d-flex justify-content-between align-items-center mb-2 flex-wrap gap-2">
                    <div class="text-muted small">
                        <i class="bi bi-info-circle me-1"></i>
                        শুধুমাত্র যেসব কিস্তির status <strong>paid</strong> — সেগুলো এখানে দেখাচ্ছে।
                    </div>
                </div>

                <div class="table-responsive">
                    <table class="table table-sm table-hover align-middle table-inst mb-0">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>User</th>
                            <th>Loan</th>
                            <th>Due date</th>
                            <th>Installment</th>
                            <th>Paid amount</th>
                            <th>Method</th>
                            <th>TRX ID</th>
                            <th>Paid at</th>
                            <th class="text-end">Actions</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $installments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ins): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>#<?php echo e($ins->id); ?></td>

                                
                                <td>
                                    <div class="fw-semibold">
                                        <?php echo e($ins->loan?->user?->name ?? 'N/A'); ?>

                                    </div>
                                    <small class="text-muted">
                                        <?php echo e($ins->loan?->user?->email ?? $ins->loan?->user?->phone); ?>

                                    </small>
                                </td>

                                
                                <td>
                                    <div class="fw-semibold">
                                        Loan #<?php echo e($ins->loan_id); ?>

                                    </div>
                                    <small class="text-muted">
                                        ৳ <?php echo e(number_format($ins->loan->amount ?? 0)); ?>

                                        · <?php echo e($ins->loan->tenure_months ?? 0); ?> মাস
                                    </small>
                                </td>

                                
                                <td>
                                    <div class="fw-semibold">
                                        <?php echo e(\Illuminate\Support\Carbon::parse($ins->due_date)->format('d M Y')); ?>

                                    </div>
                                    <small class="text-muted">
                                        <?php echo e(\Illuminate\Support\Carbon::parse($ins->due_date)->diffForHumans()); ?>

                                    </small>
                                </td>

                                
                                <td class="fw-semibold">
                                    ৳ <?php echo e(number_format($ins->amount)); ?>

                                    <div class="text-muted small">
                                        P: <?php echo e(number_format($ins->principal_part)); ?>,
                                        I: <?php echo e(number_format($ins->interest_part)); ?>

                                    </div>
                                </td>

                                
                                <td>
                                    <span class="badge-status badge-paid">
                                        <span class="dot"></span>
                                        ৳ <?php echo e(number_format($ins->paid_amount)); ?>

                                    </span>
                                </td>

                                
                                <td>
                                    <?php if($ins->payment_method): ?>
                                        <div class="fw-semibold small text-uppercase">
                                            <?php echo e($ins->payment_method); ?>

                                        </div>
                                    <?php else: ?>
                                        <span class="text-muted small">—</span>
                                    <?php endif; ?>
                                </td>

                                
                                <td>
                                    <?php if($ins->payment_trx_id): ?>
                                        <span class="small"><?php echo e($ins->payment_trx_id); ?></span>
                                    <?php else: ?>
                                        <span class="text-muted small">—</span>
                                    <?php endif; ?>
                                </td>

                                
                                <td>
                                    <div class="fw-semibold small">
                                        <?php echo e($ins->paid_at ? $ins->paid_at->format('d M, Y H:i') : '-'); ?>

                                    </div>
                                </td>

                                
                                <td class="text-end">
                                    <div class="d-flex flex-column flex-sm-row gap-1 justify-content-end">
                                        
                                        <a href="<?php echo e(route('admin.loans.installments', ['loan' => $ins->loan_id])); ?>"
                                           class="btn-soft-secondary btn-sm d-inline-flex align-items-center gap-1">
                                            <i class="bi bi-list-check"></i>
                                            <span class="d-none d-xl-inline">Loan installments</span>
                                        </a>

                                        <a href="<?php echo e(route('admin.installments.edit', $ins)); ?>"
                                           class="btn-soft-primary btn-sm d-inline-flex align-items-center gap-1">
                                            <i class="bi bi-pencil-square"></i>
                                            <span class="d-none d-md-inline">Edit</span>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="10" class="text-center text-muted py-3">
                                    <i class="bi bi-inbox me-1"></i>
                                    No paid installments found yet.
                                </td>
                            </tr>
                        <?php endif; ?>
                        </tbody>
                    </table>
                </div>

                <div class="mt-3">
                    <?php echo e($installments->links()); ?>

                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecareba2/loan.rkmotorsbike.top/resources/views/backend/loans/installments_paid.blade.php ENDPATH**/ ?>