<div class="table-responsive" id="result">
    <table class="table" style="width:100%">
        <thead style="width:100%">
            <tr>
                <th class="bg-dark">Name</th>
                <th class="bg-dark">Received Commission</th>
                <th class="bg-dark">Paid Commission</th>
                <th class="bg-dark">Balance</th>
                <th class="bg-dark">Action</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($managers as $m)
                <tr>
                    <td>{{ $m->name }}</td>
                    <td>
                        @foreach ($accounts as $ac)
                            @if ($ac->reseller_id == $m->id)
                                {{ $ac->ramount }}
                            @endif
                        @endforeach
                    </td>
                    <td>
                        @foreach ($accounts as $ac)
                            @if ($ac->reseller_id == $m->id)
                                {{ $ac->pamount ?? 0 }}
                            @endif
                        @endforeach
                    </td>
                    <td>
                        @foreach ($accounts as $ac)
                            @if ($ac->reseller_id == $m->id)
                                {{ $ac->ramount - $ac->pamount }}
                            @endif
                        @endforeach
                    </td>
                    <td>
                        <a href="{{ route('view-reseller-commission', $m->id) }}" class="btn btn-primary">View</a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</div>
