{% 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">Search Complaints</h4>
                <form method="get">
                    {% csrf_token %}
                   
                    <div class="form-group row">
                        <label class="col-sm-4 col-form-label">Search(By Mobilenumber and Complaint Number)</label>
                        <div class="col-sm-10">
                            <input type="text" id="query" name="query" 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 searchcomp %}
                            {% if messages %}
                            {% for message in messages %}
                             {% if message.tags == 'error' %}
                           <div class="alert alert-warning alert-dismissible fade show" role="alert">
                          {{message}}
                         <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                             </button>
                              </div>
                           {% endif %}
                            {% endfor %}
                           {% endif %}
                               {% if messages %}
                            {% for message in messages %}
                             {% if message.tags == 'info' %}
                           <div class="alert alert-warning alert-dismissible fade show" role="alert">
                          {{message}}
                         <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                             </button>
                              </div>
                           {% endif %}
                            {% endfor %}
                           {% endif %}
          <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 searchcomp %}
              <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>
          {% else %}
    {% if query %}
        <p style="font-size: 20px;color: blue;text-align: center;">No records found for: "{{ query }}"</p>
    
    {% endif %}

    
        </div>{% endif %}
        
      </div>
    </div>
    
    
  </div>
  {% endblock %}