<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <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="app.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;
        }

        /*.fa-plus{
          font-size: 100px;
          float: right;
        }*/
        /* 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 50px 10px 750px;
              padding: 6px 0; */
            float: right;
            }
            .buttonRight{
              position: absolute;
              bottom: 0;
              right: 0;
              display: inline-block;
              margin-left: -20px;
              margin-right: 150px;
              margin-bottom: 80px;
              padding: 10px 24px;
              position: fixed;
              }
              .btn-circle {
            width: 40px;
            height: 40px;
            padding: 6px 0px;
            border-radius: 75px;
            text-align: center;
            font-size: 20px;
            line-height: 1.42857;
        }
        .form-popup {
        display: none;
        position: fixed;
        bottom: 0;
        right: 15px;
        border: 3px solid #f1f1f1;
        z-index: 9;
      }
      .form-container {
      max-width: 300px;
      padding: 10px;
      background-color: white;
    }
    /* Set a style for the submit/login button */
      .form-container .btn {
        background-color: #4CAF50;
        color: white;
        padding: 16px 20px;
        border: none;
        cursor: pointer;
        width: 100%;
        margin-bottom:10px;
        opacity: 0.8;
      }

      /* Add a red background color to the cancel button */
      .form-container .cancel {
        background-color: rgba(255, 0, 0, 0.746);
      }
      .form-container input[type=text] {
      width: 100%;
      padding: 15px;
      margin: 5px 0 22px 0;
      border: none;
      background: #f1f1f1;
    }


    </style>

    <title>Blocked users</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">
                <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 active">
                <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">Blocked Users</h1>
      <div>
        <!--<form class="form-inline my-2 my-lg-0" method="GET" action="{%url 'blockUsers'%}">
          <b><label for="blockUser" style="color: brown;">Enter UserId</label></b>
        <input class="form-control mr-sm-2" type="text" placeholder="Enter UserId to block"  name="id" >
        <button class="btn btn-outline-success my-2 my-sm-0" type='submit'>Submit</button>
        </form>
        </div>
      <div>-->
        <form class="form-inline my-2 my-lg-0" method="GET" action="{%url 'blockedUsers'%}">
        <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="search" >
        <button class="btn btn-outline-success my-2 my-sm-0" type='submit'>Search</button>
        </form>
        </div>
                <!--<button class="fa fa-plus pull-right d-inline text-secondary" aria-hidden="true" style="margin-right: 250px; margin-top: 15px; outline: none; background-color: transparent; border: none;"></button>-->
    <br>
    {% for i in data %}
    
    <div class="card bg-light">
      <div class="card-body">

        <button class="btn btn-secondary pull-right" style="border-radius: 20px; height: 40px; width: 125px; margin-top: 6px;" onclick=unblock({{i.user_id}})>Unblock</button>
        <div class="h3 d-inline">{{i.user_id}}-{{i.name}}</div>
        <div class="small">{{i.resource_name}}-fine:{{i.fine}}</div>
      
      </div>
    </div>

    {% endfor %}
    <div class="buttonRight">
      <button type="button" class="btn btn-success btn-circle btn-xl" onclick="openForm()" >
      <i class="fa fa-plus" aria-hidden="true" ></i>
      </button>
      <div class="form-popup" id="myForm" style="display:none">
        <form method="GET" action="{%url 'blockUsers'%}" class="form-container" >
      
          <label for="id"><b>Id</b></label>
          <input type="text" placeholder="Enter ID" name="id" required>
          <br>
          <label for="fine"><b>Fine</b></label>
          <input type="text" placeholder="Enter Fine" name="fine" required>
        
          <button type="submit" class="btn">Submit</button>
          <button type="button" class="btn cancel" onclick="closeForm()">Close</button>
        </form>
      </div>
    </div>
    <script>
      function unblock(id){
        $.ajax({
          type:"GET",
          data:{'id':id},
          url:"{{'/sports/unblock'}}",
          success:function(data){
            location.reload()
          }
        });
      }
    </script>
    <script>
      function openForm() {
        document.getElementById("myForm").style.display = "block";
      }
      
      function closeForm() {
        document.getElementById("myForm").style.display = "none";
      }
      </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>
