@extends('layouts.main')
@section('content')
    <div class="table mt-2 p-3 table-responsive">
        <div class="row mb-3">
            <div class="col-md-3">
                <label for="" class="form-label">Dari Tanggal</label>
                <input type="date" class="form-control" name="dariTanggal" id="tglMulai" value="{{ $tglMulai }}">
            </div>
            <div class="col-md-3">
                <label for="" class="form-label">Sampai Tanggal</label>
                <input type="date" class="form-control" name="sampaiTanggal" id="tglSelesai" value="{{ $tglSelesai }}">
            </div>
            <div class="col-md-2">
                <label for="status" class="form-label">Status</label>
                <select class="form-select" aria-label="Default select example" name="status" required id="statuss">
                    <option value="pending" {{ $status == 'pending' ? 'selected' : '' }}>pending</option>
                    <option value="paid" {{ $status == 'paid' ? 'selected' : '' }}>paid</option>
                    <option value="on_delivery" {{ $status == 'on_delivery' ? 'selected' : '' }}>on delivery</option>
                    <option value="delivered" {{ $status == 'delivered' ? 'selected' : '' }}>delivered</option>
                    <option value="expired" {{ $status == 'expired' ? 'selected' : '' }}>expired</option>
                    <option value="cancelled" {{ $status == 'cancelled' ? 'selected' : '' }}>cancelled</option>
                </select>
            </div>
            <div class="col-md-2">
                <label for="btn-cetak" class="form-label">&nbsp;</label><br>
                <a href="" class="btn btn-primary text-black btn-hover-white" id="btn-cetak"
                    onclick="this.href='/admin/ceklaporan/'+ document.getElementById('tglMulai').value + '/' + document.getElementById('tglSelesai').value +'/' + document.getElementById('statuss').value">Proses</a>
            </div>
        </div>
        <table class="table table-bordered table-striped" id="table-menu">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Tgl Penjualan</th>
                    <th>Kasir</th>
                    <th>Produk</th>
                    <th>Jumlah</th>
                    <th>Harga</th>
                    <th>Diskon</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
{{--
                @dd($data) --}}
                @foreach ($data as $m)
                    <tr>
                        <td>{{ $loop->iteration }}</td>
                        <td>{{ $m->tanggal }}</td>
                        <td>{{ $m->kasir }}</td>
                        <td>{{ $m->pesanan }}</td>
                        <td>{{ $m->jumlah }}</td>
                        <td>Rp {{ number_format($m->harga_satuan) }}</td>
                        <td>{{ $m->diskon }} %</td>
                        <td>{{ $m->status }}</td>
                    </tr>
                @endforeach
            </tbody>
            <tfoot>
                @if ($jumlah != null)
                    <tr>
                        <th colspan="7">Total Pendapatan :</th>
                        <th>Rp {{ number_format($sumTotal) }}</th>
                    </tr>
                @endif
            </tfoot>
        </table>
        <a href="" class="btn btn-primary" id="btn-cetak" target="_blank"
            onclick="this.href='/admin/laporan/cetak/'+ document.getElementById('tglMulai').value + '/' + document.getElementById('tglSelesai').value + '/' + document.getElementById('statuss').value">Cetak
            Laporan</a>
    </div>
@endsection

@push('script')
    <script>
        $(document).ready(function() {
            $('#table-menu').DataTable();
        });
    </script>
@endpush
