
<?php $__env->startSection('title'); ?> Paid Invoice | Beauty Parlour <?php $__env->stopSection(); ?>
<?php $__env->startSection('paid-bill-invoice-list'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('paid-bill-invoice-list'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> Paid Invoice List</span></h3>
    </div>
</div>

<div class="table_wrapper py-1 card">
    <div class="row my-2 aggregate-section-div">
        <div class="px-3 ">
            <div class=" d-flex justify-content-between align-items-center aggregate-section border">
                <div class="d-flex align-items-center">
                    <p class="mb-0"><a href="<?php echo e(route('bill-invoice-list')); ?>"
                            class="text-primary py-2 px-3 active">All(<?php echo e($allInvoiceCount); ?>)</a>
                    </p>
                    
                    <p class="mb-0"><a href="<?php echo e(route('paid-bill-invoice-list')); ?>" class="text-primary py-2 px-3">Paid
                            (<?php echo e($paidInvoiceCount); ?>)</a></p>
                    
                    <p class="mb-0"><a href="<?php echo e(route('due-bill-invoice-list')); ?>" class="text-primary py-2 px-3">Unpaid
                            (<?php echo e($dueInvoiceCount); ?>)</a></p>

                    <p class="mb-0"><a href="<?php echo e(route('pending-bill-invoice-list')); ?>" class="text-primary py-2 px-3">Pending
                            (<?php echo e($pendingInvoiceCount); ?>)</a></p>
                </div>
                <div class="d-none d-sm-block">
                    <?php if(Auth::user()->can('billing-create')): ?>
                    <a href="<?php echo e(route('billing-create')); ?>"
                        class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"><span class="">Create
                            Invoice</span></a>
                    <?php endif; ?>
                </div>
            </div>

            <?php if(Auth::user()->can('billing-create')): ?>
            <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none">
                <a href="<?php echo e(route('billing-create')); ?>" class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"><span
                        class="">Create
                        Invoice</span></a></div>
            <?php endif; ?>
        </div>
    </div>



    <div class="row px-3">
        <div class="table-container table-responsive">
            <table id="" class="table table-bordered">
                <thead class="text-uppercase">
                    <tr class="me-3">
                        <th class="text-center" scope="col"><span>Invoice ID</span></th>
                        <th class="text-center" scope="col"><span>Client Name</span></th>
                        <th class="text-center" scope="col"><span>Payment Method</span></th>
                        <th class="text-center" scope="col"><span>Billing Creation</span></th>
                        <th class="text-center" scope="col"><span>Status</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

                    <?php $__currentLoopData = $allInvoiceData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(isset($item) && $item != null): ?>
                    <tr class="">

                        <td>
                            <div class="row_title">
                                <b> #<?php echo e($item->billing_id); ?></b>
                            </div>
                            <div class="row-actions mt-2">
                                <?php if(Auth::user()->can('billing-edit')): ?>
                                <span><button
                                        class="edit_class_modal border-0 bg-transparent custom-invoice-service-details-sub"
                                        onclick="invoiceServiceList(<?php echo e($item->id); ?>)"> Invoice
                                        Details </button></span>

                                <span> | <a class="edit_class_modal border-0 bg-transparent text-primary custom-invoice-service-details-sub"
                                        href="<?php echo e(route('get-bill-payment-invoice', $item->id)); ?>"> Invoice View
                                    </a></span>

                                <?php endif; ?>
                            </div>
                        </td>

                        <td>
                            <a href="<?php echo e(route('client-profile', $item->client_id)); ?>"
                                class="text-info fw-bolder"><?php echo e($item->clientData->client_name); ?></a>
                        </td>
                        <td><?php echo e($item->paymentTypeData->payment_type_name); ?></td>
                        <td class="text-start">
                            <b>Date: </b> <?php echo e(Carbon\Carbon::parse($item->billing_date)->format('d-m-Y')); ?> <br>
                            <b>Time: </b> <?php echo e(Carbon\Carbon::create($item->created_at->toTimeString())->format('h:i')); ?>

                        </td>

                        <td>
                            <?php if($item->is_bill_pay == true): ?>
                            <?php if($item->is_bill_cancel == 0): ?>
                            <span class="badge custom-bg-green">Paid</span>
                            <?php elseif($item->is_bill_cancel == 1): ?>
                            <span class="badge bg-success">Adjusted</span>
                            <span class="badge bg-danger">Canceled</span>
                            <?php elseif($item->is_bill_cancel == 2): ?>
                            <span class="badge bg-success">Refunded</span>
                            <span class="badge bg-danger">Canceled</span>
                            <?php elseif($item->is_bill_cancel == 3): ?>
                            <span class="badge custom-bg-blue">Nothing</span>
                            <span class="badge bg-danger">Canceled</span>
                            <?php endif; ?>
                            <?php else: ?>
                            <span class="badge bg-warning">Unpaid</span>
                            <?php endif; ?>
                        </td>

                    </tr>

                    
                    <div class="modal fade" id="invoiceServiceList<?php echo e($item->id); ?>" tabindex="-1"
                        aria-labelledby="oneInputModalLabel" aria-hidden="true" data-bs-backdrop='static'>
                        <div class="modal-dialog modal-dialog-centered max-width-900px">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h1 class="modal-title fs-5" id="oneInputModalLabel">Invoice Service List</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal"
                                        aria-label="Close"></button>
                                </div>
                                <div class="modal-body p-0" id="updateBillingServiceDetails<?php echo e($item->id); ?>">

                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    
                    <div class="modal fade" id="paymentHistory<?php echo e($item->id); ?>" tabindex="-1"
                        aria-labelledby="oneInputModalLabel" aria-hidden="true" data-bs-backdrop='static'>
                        <div class="modal-dialog modal-dialog-centered max-width-900px">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h1 class="modal-title fs-5" id="oneInputModalLabel">Bill Payment History</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal"
                                        aria-label="Close"></button>
                                </div>
                                <div class="modal-body p-0 custom-payment-history-table" id="updateBillingPaymentHistory<?php echo e($item->id); ?>">

                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    
                    <div class="modal fade" id="duePayModal<?php echo e($item->id); ?>" tabindex="-1" aria-labelledby="oneInputModalLabel"
                        aria-hidden="true" data-bs-backdrop='static'>
                        <div class="modal-dialog modal-dialog-centered max-width-900px">
                            <div class="modal-content" id="updateBillingPaymentDetails<?php echo e($item->id); ?>">
                    
                            </div>
                        </div>
                    </div>

                    <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                </tbody>
            </table>
        </div>

        <?php if(isset($allInvoiceCount) && $allInvoiceCount > 10): ?>
        <div class="clearfix d-flex">
            <div class="float-left">
                <p class="text-muted">
                    <?php echo e(__('Showing')); ?>

                    <span class="font-weight-bold"><?php echo e($allInvoiceData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

                    <span class="font-weight-bold"><?php echo e($allInvoiceData->lastItem()); ?></span>
                    <?php echo e(__('of')); ?>

                    <span class="font-weight-bold"><?php echo e($allInvoiceData->total()); ?></span>
                    <?php echo e(__('results')); ?>

                </p>
            </div>

            <div class="float-right custom-table-pagination">
                <?php echo $allInvoiceData->links('pagination::bootstrap-4'); ?>

            </div>
        </div>
        <?php endif; ?>
    </div>
</div>

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

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

<script>
    //To show update modal...
    function invoiceServiceList(id) {
        var url = "<?php echo e(route('paid-bill-product-details-with-id')); ?>";
        if (id != '') {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    billing_id: id,
                },
                success: function (data) {
                    if(data.error){
                        toastr.error(data.error);
                    }else{
                        $("#invoiceServiceList"+id).modal('show');
                        $("#updateBillingServiceDetails"+id).html(data);
                    }
                }
            });
        }
    }

    //To get payment history data...
    function paymentHistory(id) {
        var url = "<?php echo e(route('get-billing-payment-history-with-id')); ?>";
        if (id != '') {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    billing_id: id,
                },
                success: function (data) {
                    if(data.error){
                        toastr.error(data.error);
                    }else{
                        $("#paymentHistory"+id).modal('show');
                        $("#updateBillingPaymentHistory"+id).html(data);
                    }
                }
            });
        }
    }

    //To show due pay modal...
    function duePay(id) {
        var url = "<?php echo e(route('due-bill-payment-details-with-id')); ?>";
        if (id != '') {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    billing_id: id,
                },
                success: function (data) {
                    if(data.error){
                        toastr.error(data.error);
                    }else{
                        $("#duePayModal"+id).modal('show');
                        $("#updateBillingPaymentDetails"+id).html(data);
                    }
                }
            });
        }
    }

    //To calculate payment amount...
    function updatePayAmountForDue(id) {
        let totalProductPrice = parseFloat($("#totalAmount"+id).val());
        let totalDuePrice = parseFloat($("#dueAmount"+id).val());
        let paymentAmount = parseFloat($("#paymentAmount"+id).val());

        //To check negative number...
        if(paymentAmount < 0){
            toastr.error('Sorry, Negative number not applicable.!');
            $("#paymentAmount"+id).val(0)
        }else{
            if (paymentAmount >= 0) {
                let finalAmount = (totalDuePrice - paymentAmount);
                if(finalAmount >= 0){
                    if(finalAmount == 0){
                        $("#finalDueAmountText"+id).text('0');
                    }else{
                        $("#finalDueAmountText"+id).text(finalAmount);
                    }
                    $("#finalChangeAmountText"+id).text('0');
                    $("#changeAmount"+id).val(0);
                }else{
                    let changeAmount = Math.abs(finalAmount);
                    $("#finalChangeAmountText"+id).text(changeAmount);
                    $("#finalDueAmountText"+id).text('0');
                    $("#changeAmount"+id).val(changeAmount);
                }
            }
        }
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\skin-care\resources\views/admin/billingInvoice/billInvoiceList.blade.php ENDPATH**/ ?>