{% 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 Users</h4>
                <form method="get">
                    {% csrf_token %}
                   
                    <div class="form-group row">
                        <label class="col-sm-4 col-form-label">Search(By Mobilenumber, Complainant Name and Email)</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 searchusers %}
      
         
        {% 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;"> User Name</th>
                <th style="font-weight: bolder;"> Email</th>
                <th style="font-weight: bolder;"> Contcat Number</th>
               
                <th style="font-weight: bolder;"> Reg Date </th>
               
                <th style="font-weight: bolder;">Action </th>
              </tr>
            </thead>
            <tbody>
                {% for i in searchusers %}
              <tr>
                <td> {{ forloop.counter }} </td>
                <td>{{i.admin.first_name}} {{i.admin.last_name}}</td>
                <td>{{i.admin.email}}</td> 
                <td>{{i.mobilenumber}}</td>              
                <td>{{i.regdate_at}}</td>
               
                <td><a href="{% url 'viewusers' i.id %}" class="btn btn-success">
                    View</a> <a href="{% url 'delete_user' i.id %}" class="btn btn-danger">
                        DELETE</a> <a href="{% url 'view_complaints' i.id %}" class="btn btn-primary">
                            Complaints</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 %}