{% extends 'base.html' %}
{% block content %}
<div class="row">

    <div class="col-lg-12 grid-margin stretch-card">
      <div class="card">
      
        <div class="card-body">
            <div class="card-block">
                <h4 class="sub-title">Between Dates Report</h4>
                <form method="get" action="" enctype="multipart/form-data" action="{% url 'complaintsreports' %}">
                    {% csrf_token %}
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">From Date</label>
                        <div class="col-sm-10">
                            <input type="date" id="query" name="start_date" class="form-control" required="">
                        </div>
                    </div>
                     <div class="form-group row">
                        <label class="col-sm-2 col-form-label">To Date</label>
                        <div class="col-sm-10">
                            <input type="date" id="query" name="end_date" class="form-control" required="">
                        </div>
                    </div>
    
    
                    <div class="form-group row">
                        <div class="col-sm-10">
                            <button type="submit" class="btn btn-dark">Submit</button>
                        </div>
                    </div>
                </form>
                        
                            </div>
                            {% if lodgedcomplaints %}
        <p style="font-size: 20px;color: blue;text-align: center;">Data Between: "{{ start_date }} to {{ end_date }}"</p>
        
          {% include 'includes/messages.html' %}
          <table class="table table-bordered">
            <thead>
              <tr>
                <th style="font-weight: bolder;"> # </th>
                <th style="font-weight: bolder;"> Complaint No</th>
                <th style="font-weight: bolder;"> Complainant Name</th>
                <th style="font-weight: bolder;"> Complainant Mobile Number</th>
                <th style="font-weight: bolder;"> Complaint Lodged Date </th>
                <th style="font-weight: bolder;"> Status </th>
                <th style="font-weight: bolder;">Action </th>
              </tr>
            </thead>
            <tbody>
                {% for i in lodgedcomplaints %}
              <tr>
                <td> {{ forloop.counter }}</td>
                <td>{{i.complaint_number}}</td>
                <td>{{ i.userregid.admin.first_name }} {{ i.userregid.admin.last_name }}</td>
                <td>{{i.userregid.mobilenumber}}</td>
                <td>{{i.complaintdate_at}}</td>
                <td>{% if i.status == '0' %}
                    <span class="badge badge-danger">Not Processed Yet</span>
                {% elif i.status == 'Inprocess' %}
                    <span class="badge badge-warning">In Process</span>
                {% elif i.status == 'Closed' %}
                    <span class="badge badge-success">Closed</span>
                {% endif %}</td>
                <td><a href="{% url 'viewlodgedcomplaint' i.id %}" class="btn btn-success">
                    View</a></td>
              </tr>{% endfor %}
           
            </tbody>
          </table>
          <div class="pagination" style="padding-top: 10px;text-align: center;">
            <span class="step-links">
                {% if complaints.has_previous %}
                    <a href="?page=1">&laquo; first</a>
                    <a href="?page={{ complaints.previous_page_number }}">previous</a>
                {% endif %}
        
                <span class="current">
                    Page {{ complaints.number }} of {{ complaints.paginator.num_pages }}.
                </span>
        
                {% if complaints.has_next %}
                    <a href="?page={{ complaints.next_page_number }}">next</a>
                    <a href="?page={{ complaints.paginator.num_pages }}">last &raquo;</a>
                {% endif %}
            </span>
        </div>
        </div>{% endif %}
        
      </div>
    </div>
    
    
  </div>
  {% endblock %}