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

<!-- Dashboard Section -->
<div class="container py-5">
    <div class="row g-4">
        <!-- Profile + Payment -->
        <form action='<?php echo e(route("payment")); ?>' method="post" onsubmit="return validatePayment()">
            <?php echo csrf_field(); ?>
            <div class="col-12">
                <div class="card card-custom p-4">
                    <div class="row align-items-center">
                        <div class="col-md-8 d-flex align-items-center gap-4">
                            <div class="avatar-circle"><i class="fa-solid fa-user"></i></div>
                            <div>
                                <h5 class="mb-0"><?php echo e(Session::get('name')); ?></h5>
                                <div class="text-muted small">Customer ID: <?php echo e($customer->cus_id); ?></div>
                                <div class="text-muted small">Customer IP: <?php echo e($customer->ip); ?></div>
                                <div class="text-muted small">Location: <?php echo e($customer->ag_office_address); ?></div>
                                <div class="text-muted small">Phone: <?php echo e($customer->ag_mobile_no); ?></div>
                                <?php if($customer->ag_status == 1): ?>
                                <span class="badge bg-success mt-2">Active</span>
                                <?php elseif($customer->ag_status == 2): ?>
                                <span class="badge bg-success mt-2">Active</span>
                                <?php elseif($customer->ag_status == 0): ?>
                                <span class="badge bg-danger mt-2">Inactive</span>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-4 text-end">
                            <div class="d-flex justify-content-end align-items-center gap-2 mb-2">
                                <img src="https://download.logo.wine/logo/BKash/BKash-Logo.wine.png" class="bkash-logo" alt="bKash">
                                <span class="fw-semibold text-danger">Payment</span>
                            </div>
                            <?php
                            $dueadvance = $billinng->dueadvance;
                            $monthlyBill = $billinng->monthlybill;
                            if ($dueadvance < 0) {
                                $due=0;
                                $advance=abs($dueadvance);
                                }else{
                                $due=$dueadvance;
                                }
                                ?>
                                <h5 class="mb-2">Bill Amount:</h5>
                                <input type="number" class="my-3 border-1" style="width: 100px;" id="" name="amount" value="<?php echo e($due); ?>"><br>
                                <?php if($dueadvance < 0): ?>
                                    <p class="text-success fw-bold">Advance Amount: <?php echo e($advance); ?></p>
                                    <?php elseif($dueadvance == 0): ?>
                                    <p class="text-success fw-bold">bill Amount : 0</p>
                                    <?php else: ?>
                                    <p class="text-danger fw-bold">Due Amount: <?php echo e($due); ?></p>
                                    <?php endif; ?>
                                    <input type="hidden" name="customer_id" value="<?php echo e($customer->cus_id); ?>">
                                    <button class="btn btn-success btn-pay">Pay Now</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

        <!-- Notice -->
        <div class="col-12">
            <h5 class="section-title">Notice</h5>
            <?php if(Session::has('wrong')): ?>
            <div class="alert alert-danger" role="alert">
                <p class="mb-0"> <?php echo e(Session::get('wrong')); ?></p>
            </div>
            <?php elseif(Session::has('success')): ?>
            <div class="alert alert-success" role="alert">
                <p class="mb-0"><?php echo e(Session::get('success')); ?></p>
            </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<div class="container py-5">
    <div class="row g-4">
        <!-- Profile + Payment -->
        <div class="col-12">
            <div class="card card-custom p-4">
                <div class="row align-items-center">
                    <table class="table">
                        <thead>
                            <tr>
                                <th scope="col">#</th>
                                <th scope="col">Date</th>
                                <th scope="col">Description</th>
                                <th scope="col">Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $accountStatement; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $statement): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <th scope="row"><?php echo e($loop->iteration); ?></th>
                                <td><?php echo e($statement->entry_date); ?></td>
                                <td><?php echo e($statement->acc_description); ?></td>
                                <td><?php echo e($statement->acc_amount); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>

                </div>
            </div>
        </div>

    </div>
</div>

<script>
    function validatePayment() {
        let amount = parseFloat(document.getElementById('amount').value);
        let monthlyBill = <?php echo e($monthlyBill); ?>;

        if (isNaN(amount) || amount < monthlyBill) {
             alert("The payment amount must be equal to or greater than the monthly bill (<?php echo e($monthlyBill); ?> BDT)");
            return false;
        }

        return true;
    }
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/bsdnewco/kuniabazarwifi.bsdnew.com/userportal/resources/views/home/index.blade.php ENDPATH**/ ?>