
<?php $__env->startSection('title', 'Loans'); ?>

<?php $__env->startSection('page-header'); ?>
<header class="header bg-ui-general">
    <div class="header-info">
        <h1 class="header-title">
            <strong>Loans</strong>
        </h1>
    </div>

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

<?php $__env->startSection('content'); ?>
<div class="col-md-12">

    <div class="card card-body mb-2">
        <form method="GET" class="mb-4">
            <div class="form-row">
                <!-- Customer -->
                <div class="form-group col-md-3">
                    <select name="customer_id" class="form-control" data-provide="selectpicker" data-live-search="true">
                        <option value="">Select Customer</option>
                        <?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($customer->id); ?>"
                            <?php echo e(old(key: 'customer_id') == $customer->id ? 'selected' : ''); ?>>
                            <?php echo e($customer->name); ?> (<?php echo e($customer->mobile_no); ?>)
                        </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <!-- Status -->
                <div class="form-group col-md-3">
                    <select name="status" class="form-control">
                        <option value="">Select Status</option>
                        <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                        <option value="accept" <?php echo e(request('status') == 'accept' ? 'selected' : ''); ?>>Accept</option>
                        <option value="completed" <?php echo e(request('status') == 'completed' ? 'selected' : ''); ?>>Completed
                        </option>
                        <option value="overdue" <?php echo e(request('status') == 'overdue' ? 'selected' : ''); ?>>Overdue</option>
                    </select>
                </div>

                <!-- Start Date -->
                <div class="form-group col-md-2">
                    <input type="text" class="form-control" data-provide="datepicker" data-date-format="yyyy-mm-dd"
                        name="start_date" placeholder="Start Date" value="<?php echo e(request('start_date')); ?>">
                </div>

                <!-- End Date -->
                <div class="form-group col-md-2">
                    <input type="text" class="form-control" data-provide="datepicker" data-date-format="yyyy-mm-dd"
                        name="end_date" placeholder="End Date" value="<?php echo e(request('end_date')); ?>">
                </div>

                <!-- Buttons -->
                <div class="form-group col-md-2">
                    <button type="submit" class="btn btn-primary">Filter</button>
                    <a href="#" class="btn btn-info">Reset</a>
                </div>
            </div>
        </form>
    </div>

    <div class="card">
        <div class="card-header">
            <h4 class="card-title fw-400">All Loans</h4>
        </div>

        <div class="card-body table-responsive">
            <table class="table table-bordered">
    <thead>
        <tr>
            <th>Loan ID</th>
            <th>Customer</th>
            <th>Loan Amount</th>
            <th>Total Payable</th>
            <th>Total Paid</th>
            <th>Total Due</th>
            <th>Status</th>
            <th>Issue Date</th>
        </tr>
    </thead>

    <tbody>
        <?php $__currentLoopData = $reportLoans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <tr>
            <td><?php echo e($loan['loan_id']); ?></td>
            <td><?php echo e($loan['customer']); ?></td>
            <td><?php echo e(number_format($loan['loan_amount'], 2)); ?></td>
            <td><?php echo e(number_format($loan['total_payable'], 2)); ?></td>
            <td><?php echo e(number_format($loan['total_paid'], 2)); ?></td>
            <td><?php echo e(number_format($loan['total_due'], 2)); ?></td>
            <td><?php echo e(ucfirst($loan['status'])); ?></td>
            <td><?php echo e($loan['issue_date']); ?></td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>

    
    <?php if($reportLoans->count()): ?>
        <tfoot>
            <tr class="fw-bold bg-light">
                <td colspan="2">Grand Total</td>
                <td><?php echo e(number_format($totalLoanAmount, 2)); ?></td>
                <td><?php echo e(number_format($totalPayable, 2)); ?></td>
                <td><?php echo e(number_format($totalPaid, 2)); ?></td>
                <td><?php echo e(number_format($totalDue, 2)); ?></td>
                <td colspan="2"></td>
            </tr>
        </tfoot>
    <?php endif; ?>
</table>


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

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

<?php $__env->startSection('styles'); ?>
<style>
    /* Custom styles if needed */

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

<?php $__env->startSection('scripts'); ?>
<script>
    /* Optional scripts if needed */

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

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/demosoftghor/sm.demo.softghor.com/resources/views/pages/loans/loan_report.blade.php ENDPATH**/ ?>