<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Laporan Hasil Perhitungan Hulu Sungai</title>
    <style>
        * {
            font-family: 'Times New Roman', Times, serif;
        }
        @page {
  size: auto;  /* auto is the initial value */
  margin: 0mm; /* this affects the margin in the printer settings */
}
html {
  margin: 0px; /* this affects the margin on the HTML before sending to printer */
}
body {
  margin: 10mm 15mm 10mm 15mm; /* margin you want for the content */
}
    </style>
  </head>
  <body>
    <table class=" table-hover   table tables-responsive" style="width:100% !important" id="table">
      <h6>Nama Device : {{ $nama_device->nama_device }}</h6>
      <h6>Waktu Awal : {{ date("d, F Y",strtotime($awal)) }}</h6>
      <h6>Waktu Akhir :  {{ date("d, F Y",strtotime($akhir)) }}</h6>
      <thead>
        <tr>
          <th>#</th>
          <th>Nama Perangkat</th>
          <th>Lokasi</th>
          <th>Rata-Rata Ketinggian</th>
          <th>Status Siaga</th>
          <th>Tanggal Interval</th>
          <th>Tanggal Kalkulasi</th>
        </tr>
      </thead>
      <tbody>
        @foreach ($result as $rows) 
  @php
      $setting = Illuminate\Support\Facades\DB::table('setting_siaga')
              ->where("uuid_device",$rows->uuid_device)
              ->OrderBy("uuid","desc")
              ->first();
              if($rows) {
                  if($rows->status_siaga == "Siaga 1") {
                      $siaga  = 30;
                  } 
                  if($rows->status_siaga == "Siaga 2") {
                      $siaga = 60;
                  }
                  if($rows->status_siaga == "Siaga 3") {
                      $siaga = 80;
                  }
                  if($rows->status_siaga == "Siaga 4") {
                      $siaga = 100;
                  }
                  if($rows->status_siaga == "Normal") {
                      $siaga = 15;
                  }
              }
  @endphp 
        <tr>
          <td>{{ $loop->iteration }}</td>
          <td>{{ $rows->alat->nama_device }}</td>
          <td>{{ $rows->alat->location }}</td>
          <td><span>{{ $rows->depth_average }} CM </span></td>
          <td>
            @if ($rows->status_siaga == "Siaga 1")
              <span>Siaga 1</span>
              @elseif ($rows->status_siaga == "Siaga 2")
              <span>Siaga 2</span>
              @elseif ($rows->status_siaga == "Siaga 3")
              <span>Siaga 3</span>
              @elseif ($rows->status_siaga == "Siaga 4")
              <span>Siaga 4</span>
              @elseif($rows->status_siaga == "Normal")
              <span>Normal</span>
            @endif
          </td>
          <td>{{ date("d, F Y H:i",strtotime($rows->datetime_calculate)) }}</td>
          <td>{{ date("d, F Y H:i",strtotime($rows->last_time)) }}</td>
        </tr>
        @endforeach
      </tbody>
    </table>

    <script>
        window.print();
    </script>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  </body>
</html>