{% extends 'base.html' %}
{% block content %}


  <div class="row">
   
    <div class="col-md-12">
      <div class="card">
        
        <div class="card-block" style="padding-left: 20px;padding-top: 20px;">
        <h4 class="sub-title">Search Records</h4>
        <form method="get">
            {% csrf_token %}
           
            <div class="form-group row">
                <label class="col-sm-4 col-form-label">Search(By Mobilenumber, Fullname 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>
        
        <div class="table-responsive pt-3">
            {% if searchdata %}
          <table class="table table-striped project-orders-table">
            {% 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 %}
            <thead>
                <tr>
                    <th class="ml-5">S.No</th>
                    <th>Full Name</th>
                    <th>Profession</th>
                    <th>Mobile Number</th>
                    <th>Status</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                  {% for i in searchdata %}
                  <tr>
                    <td>{{ forloop.counter }}</td>  <!-- Display serial number -->
                    <td>{{ i.fullname }}</td>       <!-- Display full name -->
                    <td>{{ i.profession }}</td>     <!-- Display profession -->
                    <td>{{ i.mobilenumber }}</td>   <!-- Display mobile number -->
                    {% if i.status == '2' %}
                    <td>Private</td>                <!-- Display status: Private if status is '1' -->
                    {% else %}
                    <td>Public</td>                 <!-- Display status: Public if status is not '1' -->
                    {% endif %}
                    <td>
                      <div class="d-flex align-items-center">
                        <a href="{% url 'view_data' i.id %}" class="btn btn-success btn-sm btn-icon-text mr-3">Edit Details <i class="typcn typcn-edit btn-icon-append"></i></a>
                        <a href="{% url 'delete_data' i.id %}" onclick="return confirm('Do you really want to delete?');" class="btn btn-danger btn-sm btn-icon-text" style="color:white">Delete <i class="typcn typcn-delete-outline btn-icon-append"></i></a>
                      </div>
                    </td>
                  </tr>
                  {% endfor %}
              
            </tbody>
        </div>
   
          </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 %}