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


  <div class="row">
    <div class="col-md-12">
      <div class="card">
        <div class="table-responsive pt-3">
          <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 == 'success' %}
            <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 data_list %}
                  <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>
          <div class="pagination" style="padding-top: 10px;padding: left 10px;text-align: center;">
            <span class="step-links">
                {% if data_list.has_previous %}
                    <a href="?page=1">&laquo; first</a>
                    <a href="?page={{ data_list.previous_page_number }}">previous</a>
                {% endif %}
        
                <span class="current" style="padding-left: 10px;padding-bottom: 10px;">
                    Page {{ data_list.number }} of {{ data_list.paginator.num_pages }}.
                </span>
        
                {% if data_list.has_next %}
                    <a href="?page={{ data_list.next_page_number }}">next</a>
                    <a href="?page={{ data_list.paginator.num_pages }}">last &raquo;</a>
                {% endif %}
            </span>
        </div>
        </div>
      </div>
    </div>
  </div>
  {% endblock %}