@extends('admin-layouts.master')

@section('content')
<div class="container-fluid">

    <!-- Page Heading -->
    <h1 class="h3 mb-2 text-gray-800">Data Pemeriksaan Pasien</h1>
    

    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">Pasien yang telah melakukan pemeriksaan</h6>
        </div>
        <div class="card-body">
            <div class="text-right px-3 py-3">

                {{-- <a href="{{ route('pasien.create') }}" class="btn btn-outline-primary">
                    Tambah User
                </a> --}}

            </div>
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>No Rekam Medis</th>
                            <th>Nama</th>
                            <th>Tekanan Darah</th>
                            <th>Tinggi Badan</th>
                            <th>Berat Badan</th>
                            <th>Respi</th>
                            <th>Suhu Tubuh</th>
                            <th>Nadi</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    
                    <tbody>
                        @foreach ($pemeriksaan as $u)
                        <tr>
                                
                            <td>{{ $loop->iteration }}</td>
                            <td>{{ $u->pasien->nomor_rekam_medis }}</td>
                            <td>{{ $u->pasien->nama_pasien }}</td>
                            <td>{{ $u->tekanan_darah }}</td>
                            <td>{{ $u->tinggi_badan }}</td>
                            <td>{{ $u->berat_badan }}</td>
                            <td>{{ $u->respi}}</td>
                            <td>{{ $u->suhu }}</td>
                            <td>{{ $u->nadi }}</td>
                            <td>
                                {{-- <a class="btn btn-info" href="{{ route('pasien.show',$u) }}"><i class="fas fa-eye"></i></a> --}}
                                <a class="btn btn-warning" href="{{ route('pemeriksaan.edit',$u) }}"><i class="fas fa-edit"></i></a>
                                <button href="{{route('pemeriksaan.destroy', $u)}}" id="delete" class="btn btn-danger"><i class="fas fa-trash"></i></button>
                                {{-- <a class="btn btn-success" href=""><i class="fas fa-notes-medical"></i> Pemeriksaan</a> --}}
                            </td>
                        </tr>
                        @endforeach
                        
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>
<form action="" method="post" id="deleteForm">
    @csrf
    @method("DELETE")
    <input type="submit" value="Hapus" style="display:none">
    </form>
    @push('scripts')
    
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous">
    </script>

    <script>
    $('button#delete').on('click', function(e){
      e.preventDefault();
    
      var href = $(this).attr('href');
    
      Swal.fire({
          title: 'Apakah Kamu yakin akan menghapus data ini?',
          text: "Data yang sudah dihapus tidak dapat dikembalikan!",
          icon: 'warning',
          showCancelButton: true,
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          confirmButtonText: 'Ya, Hapus!'
          }).then((result) => {
          if (result.value) {
              document.getElementById('deleteForm').action = href;
              document.getElementById('deleteForm').submit();
                  Swal.fire(
                  'Berhasi Dihapus!',
                  'Data Kamu Berhasil Dihapus.',
                  'success'
                  )
              }
          })
    
    
    })
   
    </script>
<script src="{{ asset('template-admin/vendor/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('template-admin/vendor/datatables/dataTables.bootstrap4.min.js') }}"></script>
<script src="{{ asset('template-admin/js/demo/datatables-demo.js') }}"></script>
@endpush

@endsection