<h2 class="header text-center">Payment History</h2>
<div class="table-responsive">
    <table class="table table-bordered">
        <tr>
            <th>Action</th>
            <th>Description</th>
            <th>Received/Collected By</th>
            <th>Type</th>
            <th>Amount</th>
            <th>Discount</th>
        </tr>
        <?php ($total = 0); ?>
        <?php ($index = 0); ?>


        <?php $__currentLoopData = $paymenthistory->get(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php ($total += $p->paid_amount); ?>

            <tr>
                <td class="text-center">

                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('money-receipt-destroy')): ?>
                        <?php if($index == 0): ?>
                            <form action="<?php echo e(route('paymentDelete', $p->id)); ?>" method="post">
                                <?php echo csrf_field(); ?>
                                <input name="payment_id" type="hidden" value="<?php echo e($p->id); ?>">
                                <button onclick="return confirm('Are you sure you want to Delete?');" type="submit"
                                    class="btn btn-danger btn-sm processConfirm">
                                    <i class="fa fa-trash"></i>
                                </button>
                            </form>
                        <?php elseif(auth()->user()->id == 1): ?>
                            <form action="<?php echo e(route('paymentDelete', $p->id)); ?>" method="post">
                                <?php echo csrf_field(); ?>
                                <input name="payment_id" type="hidden" value="<?php echo e($p->id); ?>">
                                <button onclick="return confirm('Are you sure you want to Delete?');" type="submit"
                                    class="btn btn-danger btn-sm">
                                    <i class="fa fa-trash"></i>
                                </button>
                            </form>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php if(checkSettings('print-invoice') == 'enable'): ?>
                        <?php if(checkSettings('only-last-invoice-print') == 'enable'): ?>
                            <?php if(auth()->user()->hasRole('Admin')): ?>
                                <a href="<?php echo e(route('invoice-print', $p->id)); ?>" target="_blank"
                                    class="mt-1 btn btn-primary btn-sm">
                                    <i class="fa fa-print"></i>
                                </a>
                            <?php elseif(auth()->user()->hasPermissionTo('print-invoice')): ?>
                                <?php if($index == 0): ?>
                                    <a href="<?php echo e(route('invoice-print', $p->id)); ?>" target="_blank"
                                        class="mt-1 btn btn-primary btn-sm">
                                        <i class="fa fa-print"></i>
                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php else: ?>
                            <a href="<?php echo e(route('invoice-print', $p->id)); ?>" target="_blank"
                                class="mt-1 btn btn-primary btn-sm">
                                <i class="fa fa-print"></i>
                            </a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <p>Id: <?php echo e($p->id); ?></p>

                </td>


                <td> <span class="badge badge-primary">Date: </span> <?php echo e($p->created_at); ?> <br>
                    <span class="badge badge-primary">MR ID: </span> <?php echo e($p->money_receipt_number); ?> <br>
                    <span class="badge badge-primary">DS: </span> <?php echo e($p->description); ?>

                    <?php if(isset($p->user)): ?>
                        <?php if($p->user->name == "Bkash-Webhook"): ?>
                            <br><span class="badge badge-primary">Payment No: </span> <?php echo e($p->customerMsisdn ?? ''); ?>

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

                <td class="text-left"><span class="badge badge-success">R.By: </span>
                    <?php echo e($p->user->name ?? 'Online Payment'); ?> <br> <span class="badge badge-success">C.By: </span>
                    <?php echo e($p->employee->name ?? ''); ?></td>

                <td><?php echo e($p->income->name ?? ''); ?></td>
                <td class="text-right"><?php echo e($p->paid_amount); ?></td>
                <td class="text-right"><?php echo e($p->discount_amount); ?></td>

            </tr>
            <?php ($index++); ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        <tr>
            <th colspan="4" class="text-right">Total Amount: </th>
            <th class="text-right"><?php echo e($total); ?> TK</th>
            <th class="text-right"><?php echo e($paymenthistory->sum('discount_amount')); ?></th>
        </tr>
    </table>
</div>
<?php /**PATH /var/www/html/rbnetwork/radius-circle/resources/views/paymenthistory/paymentLog.blade.php ENDPATH**/ ?>