@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-md-6 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('produk.create') }}>
                    <a class="btn btn-primary" href="{{ route('produk.create') }}"><i class="fa fa-plus"></i> Tambah</a>
                </div>
                <div class="col-auto mr-1" {{ is_hidden('produk.cetak') }}>
                    <a class="btn btn-secondary" href="{{ route('produk.cetak') }}" 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>Kode</th>
                    <th>Nama Produk</th>
                    <th>Aksi</th>
                </thead>
                @foreach ($rows as $key => $row)
                    <tr>
                        <td>{{ ($rows->currentPage() - 1) * $limit + $key + 1 }}</td>
                        <td>{{ $row->kode_produk }}</td>
                        <td>{{ $row->nama_produk }}</td>
                        <td>
                            <a class="btn btn-sm btn-info" href="{{ route('produk.edit', $row) }}"
                                {{ is_hidden('produk.edit') }}><i class="fa fa-edit"></i> Ubah</a>
                            <form action="{{ route('produk.destroy', $row) }}" method="POST"
                                style="display: inline-block;" onsubmit="return confirm('Hapus Data?')"
                                {{ is_hidden('produk.destroy') }}>
                                {{ csrf_field() }}
                                {{ method_field('DELETE') }}
                                <button type="submit" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i>
                                    Hapus</button>
                            </form>
                        </td>
                    </tr>
                @endforeach
            </table>
        </div>
        @if ($rows->hasPages())
            <div class="card-footer">
                {{ $rows->links() }}
            </div>
        @endif
    </div>
@endsection
