<div class="headlap">
    <h3>LAPORAN DATA PENJUALAN <br>{{ $data['jns'] }} {{ $data['via'] }}
        @if ($data['jns'] != '')
            <br>
        @endif

        {{ $data['tgl1'] }} - {{ $data['tgl2'] }}
    </h3>
    <div style="border:1px solid; margin: 10px"></div>
    <table class="lap">
        <thead>
            <tr>
                <th rowspan="2">No</th>
                <th rowspan="2">Petugas</th>
                <th rowspan="2">No. Transaksi</th>
                <th rowspan="2">Pelanggan</th>
                <th rowspan="2">Tanggal</th>
                <th rowspan="2">Transaksi</th>
                <th rowspan="2">Kurir</th>
                <th rowspan="2">Jumlah</th>
                <th rowspan="2">Diskon</th>
                <th rowspan="2">Ongkir</th>
                <th colspan="2">Pembayaran</th>


                <th rowspan="2">Total</th>

            </tr>
            <tr>
                <th>Cash</th>
                <th>Transfer</th>
            </tr>
        </thead>
        <tbody>
            @php
                $jumttl = [];
                $ongttl = [];
                $ttl = [];
                $ttlc = [];
                $ttlt = [];
            @endphp
            @forelse ($transaksi as $t)
                @php
                    $jumttl[] = $t->jumlah;
                    $ongttl[] = $t->ongkir;
                    $ttl[] = $t->total;
                    $ttlc[] = $t->via_bayar == 'K' ? $t->total : '';
                    $ttlt[] = $t->via_bayar == 'T' ? $t->total : '';
                @endphp
                <tr>
                    <td class="text-center">{{ $no++ }}</td>
                    <td>{{ $t->user->nm_user }}</td>
                    <td>{{ $t->kd_transaksi }}</td>
                    <td>{{ $t->member->nm_member }}</td>
                    <td>{{ tgl_time($t->created_at) }}</td>
                    <td>{!! $t->jns_transaksi == 'OFF'
                        ? '<span class="text-danger">Offline</span>'
                        : '<span class="text-success">Online</span>' !!}
                    </td>
                    <td>
                        @if ($t->sts_antar == 'Y')
                            <span class="text-primary">{{ $t->kurir->karyawan->nm_karyawan }}</span>
                        @else
                            Ambil Di Toko
                        @endif
                    </td>
                    <td class="text-right">{{ $t->jumlah }}</td>
                    <td class="text-center">{{ $t->diskon }}</td>
                    <td class="text-right">{{ $t->ongkir }}</td>
                    <td class="text-right">{{ $t->via_bayar == 'K' ? $t->total : 0 }}</td>
                    <td class="text-right">{{ $t->via_bayar == 'T' ? $t->total : 0 }}</td>
                    <td class="text-right">{{ $t->total }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="17" class="text-center">Data tidak ditemukan</td>
                </tr>
            @endforelse

        @empty(!array_sum($jumttl))
            <tr style="background-color: rgb(241, 210, 210)">

                <td class="text-center" style="font-size:14px; font-weight: bold" colspan="9">Jumlah Total</td>
                <td class="text-right" style="font-size:14px; font-weight: bold">
                    {{ array_sum($ongttl) }}
                </td>
                <td class="text-right" style="font-size:14px; font-weight: bold">
                    {{ array_sum($ttlc) }}
                </td>
                <td class="text-right" style="font-size:14px; font-weight: bold">
                    {{ array_sum($ttlt) }}
                </td>

                <td class="text-right" style="font-size:14px; font-weight: bold">
                    {{ array_sum($ttl) }}
                </td>
            </tr>
        @endempty

    </tbody>
</table>

</div>
