@extends('layouts.admin')

@section('title', 'Monitoring Sistem')
@section('page-title', 'Monitoring Data')

@section('content')
<div class="row">
    {{-- TABEL SEMUA TRANSAKSI --}}
    <div class="col-12 mb-4">
        <div class="card">
            <div class="card-header">
                <h4>Semua Transaksi</h4>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Invoice</th>
                                <th>Pembeli</th>
                                <th>Total</th>
                                <th>Status</th>
                                <th>Waktu</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($transaksis as $t)
                            <tr>
                                <td>{{ $t->kode_invoice }}</td>
                                <td>{{ $t->pembeli->nama_lengkap }}</td>
                                <td>Rp {{ number_format($t->total_harga, 0, ',', '.') }}</td>
                                <td>{{ strtoupper($t->status) }}</td>
                                <td>{{ $t->created_at->format('d M Y H:i') }}</td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
                {{ $transaksis->links() }}
            </div>
        </div>
    </div>

    {{-- TABEL SEMUA PRODUK --}}
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h4>Semua Produk Terdaftar</h4>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Nama Produk</th>
                                <th>Pemilik (Petani)</th>
                                <th>Harga</th>
                                <th>Stok</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($produks as $p)
                            <tr>
                                <td>{{ $p->nama_produk }}</td>
                                <td>{{ $p->petani->nama_lengkap }}</td>
                                <td>Rp {{ number_format($p->harga, 0, ',', '.') }}</td>
                                <td>{{ $p->stok }}</td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
                {{ $produks->links() }}
            </div>
        </div>
    </div>
</div>
@endsection