<?php echo $__env->make('admin.layouts.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('admin.layouts.sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
    <div class="m-subheader">
        <div class="d-flex align-items-center">
            <div class="mr-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    Co-Lending Loans
                </h3>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__head">
                <div class="m-portlet__head-caption">
                    <div class="m-portlet__head-title">
                        <span class="m-portlet__head-icon">
                            <i class="fa fa-list"></i>
                        </span>
                        <h3 class="m-portlet__head-text">
                            Loans
                        </h3>
                    </div>
                </div>
                <div class="m-portlet__head-tools" style="padding-right: 13px;">
                    <a href="/admin/co-lending" class="btn btn-default btn-sm">
                        <i class="fa fa-arrow-left"></i> Back
                    </a>
                </div>
            </div>
            <div class="m-portlet__body">

                
                <form method="GET" action="/admin/co-lending/loans" class="form-inline" style="margin-bottom: 15px; gap: 8px; display: flex; flex-wrap: wrap;">
                    <input type="text" name="search_loan" class="form-control form-control-sm" placeholder="Search by Loan ID"
                        value="<?php echo e(request('search_loan')); ?>" style="width: 220px;">
                    <input type="text" name="search_product" class="form-control form-control-sm" placeholder="Search by Product ID"
                        value="<?php echo e(request('search_product')); ?>" style="width: 200px;">
                    <input type="date" name="search_date" class="form-control form-control-sm"
                        value="<?php echo e(request('search_date')); ?>" style="width: 180px;">
                    <button type="submit" style="margin-top: -10px;" class="btn btn-accent btn-sm">Search</button>
                    <?php if(request('search_loan') || request('search_product') || request('search_date')): ?>
                        <a href="/admin/co-lending/loans" style="margin-top: -10px;" class="btn btn-secondary btn-sm">Clear</a>
                    <?php endif; ?>
                </form>

                <div style="overflow-x: auto;">
                    <table class="table table-bordered table-hover" style="font-size: 13px; white-space: nowrap;">
                        <thead>
                            <tr style="background-color: #f4f5f8;">
                                <th>Loan ID</th>
                                <th>Loan Amount</th>
                                <th>Interest Rate</th>
                                <th>Tenure</th>
                                <th>Disbursement Date</th>
                                <th>Product ID</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $loans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td style="font-weight: 600;"><?php echo e($loan->loan_id ?? '—'); ?></td>
                                    <td><?php echo e($loan->loan_amount !== null ? number_format($loan->loan_amount, 2) : '—'); ?></td>
                                    <td><?php echo e($loan->interest_rate !== null ? floatval($loan->interest_rate) * 100 . '%' : '—'); ?></td>
                                    <td><?php echo e($loan->tenure ?? '—'); ?></td>
                                    <td><?php echo e($loan->disbursement_date ?? '—'); ?></td>
                                    <td><?php echo e($loan->product_id ?? '—'); ?></td>
                                    <td>
                                        <a href="/admin/co-lending/loans/<?php echo e($loan->id); ?>" class="btn btn-primary btn-sm" target="_blank">
                                            View RPS
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="8" class="text-center">No records found.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>

                <div class="text-center" style="margin-top: 15px;">
                    <?php echo $loans->appends(\Request::except('page', '_token'))->render(); ?>

                </div>

            </div>
        </div>
    </div>
</div>
<?php echo $__env->make("admin.layouts.footer", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
