@extends('layouts.main')
@section('container')
    @if (session()->has('success'))
        <div class="alert alert-success alert-dismissible show fade">
            <div class="alert-body">
                <button class="close" data-dismiss="alert">
                    <span>×</span>
                </button>
                {{ session('success') }}
            </div>
        </div>
    @endif
    <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex justify-content-between align-items-center">
            <h6 class="m-0 font-weight-bold text-primary">Data Obat</h6>
            <a href="/data_obat/tambah" class="btn btn-primary btn-icon-split btn-sm">
                <span class="icon text-white-50">
                    <i class="fas fa-plus"></i>
                </span>
                <span class="text">Tambah</span>
            </a>
        </div>

        <div class="card-body">
            <div class="table-responsive">
                <table id="example" class="table table-stripped table-hover">
                    <thead>
                        <tr>
                            <th class="text-center">No</th>
                            <th class="text-center" style="width: 10%">Nama Obat</th>
                            <th class="text-center" style="width: 10%">Jenis Obat</th>
                            <th class="text-center" style="width: 50%">Keterangan</th>
                            <th class="text-center"style="width: 20%">Action</th>
                        </tr>
                    </thead>
                    <tbody class="text-center">
                        @foreach ($dataVaksin as $dv)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td>{{ $dv->nama_obat }}</td>
                                <td>{{ $dv->jenis_obat }}</td>
                                <td>{{ $dv->keterangan_obat }}</td>
                                <td>
                                    <a href="/data_obat/edit/{{ $dv->id }}" class="btn btn-primary">
                                        <span class="icon text-white">
                                            <i class="far fa-edit"></i>
                                        </span>
                                    </a>
                                    <a href="#" data-toggle="modal" data-target="#hapusData{{ $dv->id }}"
                                        class="btn btn-danger">
                                        <span class="icon text-white">
                                            <i class="fas fa-trash"></i>
                                        </span>
                                    </a>
                                </td>
                            </tr>
                            <div class="modal fade" id="hapusData{{ $dv->id }}" tabindex="-1" role="dialog"
                                aria-labelledby="exampleModalLabel" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Apakah Kamu Akan Menghapus Data
                                                Obat {{ $dv->nama_obat }}?
                                            </h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                        <div class="modal-body">Pilih "Hapus" di bawah jika Anda ingin menghapus data obat
                                            {{ $dv->nama_obat }}
                                        </div>
                                        <div class="modal-footer">
                                            <form action="/data_obat/{{ $dv->id }}/delete" method="post"
                                                class="d-inline">
                                                @method('delete')
                                                @csrf
                                                <button class="btn btn-secondary" type="button"
                                                    data-dismiss="modal">Cancel</button>
                                                <button class="btn btn-danger">Hapus</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
