<div class="mb-2">
    <button class="btn btn-primary" onclick="export2csv()">Download csv</button>
</div>
<div class="col-md-12">
    <div class="badge badge-info float-right m-1" style="text-align: ">Total Row: <?php echo e($list->count()); ?></div>
    <div class="badge badge-info float-right m-1" style="text-align: ">Total Amount <?php echo e($list->sum('amount')); ?> TK</div>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_reseller_balance_log')): ?>
        <div class="badge badge-info float-right m-1" style="text-align: ">Total  Manager Miscellaneous Expense <?php echo e($list->sum('commission')); ?> TK</div>
    <?php endif; ?>

</div>
<div class="table-responsive">
    <table class="table table-bordered table-striped table-condensed" id="tableId">
        <thead class="bg-blue-50">
            <tr>
                <th scope="col" class="">
                    ID
                </th>
                <th scope="col" class="">
                    Date
                </th>

                <th scope="col" class="">
                    Reseller Name
                </th>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('reseller_balance_log_with_pop')): ?>

                    <th scope="col" class="">
                        Pop Name
                    </th>
                <?php endif; ?>

                <th scope="col" class="">
                    User Name
                </th>
                <th scope="col" class="">
                    Action
                </th>

                <th scope="col" class="">
                    Amount
                </th>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_reseller_balance_log')): ?>
                    <th scope="col" class="">
                        Manager Miscellaneous Expense
                    </th>
                <?php endif; ?>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_percentage_reseller_balance_log')): ?>
                    <th scope="col" class="">
                        Manager Miscellaneous Expense
                    </th>
                <?php endif; ?>

                <th scope="col" class="">
                    Remarks
                </th>
            </tr>
        </thead>
        <tbody class="bg-white divide-y divide-gray-200">

            <?php $total = 0; $manger_commission = 0;  ?>

            <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                <tr>
                    <td class="px-6 py-2 whitespace-nowrap">
                        <?php echo e($r->id); ?>

                    </td>
                    <td class="px-6 py-2 whitespace-nowrap">
                        <?php echo e(date('d-M-Y h:i:sa', strtotime($r->created_at))); ?>

                    </td>

                    <td class="px-6 py-2 whitespace-nowrap text-sm text-gray-500">
                        <?php echo e($r->reseller->name ?? ''); ?>

                    </td>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('reseller_balance_log_with_pop')): ?>
                        <td class="px-6 py-2 whitespace-nowrap text-sm text-gray-500">
                            <?php echo e($r->pop->popname ?? ''); ?>

                        </td>
                    <?php endif; ?>

                    <td class="px-6 py-2 whitespace-nowrap text-sm text-gray-500">
                        <?php echo e($r->client->userid ?? ''); ?>

                    </td>

                    <td class="px-6 py-2 whitespace-nowrap text-sm text-gray-500">
                        <?php echo e($r->action ?? ''); ?>

                    </td>

                    <td class="px-6 py-2 whitespace-nowrap text-right">
                        <?php $total += $r->amount ?>
                        <?php echo e($r->amount); ?>

                    </td>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_reseller_balance_log')): ?>
                        <td class="px-6 py-2 whitespace-nowrap text-right">
                            <?php echo e($r->commission ?? 0); ?>

                        </td>
                    <?php endif; ?>

                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_percentage_reseller_balance_log')): ?>
                        <?php
                            if($r->amount != 0 && $r->reseller_commission_percentage != 0){
                               $this_row_commission = ($r->amount * $r->reseller_commission_percentage) / 100;
                            }else{
                                $this_row_commission = 0;
                            }
                            $manger_commission += $this_row_commission;
                        ?>
                        <td class="px-6 py-2 whitespace-nowrap text-right">
                            <?php echo e($this_row_commission ?? 0); ?>

                        </td>
                    <?php endif; ?>


                    <td class="px-6 py-2 whitespace-nowrap text-sm text-gray-500 text-right">
                        <?php echo e($r->remarks); ?>

                    </td>

                </tr>

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

            <tr>
                <td></td><td></td><td></td><td></td>
                <td colspan="2" class="text-right">Total: </td>
                <td class="px-6 py-2 whitespace-nowrap text-right"><?php echo e(number_format($total, 2, '.', '')); ?></td>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_reseller_balance_log')): ?>
                    <td class="px-6 py-2 whitespace-nowrap text-right"><?php echo e(number_format($list->sum('commission'), 2, '.', '')); ?></td>
                <?php endif; ?>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('show_commission_percentage_reseller_balance_log')): ?>

                    <td class="px-6 py-2 whitespace-nowrap text-right">
                        <?php echo e($manger_commission ?? 0); ?>

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

            <!-- More items... -->
        </tbody>
    </table>
</div>

<div class="p-5">
    
</div>
<?php /**PATH /var/www/html/rk/radius-circle/resources/views/resellerBalanceLog/result.blade.php ENDPATH**/ ?>