@extends('layouts.layout-user')
@section('content')
<table id="table-register" class="table table-bordered table-hover">
    <thead>
        <tr>
            <th colspan="10">
                <h2 style="display: inline-block; margin-right: 10px;">Data Tindak Lanjut Pelaporan Bahaya</h2>
                <span style="margin:1%; float: right;"></span>
                <form class="w-72" action="{{route('tindakan.index')}}" method="GET">
                    <div class="input-group input-group-merge" style="max-width: 300px">
                        <span class="input-group-text" id="basic-addon-search31"><i class="fa fa-search"></i></span>
                        <input name="search" class="form-control" placeholder="Search..." aria-label="Search..." aria-describedby="basic-addon-search31"></input>
                    </div>
                </form>
            </th>
        </tr>
        <tr style="background-color: #155dfa;">
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">No</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Judul Laporan</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Keterangan Laporan</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Tanggal Dibuat</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Lokasi</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Tingkat Bahaya</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Status Tindakan</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Saran Tindakan</th>
            <th style="vertical-align: middle; color: white; text-align: center; padding: 10px;">Foto</th>
            <th style="vertical-align: middle; text-align: center; color: white; padding: 10px;">Action</th>
        </tr>


    </thead>
    <!-- Isi tabel -->
    <tbody>
        @php
            $i=1;
        @endphp
        @if($pelaporans->count() >0)
         @foreach ($pelaporans as $pelaporan)
         <tr>
             <td style="text-align: center; vertical-align: middle;">{{ $i++ }}</td>
             <td style="text-align: center; vertical-align: middle;">{{ $pelaporan->judul }}</td>
             <td style="text-align: center; vertical-align: middle; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{ $pelaporan->keterangan }}</td>
             <td style="text-align: center; vertical-align: middle;">{{ $pelaporan->tanggal }}</td>
             <td style="text-align: center; vertical-align: middle;">{{ $pelaporan->lokasi }}</td>
             <td style="text-align: center; vertical-align: middle;">
                 <div style="
                     @if ($pelaporan->status === 'Ringan')
                         background-color: #1593fa; /* Biru Muda */
                     @elseif ($pelaporan->status === 'Sedang')
                         background-color: rgb(156, 196, 54); /* Kuning Muda */
                     @elseif ($pelaporan->status === 'Berat')
                         background-color: rgba(219, 71, 71, 0.799); /* Merah Muda */
                     @else
                         background-color: #ffffff; /* Default, putih */
                     @endif
                     width: 80px; height: 30px; border-radius: 10px;
                     display: flex; justify-content: center; align-items: center;
                     font-weight: bold; color: white;
                 ">
                     • {{ $pelaporan->status }}
                 </div>
             </td>
             <td style="text-align: center; vertical-align: middle;">
                <div style="
                     @if ($pelaporan->tindakan->statusTindakan  === 'Belum ditindak')
                            background-image: linear-gradient(to right, #0867E9, #6BA3F0);
                            width: 150px; /* Ganti nilai width sesuai kebutuhan */
                            height: 30px; /* Ganti nilai height sesuai kebutuhan */
                            border-radius: 10px; /* Membuat sudut bulat dengan radius 10px */
                            display: flex; /* Menggunakan flexbox */
                            justify-content: center; /* Pusatkan secara horizontal */
                            align-items: center; /* Pusatkan secara vertikal */
                            font-weight: bold; /* Teks tebal */
                            color: white; /* Warna teks putih */
                     @elseif ($pelaporan->tindakan->statusTindakan  === 'Diverifikasi')
                            background-image: linear-gradient(to right, #F76D2E, #EEA45D);
                            width: 150px; /* Ganti nilai width sesuai kebutuhan */
                            height: 30px; /* Ganti nilai height sesuai kebutuhan */
                            border-radius: 10px; /* Membuat sudut bulat dengan radius 10px */
                            display: flex; /* Menggunakan flexbox */
                            justify-content: center; /* Pusatkan secara horizontal */
                            align-items: center; /* Pusatkan secara vertikal */
                            font-weight: bold; /* Teks tebal */
                            color: white; /* Warna teks putih */
                     @elseif ($pelaporan->tindakan->statusTindakan  === 'Ditindak lanjuti')
                            background-image: linear-gradient(to right, #F84B67, #F86E85);
                            width: 150px; /* Ganti nilai width sesuai kebutuhan */
                            height: 30px; /* Ganti nilai height sesuai kebutuhan */
                            border-radius: 10px; /* Membuat sudut bulat dengan radius 10px */
                            display: flex; /* Menggunakan flexbox */
                            justify-content: center; /* Pusatkan secara horizontal */
                            align-items: center; /* Pusatkan secara vertikal */
                            font-weight: bold; /* Teks tebal */
                            color: white; /* Warna teks putih */
                     @elseif ($pelaporan->tindakan->statusTindakan === 'Selesai')
                            background-image: linear-gradient(to right, #08976B, #47D5A7);
                            width: 150px; /* Ganti nilai width sesuai kebutuhan */
                            height: 30px; /* Ganti nilai height sesuai kebutuhan */
                            border-radius: 10px; /* Membuat sudut bulat dengan radius 10px */
                            display: flex; /* Menggunakan flexbox */
                            justify-content: center; /* Pusatkan secara horizontal */
                            align-items: center; /* Pusatkan secara vertikal */
                            font-weight: bold; /* Teks tebal */
                            color: white; /* Warna teks putih */
                     @endif
                 ">
                     • {{ $pelaporan->tindakan->statusTindakan }}
                 </div>
            </td>
            <td style="text-align: center; vertical-align: middle; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{$pelaporan->saran}}</td>
             <td style="text-align: center; vertical-align: middle;"><img src="{{ asset('foto/' . $pelaporan->foto) }}" alt="Foto Pelaporan" style="width: 100px; height: 100px; object-fit: cover;"></td>
             <td style="text-align: center; vertical-align: middle;">
                <div style="display: flex; flex-direction: column; align-items: center;">
                    <a href="{{ route('tindakan.edit', ['id' => $pelaporan->id]) }}" class="btn btn-delete" style="background-color: rgb(82, 210, 67); color: #fff; border: none; border-radius: 4px; cursor: pointer; width: 100px;">Update</a>
                    <div style="margin-top: 10px;"></div> <!-- Spacer -->
                    <a href="{{ route('tindakan.destroy', ['id' => $pelaporan->id]) }}" class="btn btn-delete"  style="background-color: red; color: #fff; border: none; border-radius: 4px; cursor: pointer; width: 100px;">Delete</a>
                    <div style="margin-top: 10px;"></div> <!-- Spacer -->
                    <a href="{{ route('tindakan.show', ['id' => $pelaporan->id]) }}" class="btn btn-delete" style="background-color: rgb(0, 106, 255); color: #fff; border: none; border-radius: 4px; cursor: pointer; width: 100px;">Show</a>
                </div>


             </td>
         </tr>
        @endforeach
     @else
            <tr>
                <td class="text-center" colspan="9">Laporan not found</td>
            </tr>
        @endif
    </tbody>
</table>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>

@endsection
