@extends('layouts.app')

@section('content')
<!-- Background untuk halaman -->
<div style="background-color: #e0e0e0; width: 100%; min-height: 100vh; border-radius: 15px; padding: 1rem;">

    <!-- Header -->
    <div style="background-color: #000; color: #fff; padding: 0.1rem; border-radius: 0.5rem;">
        <h1 class="m-0">Pemasukan Barang Kas</h1>
    </div>

    <!-- Konten utama -->
    <div class="container mt-4">
        <a href="{{ route('sosial-kas.pemasukan.create') }}" class="btn btn-primary mb-3">Tambah Pemasukan</a>

        <!-- Pesan sukses jika ada -->
        @if(session('success'))
            <div class="alert alert-success">{{ session('success') }}</div>
        @endif

        <div class="card p-3 border border-secondary" style="border-radius: 15px; background-color: #fff;">
            <table class="table table-bordered table-hover mb-0">
                <thead class="table-dark">
                    <tr>
                        <th>No</th>
                        <th>Tanggal</th>
                        <th>Nama</th>
                        <th>Jumlah</th>
                        <th>Barang</th>
                        <th>Keterangan</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($data as $index => $d)
                        <tr>
                            <td>{{ $index + 1 }}</td>
                            <td>{{ $d->tanggal }}</td>
                            <td>{{ $d->kategori }}</td>
                            <td>Rp {{ number_format($d->jumlah, 0, ',', '.') }}</td>
                            <td>{{ $d->barang }}</td>
                            <td>{{ $d->keterangan }}</td>
                            <td>
                                <a href="{{ route('sosial-kas.pemasukan.edit', $d->id) }}" class="btn btn-sm btn-warning">Edit</a>
                                <form action="{{ route('sosial-kas.pemasukan.destroy', $d->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Yakin ingin menghapus data ini?')">
                                    @csrf
                                    @method('DELETE')
                                    <button class="btn btn-sm btn-danger" type="submit">Hapus</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
                @if($data->count() > 0)
                    <tfoot>
                        <tr class="fw-bold">
                            <td colspan="4" class="text-end">Total</td>
                            <td colspan="3">Rp {{ number_format($total, 0, ',', '.') }}</td>
                        </tr>
                    </tfoot>
                @endif
            </table>

            <!-- Tombol Kembali -->
            <div class="mt-3">
                <a href="{{ route('dashboard') }}" class="btn btn-secondary">Kembali</a>
            </div>
        </div>
    </div>
</div>
@endsection
