<?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">
       <iframe
                src="<?php echo isset($metabase_data->url) ? $metabase_data->url : ''; ?>"
                frameborder="0"
                width="100%"
                height="300"
                allowtransparency
        ></iframe>
    </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/da-system" 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/da-system/loans" class="form-inline" style="margin-bottom: 15px; gap: 8px; display: flex; flex-wrap: wrap;">
                    <input type="text" name="search_name" class="form-control form-control-sm" placeholder="Search by Name"
                        value="<?php echo e(request('search_name')); ?>" style="width: 220px;">
                    <input type="text" name="search_loan" class="form-control form-control-sm" placeholder="Search by Loan No"
                        value="<?php echo e(request('search_loan')); ?>" style="width: 200px;">
                    <input type="text" name="search_partner" class="form-control form-control-sm" placeholder="Search by Partner Name"
                        value="<?php echo e(request('search_partner')); ?>" style="width: 220px;">
                    <button type="submit" style="margin-top: -10px;" class="btn btn-accent btn-sm">Search</button>
                    <?php if(request('search_name') || request('search_loan') || request('search_partner')): ?>
                        <a href="/admin/da-system/loans" style="margin-top: -10px;" class="btn btn-secondary btn-sm">Clear</a>
                    <?php endif; ?>
                </form>

                <div class="" 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 No</th>
                                <th>Partner Name</th>
                                <th>Member Name</th>
                                <th>Branch</th>
                                <th>District</th>
                                <th>State</th>
                                <th>Disbursement Date</th>
                                <th>Status</th>
                                <th>Outstanding Principal</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><a style="text-decoration: underline;" target="_blank" href="/admin/da-system/loans/<?php echo e($loan->id); ?>"><?php echo e($loan->loan_no ?? '—'); ?></a></td>
                                    <td><?php echo e($loan->partner_id ?? '—'); ?></td>
                                    <td><?php echo e($loan->member_name ?? '—'); ?></td>
                                    <td><?php echo e($loan->branch_name ?? '—'); ?></td>
                                    <td><?php echo e($loan->district ?? '—'); ?></td>
                                    <td><?php echo e($loan->state ?? '—'); ?></td>
                                    <td><?php echo e($loan->disbursement_date ?? '—'); ?></td>
                                    <td>
                                        <?php if($loan->status): ?>
                                            <span style="padding: 3px 8px; border-radius: 3px; font-size: 11px; font-weight: 600;
                                                background-color: <?php echo e(strtolower($loan->status) == 'active' ? '#c9f7f5' : '#fff4de'); ?>;
                                                color: <?php echo e(strtolower($loan->status) == 'active' ? '#1bc5bd' : '#ffa800'); ?>;">
                                                <?php echo e($loan->status); ?>

                                            </span>
                                        <?php else: ?>
                                            —
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($loan->outstanding_principal ?? '—'); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="12" 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(); ?>
