@extends(auth()->user()->role == 'admin' ? 'layouts.admin' : 'layouts.app')

@section('content')
<div class="content-header">
    <div class="container-fluid">
        <h1 class="m-0"><i class="fas fa-money-check-alt mr-2"></i>Laporan Kas & Bank</h1>
    </div>
</div>

<section class="content">
    <div class="container-fluid">

        @if(auth()->user()->role == 'admin')
            <div class="card card-success card-outline card-tabs">
                <div class="card-header p-0 pt-1 border-bottom-0">
                    <ul class="nav nav-tabs" id="custom-tabs-kb-tab" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="tab-kb-total" data-toggle="pill" href="#content-kb-total" role="tab">Total Gabungan</a>
                        </li>
                        @foreach($branches as $index => $branch)
                        <li class="nav-item">
                            <a class="nav-link" id="tab-kb-{{ $index }}" data-toggle="pill" href="#content-kb-{{ $index }}" role="tab">{{ $branch }}</a>
                        </li>
                        @endforeach
                    </ul>
                </div>
                <div class="card-body">
                     <div class="tab-content">
                        <div class="tab-pane fade show active" id="content-kb-total">
                             <div class="alert alert-info"><i class="fas fa-info-circle"></i> Mutasi Kas & Bank Gabungan.</div>
                             @include('partials.table_kas_bank', ['report' => $reportTotal])
                        </div>
                        @foreach($branches as $index => $branch)
                        <div class="tab-pane fade" id="content-kb-{{ $index }}">
                             @include('partials.table_kas_bank', ['report' => $branchReports[$branch] ?? []])
                        </div>
                        @endforeach
                     </div>
                </div>
            </div>
        @else
             <!-- KARYAWAN VIEW -->
            <div class="card shadow border-0">
                <div class="card-header bg-success text-white">
                    <i class="fas fa-table mr-2"></i>Data Kas & Bank - {{ session('branch') }}
                </div>
                <div class="card-body table-responsive">
                    <table class="table table-bordered table-striped">
                        <thead class="bg-success text-white">
                            <tr>
                                <th>Tanggal</th>
                                <th>Keterangan</th>
                                <th>Jenis Akun</th>
                                <th>Masuk</th>
                                <th>Keluar</th>
                                <th>Saldo</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>2025-09-01</td>
                                <td>Penjualan Tunai</td>
                                <td>Kas Kecil</td>
                                <td>Rp500.000</td>
                                <td>-</td>
                                <td>Rp500.000</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        @endif

    </div>
</section>
@endsection
