{% extends 'base.html' %}

{% block title %}Supplier - {{ supplier.name }}{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h3 mb-0">
        <i class="bi bi-truck me-2"></i>
        Supplier Details
    </h1>
    <div>
        <a href="{% url 'inventory:supplier_list' %}" class="btn btn-outline-secondary me-2">
            <i class="bi bi-arrow-left me-2"></i>
            Back to List
        </a>
        <a href="#" class="btn btn-primary">
            <i class="bi bi-pencil me-2"></i>
            Edit
        </a>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="card-title mb-0">Supplier Information</h5>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <p><strong>Supplier Code:</strong> {{ supplier.code }}</p>
                        <p><strong>Name:</strong> {{ supplier.name }}</p>
                        <p><strong>Rating:</strong> 
                            <span class="badge bg-{% if supplier.rating >= 4 %}success{% elif supplier.rating >= 3 %}warning{% else %}danger{% endif %}">
                                {{ supplier.rating }}/5
                            </span>
                        </p>
                        <p><strong>Status:</strong> 
                            <span class="badge bg-{% if supplier.is_active %}success{% else %}secondary{% endif %}">
                                {{ supplier.is_active|yesno:"Active,Inactive" }}
                            </span>
                        </p>
                    </div>
                    <div class="col-md-6">
                        <p><strong>Contact Person:</strong> {{ supplier.contact_person|default:"Not set" }}</p>
                        <p><strong>Email:</strong> {{ supplier.email|default:"Not set" }}</p>
                        <p><strong>Phone:</strong> {{ supplier.phone|default:"Not set" }}</p>
                        <p><strong>Credit Limit:</strong> Rp {{ supplier.credit_limit|floatformat:0 }}</p>
                    </div>
                </div>
                
                {% if supplier.address %}
                <div class="mt-3">
                    <strong>Address:</strong>
                    <p class="mt-2">{{ supplier.address }}</p>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">Account Information</h5>
            </div>
            <div class="card-body">
                <p><strong>Supplier Since:</strong> {{ supplier.created_at|date:"d/m/Y" }}</p>
                <p><strong>Last Updated:</strong> {{ supplier.updated_at|date:"d/m/Y H:i" }}</p>
            </div>
        </div>
    </div>
</div>
{% endblock %}
