<?php

require 'functions.php';

$books = query("SELECT * FROM tb_booklog 
WHERE status_pembayaran = 'berhasil' 
AND tanggal_pesan BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 2 MONTH);");
setlocale(LC_TIME, 'id_ID');
usort($books, function($a, $b) {
  return strtotime($a['tanggal_pesan']) - strtotime($b['tanggal_pesan']);
});

?>

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

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
    <link rel="stylesheet" href="index2.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-TJYvzCPck+pAZ/6FzLJjPZnbvPfT+os8TJ1aT9XKKBAPhJLsgOfPJOJZzEwZ1wjqJ1btiMjKCYyPm+xsiomowA==" crossorigin="anonymous" referrerpolicy="no-referrer" />

    <!-- my font -->
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">

    <title>Villahayati.</title>
</head>
<body>
    <!-- navbar -->
    <nav class="navbar navbar-expand-lg">
  <div class="container">
    <a class="navbar-brand"><span class="stay">Villa</span>hayati.</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
      <ul class="navbar-nav mr-auto">
        <!-- Your navigation items go here -->
      </ul>
      <ul class="navbar-nav">
        <li class="nav-item">
          <a href="login/login.php" class="btn btn-danger">Login Or Register</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

    
    <!-- end of navbar -->


    <!-- Daftar Tanggal Terbooking -->
    <div class="villa">
        <div class="container">
            <div class="row mt-5">
                <div class="col-md-12">
                    <h4 class="center">Daftar Tanggal Terbooking</h4>
                    <p class="sub"> (Dalam 2 Bulan Kedepan) <br>Note : Check-In Minimal Pukul 02.00 , Check-Out Maksimal Pukul 12.00 </br></p>
                </div>
            </div>
            <div class="row mb-5">
                <div class="col-md-12">
                    <table class="table table-striped table-hover">
                        <thead class="thead-dark text-center">
                            <tr>
                                <th scope="col">No.</th>
                                <th scope="col">Tanggal</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php $i = 1; ?>
                        <?php foreach($books as $book) : ?>
                            <tr>
                                <th class="text-center" scope="row"><?= $i; ?></th>
                                <td class="text-center"><?= strftime('%d %B %Y', strtotime($book['tanggal_pesan'])); ?> - <?= strftime('%d %B %Y', strtotime($book['tanggal_pulang'])); ?></td>
                            </tr>
                            <?php $i++; ?>
                        <?php endforeach; ?>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>        
                        </div>
    <!-- end of table -->

    

    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
    <!-- <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></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> -->

    <!-- Option 2: jQuery, Popper.js, and Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
</body>
</html>
