@extends('layout.app')
@section('title', $title)
@section('content')
    {{ show_msg() }}
    <div class="card card-primary card-outline">
        <div class="card-header">
            <form class="form-inline row align-items-center">
                <div class="col-auto mr-1">
                    <select class="form-control" name="kode_produk">
                        <option value="">Semua Produk</option>
                        <?= get_produk_option($kode_produk) ?>
                    </select>
                </div>
                <div class="col-auto mr-1">
                    <input class="form-control" type="text" name="q" value="{{ $q }}" 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" {{ is_hidden('hitung.hasil.cetak') }}>
                    <a class="btn btn-secondary" href="{{ route('hitung.hasil.cetak', ['kode_produk' => $kode_produk]) }}" target="_blank"><span class="fa fa-print"></span> Cetak</a>
                </div>
            </form>
        </div>

        <div class="card-body p-0 table-responsive">
            <table class="table table-bordered table-hover table-striped m-0">
                <thead>
                    <th>No</th>
                    <th>Tanggal</th>
                    <th>Produk</th>
                    <th>Periode n</th>
                    <th>Hasil  </th>
                    <th>MAPE</th>
                    <th>Akurasi</th>
                </thead>
                @foreach ($rows as $key => $row)
                    <tr>
                        <td>{{ $no++ }}</td>
                        <td>{{ date('M-Y', strtotime($row->tanggal)) }}</td>
                        <td>{{ $row->nama_produk }}</td>
                        <td>{{$row->periode}}</td>
                        <td>{{ number_format($row->jumlah, 2) }}</td>
                        <td>{{ number_format($row->mape * 100, 2) }}%</td>
                        <td>{{ $row->akurasi }}</td>
                    </tr>
                @endforeach
            </table>
        </div>
        @if ($rows->hasPages())
            <div class="card-footer">
                {{ $rows->links() }}
            </div>
        @endif
    </div>
@endsection
