@extends('layout.app')
@section('title', $title)
@section('content')
<div class="row">
    <div class="col-md-12">
        <form class="form-inline row align-items-center" method="GET" action="">
            <div class="col-md-6 mr-1">
                <input class="form-control" type="text" name="q" value="{{$search}}" placeholder="Pencarian..." />
            </div>
            <div class="col-auto mr-1">
                <button class="btn btn-success"><i class="fa fa-search"></i> Cari</button>
            </div>
            <div class="col-auto mr-1">
                <a class="btn btn-secondary" href="{{ route('hitung.cetak') }}" target="_blank"><span class="fa fa-print"></span> Cetak</a>
            </div>
        </form>
        @if (count($results) > 0)
        <div class="card-body p-0 table-responsive">
            <table class="table table-bordered table-hover table-striped m-0">
                <thead>
                    <tr>
                        <th>Kode Produk</th>
                        <th>Nama Produk</th>
                        <th>Tanggal</th>
                        <th>Jumlah</th>
                        <th>MAPE</th>
                        <th>Akurasi</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($results as $kode_produk => $rows)
                    @foreach ($rows as $item)
                    <tr>
                        <td>{{ $kode_produk }}</td>
                        <td>{{ $produks[$kode_produk] }}</td>
                        <td>{{ date('M-Y', strtotime($item->tanggal)) }}</td>
                        <td>{{ number_format($item->jumlah, 2) }}</td>
                        <td>{{ number_format($item->mape * 100, 2) }}%</td>
                        <td>{{ $item->akurasi }}</td>
                    </tr>
                    @endforeach
                    @endforeach
                </tbody>
            </table>
        </div>
        @else
        <div class="alert alert-info">
            <p>Tidak ada hasil perhitungan untuk periode ini.</p>
        </div>
        @endif
    </div>
</div>
@endsection
