{% extends "base.html" %}

{% block title %}Sales & Purchase Orders - {{ project.project_title }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header bg-info text-white">
            <h4 class="mb-0">Sales & Purchase Orders for Project: {{ project.project_title }}</h4>
        </div>
        <div class="card-body">
            <h5 class="text-primary">Purchase Orders</h5>
            {% if purchase_orders %}
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>PO Number</th>
                        <th>Supplier</th>
                        <th>Date</th>
                        <th>Status</th>
                        <th class="text-end">Total Amount</th>
                    </tr>
                </thead>
                <tbody>
                    {% for po in purchase_orders %}
                    <tr>
                        <td>{{ po.po_number }}</td>
                        <td>{{ po.supplier.name }}</td>
                        <td>{{ po.order_date }}</td>
                        <td>{{ po.status|capfirst }}</td>
                        <td class="text-end">{{ po.total_amount|floatformat:2 }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
            <p>No purchase orders for this project.</p>
            {% endif %}

            <div class="mt-3 text-end">
                <a href="{% url 'project_dashboard' project.id %}" class="btn btn-secondary">
                    <i class="bi bi-arrow-left"></i> Back to Dashboard
                </a>
            </div>
        </div>
    </div>
</div>
{% endblock %}
