{% extends "core/base.html" %}
{% load static %}

{% block title %}Suppliers{% endblock %}
{% block topbar_title %}Suppliers{% endblock %}

{% block content %}
<div class="container-fluid px-0">

    <div class="d-flex justify-content-between align-items-center mb-3">
        <h5 class="mb-0">Suppliers</h5>
        <a href="{% url 'inventory:supplier_create' %}" class="btn btn-primary btn-sm">
            <i class="fas fa-plus"></i> Add Supplier
        </a>
    </div>

    <div class="card shadow-sm">
        <div class="sp-table-container">
            <table class="table table-sm align-middle">
                <thead class="table-light">
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Total Purchases</th>
                        <th >Total Paid</th>
                        <th >Balance</th>
                        <th  class="text-end">Actions</th>
                    </tr>
                </thead>
                <tbody>
                {% for s in suppliers %}
                    <tr>
                        <td>{{ forloop.counter }}</td>
                        <td>{{ s.name }}</td>
                        <td>{{ currency_symbol }}{{ s.total_purchased|floatformat:2 }}</td>
                        <td>{{ currency_symbol }}{{ s.total_paid|floatformat:2 }}</td>
                        <td class="fw-bold text-danger">{{ currency_symbol }}{{ s.balance|floatformat:2 }}</td>
                        <td class="text-end">
                            <a href="{% url 'inventory:supplier_detail' s.id %}"
                               class="btn btn-outline-primary btn-sm">View</a>
                        </td>
                    </tr>
                {% empty %}
                    <tr><td colspan="6" class="text-center py-3 text-muted">No suppliers found.</td></tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

</div>
{% endblock %}
