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

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

    <style>
      
        .h1{
          margin: 50px 50px 50px 250px;
          
        }

        .card{
          margin: 25px 0px;
        }


        .btn-circle{
          width: 30px;
          height: 30px;
          text-align: center;
          padding: 6px 0;
          font-size: 12px;
          line-height: 1.428571429;
          border-radius: 15px;
        }
         /*body{
        background: url(https://images.unsplash.com/photo-1486286701208-1d58e9338013?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80);
        background-size: cover;
        background-position: center;
        background-attachment: fixed;
        } */

        .form-inline{
            /* margin: 10px 0px 10px 750px;
            padding: 6px 0; */
            float: right;
          }

    </style>

    <title>Booking History</title>
  
  </head>
<body>
    
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      
      <div class="container">
        
        <a class="navbar-brand" href="{% url 'resources' %}">Sports Resources</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
        </button>

          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            
            <ul class="navbar-nav mr-auto">
              <!-- <li class="nav-item active">
              <a class="nav-link" href="#">Home </a>
              </li> -->
              <li class="nav-item">
                <a class="nav-link" href="{% url 'about' %}">About</a>
              </li>
      
              <li class="nav-item active">
                <a class="nav-link " href="{% url 'bookingHistory' %}">Booking History</a>
              </li>
      
              <li class="nav-item">
                <a class="nav-link" href="{% url 'bookingRequests' %}">Booking Requests</a>
              </li>
      
              <li class="nav-item">
                <a class="nav-link" href="{% url 'blockedUsers' %}">Blocked Users</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="{% url 'timetable' %}">Timetable</a>
              </li>
      
            </ul>
    
            <ul class="nav navbar-nav navbar-right">
              
              <!--<li class="nav-item"><a class="nav-link" href ="{% url 'logout' %}">Logout</a></li>-->
              <div class="bs-example">
              <div class="btn-group-vertical">
                  <div class="btn-group">
                      <button id="butn-1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Account</button>
                      <div class="dropdown-menu">
                          <a href="{% url 'updatePassword' %}" class="dropdown-item">Change Password</a>
                          <a href="{% url 'logout' %}" class="dropdown-item">Logout</a>
                      </div>
                  </div>
              <!-- <li class="nav-item"><a class="nav-link"href ="#">Login <i class="fa fa-user-plus" aria-hidden="true"></i></a></li> -->
            
             </ul>
          </div>

      </div> 
  
    </nav>


                
    <div class="container">
      <h1 class="mt-4 pt-4">Booking History</h1>
      <div>
        <form class="form-inline" method="GET" action="{%url 'bookingHistory'%}">
        <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="search" >
        <button class="btn btn-outline-success" type='submit'>Search</button>
        </form>
        </div>
      <br>
      {% for i in data2 %}
      <div class="card bg-light">
        <div class="card-body">

          <!--<button class="btn btn-circle btn-outline-danger pull-right" aria-hidden="true" style="border-radius: 20px; height: 40px; width: 40px; margin-top: 6px; margin-left: 10px;"><i class="fa fa-bell" aria-hidden="true"></i></button>-->
          <button class="btn btn-danger pull-right" style="border-radius: 20px; height: 40px; width: 125px; margin-top: 6px;" onclick=acceptResource({{i.user_id}})>{{i.booking_time}}</button>
          <div class="h3 d-inline">{{i.resource_name}}</div>
          <div class="small">{{i.name}} - {{i.user_id}}</div>
          
        </div>
      </div>
      {% endfor %} 

      {% for j in data1 %}
      <div class="card bg-light">
        <div class="card-body">

          <button class="btn btn-danger pull-right" style="border-radius: 20px; height: 40px; width: 125px; margin-top: 6px;" onclick=acceptResource({{j.user_id}})>{{j.day}}</button>
          <div class="h3 d-inline">{{j.resource_name}}</div>
          <div class="small">{{j.name}} -{{j.user_id}}</div>
        
        </div>
      </div>
      {% endfor %}

      {% for k in data3 %}
      <div class="card bg-light">
        <div class="card-body">

          <button class="btn btn-primary pull-right" style="border-radius: 20px; height: 40px; width: 125px; margin-top: 6px;">{{k.return_time}}</button>
          <div class="h3 d-inline">{{k.resource_name}}</div>
          <div class="small">{{k.name}} -{{k.user_id}}</div>
        
        </div>
      </div>
      {% endfor %}
  </div>
      <!-- Bootstrap JS -->
      <script>
        function acceptResource(id){
          $.ajax({
            type:"GET",
            data:{'id':id},
            url:"{{'/sports/acceptResource'}}",
            success:function(data){
              location.reload()
            }
          });
        }
      </script>
    <script
    src="https://code.jquery.com/jquery-3.5.1.min.js"
    integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
    crossorigin="anonymous"></script>
    <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
  </body>
</html>
