{% extends "users/base.html" %}
{% block title %}List Email Accounts{% endblock title %}
{% block content %}

<div class="card card-default">
      <div class="card-header">
        <h2>List Email Accounts</h2>
		
        

      </div>
    
   <div class="card-body">
    <div class="row">
   <div class="col-xl-6">
   <a class="mb-1 btn btn-pill btn-success" href="{% url 'email_accounts_create' %}" role="button" style="text-transform: none;">+ Create Email</a>
</div>
<div class="col-xl-6 d-flex justify-content-end">
    <form action="{% url 'email_accounts' %}" method="post" class="form-inline mb-3">
        <div class="form-group mr-2">
            <input type="text" id="search" name="search" class="form-control" placeholder="Search for domains...">
        </div>
        {% csrf_token %}
        <button type="submit" class="btn btn-danger">Filter</button>
    </form>
	</div>
	</div>
<div class="table-responsive">
    <table class="table table-bordered">
        <thead class="thead-light">
             <tr>
                <th>Email</th>
                <th>Storage</th>
               
                <th>Actions</th>
            </tr>
        </thead>
        <tbody id="domainTable">
            {% for email in emails %}
            <tr>
                <td>{{ email.email }}</td>
                <td>{{ email.disk_usage }} / {{ email.DiskUsage }}</td>
                
                <td>
                   <a href="{% url 'email_edit' email.id %}" class="btn btn-outline-primary btn-sm">
  <i class="mdi mdi-square-edit-outline"></i> Manage
</a>

<a href="{% url 'webmail_service' email.email %}" class="btn btn-outline-success btn-sm">
  <i class="mdi mdi-email-open"></i> Check Email
</a>


<form action="{% url 'email_delete' email.id %}" method="post" style="display:inline;">
                        {% csrf_token %}
                        <button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirm('Are you sure you want to delete this email ?');"> <i class="mdi mdi-trash-can"></i> Delete</button>
                    </form>
      
                </td>
            </tr>
            {% empty %}
            <tr>
                <td colspan="4" class="text-center">No results found.</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
    <!-- No Results Message -->
    <div id="noResults" class="text-center text-danger" style="display:none;">No results found.</div>

</div>
</div>


{% endblock content %}

{% include "users/footer.html" %}