<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Jadwal Operasi</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <link rel="shortcut icon" type="image/png" href="<?= base_url('assets_/assets/img/logo-mini.png') ?>">
  <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
  <style>
    h1 {
      font-size: 30px;
      font-weight: bold;
      color: #000;
      text-transform: uppercase;
      font-weight: 300;
      text-align: center;
      margin-bottom: 15px;
      margin-top: 20px;
    }

    table {
      width: 100%;
      table-layout: fixed;
    }

    .tbl-header {
      background-color: #007bff;
      /* Warna latar belakang header tabel */
    }

    .tbl-header.aa {
      background-color: rgb(0, 1, 2);
      /* Warna latar belakang header tabel */
    }

    .tbl-content {
      max-height: 400px;
      /* Atur batas maksimum tinggi */
      overflow-y: auto;
      /* Mengizinkan scroll vertikal */
      overflow-x: hidden;
      /* Menyembunyikan scroll horizontal */
      margin-top: 0px;
      border: 1px solid rgba(255, 255, 255, 0.3);
      position: relative;
      /* Untuk animasi */
      transition: transform 0.5s ease;
      /* Animasi geser */
    }

    th {
      padding: 10px 15px;
      text-align: center;
      /* Memusatkan teks di header tabel */
      font-weight: 200;
      font-weight: bold;
      font-size: 20px;
      /* Ukuran font header tabel */
      color: #000;
      text-transform: uppercase;
      background-color: rgba(0, 123, 255, 0.78);
    }

    td {
      padding: 15px;
      text-align: center;
      /* Memusatkan teks di sel data tabel */
      vertical-align: middle;
      font-weight: 300;
      font-size: 14px;
      /* Ukuran font isi tabel */
      color: #000;
      background-color: rgba(252, 252, 252, 0.78);
      border-bottom: solid 1px rgba(255, 255, 255, 0.1);
    }

    @import url(https://fonts.googleapis.com/css?family=Roboto:400,500,300,700);

    body {
      font-family: 'Roboto', sans-serif;
    }

    /* Mengatur gambar latar belakang */
    .background-image {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-image: url('<?= base_url('assets_/assets/img/backgroundhd1.jpg') ?>');
      background-size: cover;
      background-position: center;
      opacity: 0.3;
      z-index: -1;
    }

    section {
      margin: 50px;
    }

    .header-logo {
      margin: 20px 0 10px 0;
    }

    .made-with-love {
      margin-top: 40px;
      padding: 10px;
      clear: left;
      text-align: center;
      font-size: 10px;
      font-family: Arial;
      color: #fff;
    }

    .made-with-love i {
      font-style: normal;
      color: #F50057;
      font-size: 14px;
      position: relative;
      top: 2px;
    }

    .made-with-love a {
      color: #fff;
      text-decoration: none;
    }

    .made-with-love a:hover {
      text-decoration: underline;
    }

    /* Custom scrollbar for webkit browsers */
    ::-webkit-scrollbar {
      width: 6px;
    }

    ::-webkit-scrollbar-track {
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    }

    ::-webkit-scrollbar-thumb {
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    }
  </style>
</head>

<body>

  <div class="background-image"></div> <!-- background image -->

  <div class="text-center mb-4">
    <img class="header-logo" src="<?php echo base_url(); ?>assets_/assets/img/and.png" height="90" width="300" class="mb-2">
    <h1 style="font-weight: bold;">Jadwal Operasi Instalasi Bedah Sentral</h1>
  </div>

  <section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-12">
          <div class="card">
            <div class="card-body tbl-content" id="table-container">
              <div class="">
                <table id="example2" class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th>Nomor Operasi</th>
                      <th>Tanggal</th>
                      <th>Kode Registrasi</th>
                      <th>Dokter Operasi</th>
                    </tr>
                  </thead>
                  <tbody id="jadwal-operasi-body">
                    <!-- Data akan dimuat di sini -->
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>

  <script>
    $(document).ready(function() {
      function loadJadwalOperasi() {
        $.ajax({
          url: "<?php echo base_url('ikbs/get_jadwal_operasi'); ?>",
          type: "POST",
          dataType: "json",
          success: function(data) {
            var tbody = $('#jadwal-operasi-body');
            tbody.empty();
            var tglsekarang = '<?php echo date("Y-m-d"); ?>';

            if (data) {
              $.each(data, function(index, item) {
                if (item.tgl_op >= tglsekarang) {
                  var row = '<tr>';
                  // row += '<td>' + (index + 1) + '</td>';
                  row += '<td>' + item.no_index_op + '</td>';
                  row += '<td>' + item.tgl_op + '</td>';
                  row += '<td>' + item.kd_registrasi + '</td>';
                  row += '<td>' + item.dokter_op + '</td>';
                  row += '</tr>';
                  tbody.append(row);
                }
              });
            } else {
              tbody.append('<tr><td colspan="5" class="text-center">Data tidak ditemukan</td></tr>');
            }

            // Mulai fungsi slide jika ada lebih dari 8 data
            if (tbody.children().length > 1) {
              startSliding();
            }
          }
        });
      }

      function startSliding() {
        setInterval(function() {
          $('#table-container').css('transform', 'translateX(-100%)'); // Geser ke kiri

          // Setelah 1 menit, kembali ke posisi awal
          setTimeout(function() {
            $('#table-container').css('transform', 'translateX(0)'); // Kembali ke posisi awal
          }, 10000); // 1 menit
        }, 120000); // Geser setiap 2 menit
      }

      loadJadwalOperasi();
      setInterval(loadJadwalOperasi, 30000);
    });
  </script>



</body>
<!-- <div style="margin-top: 10px;" class="text-center">
  <a><strong> By IT Support RSU Ananda </strong></a>
</div> -->

</html>